[Bug 21048] [SiS 630/730] Assertion failed when try to use Direct3D under wine

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=21048

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #6 from Ian Romanick  ---
The SIS driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/5d5ddc77/attachment.html>


[Bug 19883] fire_buffer: DRM_VIA_PCICMD returned -22

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=19883

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #1 from Ian Romanick  ---
The Unichrome driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/163a0a24/attachment-0001.html>


[Bug 9969] Heavy MGA DRI use causes Xorg lock

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=9969

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #8 from Ian Romanick  ---
The MGA driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/ec355f83/attachment.html>


[Bug 10191] compiz.real crashed with SIGSEGV in viaGetLock()

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=10191

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #2 from Ian Romanick  ---
The Unichrome driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/0b64ac31/attachment.html>


[Bug 7384] memory leak in via_screen.c & via_context.c (OptionCache)

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=7384

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #3 from Ian Romanick  ---
The Unichrome driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/ac8dc8d3/attachment.html>


[Bug 2068] Depth buffer issues with transparent objects (Unichrome).

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=2068

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #3 from Ian Romanick  ---
The Unichrome driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/d22c646b/attachment.html>


[Bug 5600] sis_tex.c Failure to allocate texture memory

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=5600

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #4 from Ian Romanick  ---
The sis driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/9393c8bc/attachment.html>


[Bug 3493] r128: Entire X-windowing system hangs during normal 3D gaming

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=3493

Ian Romanick  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |WONTFIX

--- Comment #18 from Ian Romanick  ---
The r128 driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/71622d42/attachment.html>


[Bug 3862] [r128] Seg. fault with r128 driver

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=3862

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #8 from Ian Romanick  ---
The r128 driver longer exists in Mesa.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/d9e4168d/attachment-0001.html>


[Bug 1236] Blender menus are not drawn with Matrox G400 DualHead(FreeBSD 4.10, Slackware-current)

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=1236

Ian Romanick  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #6 from Ian Romanick  ---
(In reply to Marcin Baczyński from comment #5)
> Probably the MGA bugs can be closed now that the driver is removed from git?

Yes. :)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/ab723423/attachment.html>


[Bug 92184] Many piglit assertion failures in radeon_unmap_renderbuffer

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=92184

--- Comment #1 from Ian Romanick  ---
It appears that this happens whenever a software fallback occurs... and there
are a lot of software fallbacks in the r100 drivers.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/cb1a52d2/attachment.html>


[Bug 76130] Radeon HD 4570 set dpm state fails after suspend

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=76130

--- Comment #21 from Thaddaeus Tintenfisch  ---
Now with kernel 4.4-rc3 the error messages are gone, but the performance issue
is still present (glxgears: ~440 FPS before suspend, ~180 FPS after).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/ae8dd1cd/attachment.html>


[RESEND] drm: imx: imx-tve: Fix module autoload for OF platform driver

2015-11-30 Thread Philipp Zabel
Hi Luis,

thanks for the reminder.

Am Montag, den 30.11.2015, 15:02 + schrieb Luis de Bethencourt:
> This platform driver has a OF device ID table but the OF module
> alias information is not created so module autoloading won't work.
> 
> Signed-off-by: Luis de Bethencourt 
> ---
> 
> Hi,
> 
> This is a resend of a patch from October 20th [0]

Sorry to have missed it, I was in the middle of a vacation then.
I've applied it to my fixes branch now.

> I am adding Andrew Morton to the CC list as was recommended at the Korea Linux
> Forum.
> 
> This patch adds the missing MODULE_DEVICE_TABLE() for OF to export
> that information so modules have the correct aliases built-in and
> autoloading works correctly.
> 
> A longer explanation by Javier Canillas can be found here:
> https://lkml.org/lkml/2015/7/30/519
> A multitude of similar patches have been merged for other drivers, search
> the git log for "module autoload for OF platform driver".
> 
> Thanks,
> Luis

regards
Philipp



[Bug 76490] Hang during boot when DPM is on (R9 270X)

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=76490

--- Comment #72 from Alex Deucher  ---
(In reply to Maxim Sheviakov from comment #71)
> Hmm, nice point. By the way, is the MCLK kinda divided by four? So, if
> Memory Clock is 5600MHz, I'll have to do 5600/4*1 to get the correct
> value? It's like, 12 value = 1.2GHz*4 = Original frequency = 4800MHz,
> right? If that's it, I'll fix my quirk (AGAIN, LOL) and try using 970MHz and
> 5600MHz written as needed, 'cause my GPU is MSI R7 370 Armor 2X, and looks
> like values in quirk are *kinda* low for it.

The mclk values are the actual mclk values.  GDDR5 is quad pumped so you get 4x
effective data rate per clock.  That might be what you are thinking of.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/850b0c6d/attachment.html>


[RFC PATCH 1/2] drm: add support for for clk and de polarity

2015-11-30 Thread Philipp Zabel
Am Freitag, den 27.11.2015, 09:37 +0200 schrieb Tomi Valkeinen:
> On 26/11/15 16:20, Manfred Schlaegl wrote:
> > Good to see that this discussion is triggered.
> 
> I seem to have missed this one. This is important for omapdrm also.
> We've had similar patch in TI's linux for a while, but I have never had
> time to start upstreaming it.
> 
> Two comments:
> 
> The "pixclock polarity" could be explained a bit, as it's not really
> about polarity. This was discussed when the display-timings stuff was
> worked on, and display-timings.txt explains what the "pixelclk-active"
> property means.

Yes, the relevant part of this setting is whether the panel will sample
the data bus on the falling or rising edge of the pixel clock signal.
The display interface has guarantee that the data bus is stable around
that time.

> So here I think you could maybe have a comment pointing to
> display-timings.txt, or perhaps a short comment about what the flag is.
> Or if you come up with a great name for the define, that's good too =).

We have the choice of describing the flag from point of view of the
display controller (as the DISPLAY_FLAGS do), from point of view of the
panel, or using a somewhat neutral description like in the device tree.
Which choice I'd prefer depends on whether the flags go into
drm_display_mode / drm_mode_modeinfo or in drm_display_info.

In any case, I think that it'd be better to talk about driving or
sampling data on rising or falling edges instead of clock polarity.

> The other comment is not about this patch as such, but similar flags
> that OMAP has, and possibly some other platforms too:
> 
> 1) sync signals driven on rising or falling edge of pixel clock
> 2) hsync and vsync happen at the same time or hsync happens first,
> followed by vsync
> 
> Any other platforms have similar features?

The i.MX6 display interface consists of a number of rather freely
configurable signal generators, so all of this should be possible to do.

regards
Philipp



[Bug 92850] Segfault loading War Thunder

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=92850

--- Comment #22 from bellamorte42 at gmail.com ---
Oh, I caught an error in the terminal during the crash.

context mis-match in pipe_sampler_view_release()

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/1a8127cf/attachment.html>


[PATCH v7 14/14] drm/mediatek: Add fence control, wait on GPU fence

2015-11-30 Thread Philipp Zabel
Wait on the exclusive fence for the incoming framebuffer, using
"wait_for_fences" from drm_atomic_helper.c, which needs to be exported
first.

Signed-off-by: CK Hu 
Signed-off-by: YT Shen 
Signed-off-by: Daniel Kurtz 
Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c  | 36 ++--
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h  |  1 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.c   |  2 ++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c | 22 ---
 4 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index ec0540f..69e8fe5 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -65,6 +65,8 @@ struct mtk_crtc_state {
struct drm_crtc_state   base;
struct drm_pending_vblank_event *event;

+   boolpending_needs_vblank;
+
boolpending_config;
unsigned intpending_width;
unsigned intpending_height;
@@ -100,10 +102,24 @@ static void mtk_drm_crtc_finish_page_flip(struct 
mtk_drm_crtc *mtk_crtc)
 {
struct drm_crtc *crtc = _crtc->base;
struct mtk_crtc_state *state = to_mtk_crtc_state(crtc->state);
+   unsigned long flags;

+   spin_lock_irqsave(>dev->event_lock, flags);
drm_send_vblank_event(crtc->dev, state->event->pipe, state->event);
drm_crtc_vblank_put(crtc);
state->event = NULL;
+   spin_unlock_irqrestore(>dev->event_lock, flags);
+}
+
+static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
+{
+   struct mtk_crtc_state *state = to_mtk_crtc_state(mtk_crtc->base.state);
+
+   drm_handle_vblank(mtk_crtc->base.dev, mtk_crtc->pipe);
+   if (state->pending_needs_vblank) {
+   mtk_drm_crtc_finish_page_flip(mtk_crtc);
+   state->pending_needs_vblank = false;
+   }
 }

 static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
@@ -391,10 +407,26 @@ void mtk_drm_crtc_commit(struct drm_crtc *crtc)
}
 }

+void mtk_drm_crtc_check_flush(struct drm_crtc *crtc)
+{
+   struct mtk_crtc_state *state = to_mtk_crtc_state(crtc->state);
+   struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
+
+   if (mtk_crtc->do_flush) {
+   if (state->event)
+   state->pending_needs_vblank = true;
+   mtk_drm_crtc_commit(crtc);
+   mtk_crtc->do_flush = false;
+   }
+}
+
 static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
  struct drm_crtc_state *old_crtc_state)
 {
-   mtk_drm_crtc_commit(crtc);
+   struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
+
+   mtk_crtc->do_flush = true;
+   mtk_drm_crtc_check_flush(crtc);
 }

 static const struct drm_crtc_funcs mtk_crtc_funcs = {
@@ -482,7 +514,7 @@ void mtk_crtc_ddp_irq(struct drm_device *drm_dev, struct 
mtk_ddp_comp *ovl)
}
}

-   drm_handle_vblank(mtk_crtc->base.dev, mtk_crtc->pipe);
+   mtk_drm_finish_page_flip(mtk_crtc);
 }

 int mtk_drm_crtc_create(struct drm_device *drm_dev,
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
index f04854f..94eba3c 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
@@ -22,6 +22,7 @@

 int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe);
 void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe);
+void mtk_drm_crtc_check_flush(struct drm_crtc *crtc);
 void mtk_drm_crtc_commit(struct drm_crtc *crtc);
 void mtk_crtc_ddp_irq(struct drm_device *drm_dev, struct mtk_ddp_comp *ovl);
 int mtk_drm_crtc_create(struct drm_device *drm_dev,
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 2d5bd16..e6d8adf 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -49,6 +49,8 @@ static void mtk_atomic_complete(struct mtk_drm_private 
*private,
 {
struct drm_device *drm = private->drm;

+   drm_atomic_helper_wait_for_fences(drm, state);
+
drm_atomic_helper_commit_modeset_disables(drm, state);
drm_atomic_helper_commit_planes(drm, state, false);
drm_atomic_helper_commit_modeset_enables(drm, state);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c 
b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index c0b62d1..343c060 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -123,6 +123,8 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
  struct drm_plane_state *state)
 {
struct drm_framebuffer *fb = state->fb;
+   struct drm_gem_object *gem;
+   struct reservation_object *resv;
struct drm_crtc_state *crtc_state;
   

[PATCH v7 13/14] drm/atomic-helper: Export drm_atomic_helper_wait_for_fences

2015-11-30 Thread Philipp Zabel
From: Daniel Kurtz 

This is useful for drivers that want to implement async commits, but
need to wait on per-plane fences.

Signed-off-by: Daniel Kurtz 
Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/drm_atomic_helper.c | 7 ---
 include/drm/drm_atomic_helper.h | 2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 0c6f621..ce84d99 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -886,8 +886,8 @@ void drm_atomic_helper_commit_modeset_enables(struct 
drm_device *dev,
 }
 EXPORT_SYMBOL(drm_atomic_helper_commit_modeset_enables);

-static void wait_for_fences(struct drm_device *dev,
-   struct drm_atomic_state *state)
+void drm_atomic_helper_wait_for_fences(struct drm_device *dev,
+  struct drm_atomic_state *state)
 {
struct drm_plane *plane;
struct drm_plane_state *plane_state;
@@ -904,6 +904,7 @@ static void wait_for_fences(struct drm_device *dev,
plane->state->fence = NULL;
}
 }
+EXPORT_SYMBOL(drm_atomic_helper_wait_for_fences);

 static bool framebuffer_changed(struct drm_device *dev,
struct drm_atomic_state *old_state,
@@ -1049,7 +1050,7 @@ int drm_atomic_helper_commit(struct drm_device *dev,
 * current layout.
 */

-   wait_for_fences(dev, state);
+   drm_atomic_helper_wait_for_fences(dev, state);

drm_atomic_helper_commit_modeset_disables(dev, state);

diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 8cba54a..92b5699 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -42,6 +42,8 @@ int drm_atomic_helper_commit(struct drm_device *dev,
 struct drm_atomic_state *state,
 bool async);

+void drm_atomic_helper_wait_for_fences(struct drm_device *dev,
+  struct drm_atomic_state *state);
 void drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
struct drm_atomic_state *old_state);

-- 
2.6.2



[PATCH v7 12/14] dt-bindings: hdmi-connector: add DDC I2C bus phandle documentation

2015-11-30 Thread Philipp Zabel
Add an optional ddc-i2c-bus phandle property that points to
an I2C master controller that handles the connector DDC pins.

Signed-off-by: Philipp Zabel 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/display/connector/hdmi-connector.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt 
b/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
index acd5668..508aee4 100644
--- a/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
+++ b/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
@@ -8,6 +8,7 @@ Required properties:
 Optional properties:
 - label: a symbolic name for the connector
 - hpd-gpios: HPD GPIO number
+- ddc-i2c-bus: phandle link to the I2C controller used for DDC EDID probing

 Required nodes:
 - Video port for HDMI input
-- 
2.6.2



[PATCH v7 11/14] clk: mediatek: Add hdmi_ref HDMI PHY PLL reference clock output

2015-11-30 Thread Philipp Zabel
The configurable hdmi_ref output of the PLL block is derived from
the tvdpll_594m clock signal via a configurable PLL post-divider.
It is used as the PLL reference input to the HDMI PHY module.

Signed-off-by: Philipp Zabel 
Acked-by: James Liao 
---
 drivers/clk/mediatek/clk-mt8173.c  | 5 +
 include/dt-bindings/clock/mt8173-clk.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/mediatek/clk-mt8173.c 
b/drivers/clk/mediatek/clk-mt8173.c
index b305fa2..d7eadda 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -1091,6 +1091,11 @@ static void __init mtk_apmixedsys_init(struct 
device_node *node)
clk_data->clks[cku->id] = clk;
}

+   clk = clk_register_divider(NULL, "hdmi_ref", "tvdpll_594m", 0,
+  base + 0x40, 16, 3, CLK_DIVIDER_POWER_OF_TWO,
+  NULL);
+   clk_data->clks[CLK_APMIXED_HDMI_REF] = clk;
+
r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
if (r)
pr_err("%s(): could not register clock provider: %d\n",
diff --git a/include/dt-bindings/clock/mt8173-clk.h 
b/include/dt-bindings/clock/mt8173-clk.h
index 7956ba1..6094bf7 100644
--- a/include/dt-bindings/clock/mt8173-clk.h
+++ b/include/dt-bindings/clock/mt8173-clk.h
@@ -176,7 +176,8 @@
 #define CLK_APMIXED_LVDSPLL13
 #define CLK_APMIXED_MSDCPLL2   14
 #define CLK_APMIXED_REF2USB_TX 15
-#define CLK_APMIXED_NR_CLK 16
+#define CLK_APMIXED_HDMI_REF   16
+#define CLK_APMIXED_NR_CLK 17

 /* INFRA_SYS */

-- 
2.6.2



[PATCH v7 10/14] clk: mediatek: make dpi0_sel and hdmi_sel not propagate rate changes

2015-11-30 Thread Philipp Zabel
These muxes are supposed to select a fitting divider after the PLL
is already set to the correct rate.

Signed-off-by: Philipp Zabel 
Acked-by: James Liao 
---
 drivers/clk/mediatek/clk-mt8173.c | 4 ++--
 drivers/clk/mediatek/clk-mtk.h| 7 +--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8173.c 
b/drivers/clk/mediatek/clk-mt8173.c
index 227e356..b305fa2 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -558,7 +558,7 @@ static const struct mtk_composite top_muxes[] __initconst = 
{
MUX_GATE(CLK_TOP_ATB_SEL, "atb_sel", atb_parents, 0x0090, 16, 2, 23),
MUX_GATE(CLK_TOP_VENC_LT_SEL, "venclt_sel", venc_lt_parents, 0x0090, 
24, 4, 31),
/* CLK_CFG_6 */
-   MUX_GATE(CLK_TOP_DPI0_SEL, "dpi0_sel", dpi0_parents, 0x00a0, 0, 3, 7),
+   MUX_GATE_FLAGS(CLK_TOP_DPI0_SEL, "dpi0_sel", dpi0_parents, 0x00a0, 0, 
3, 7, 0),
MUX_GATE(CLK_TOP_IRDA_SEL, "irda_sel", irda_parents, 0x00a0, 8, 2, 15),
MUX_GATE(CLK_TOP_CCI400_SEL, "cci400_sel", cci400_parents, 0x00a0, 16, 
3, 23),
MUX_GATE(CLK_TOP_AUD_1_SEL, "aud_1_sel", aud_1_parents, 0x00a0, 24, 2, 
31),
@@ -569,7 +569,7 @@ static const struct mtk_composite top_muxes[] __initconst = 
{
MUX_GATE(CLK_TOP_SCAM_SEL, "scam_sel", scam_parents, 0x00b0, 24, 2, 31),
/* CLK_CFG_12 */
MUX_GATE(CLK_TOP_SPINFI_IFR_SEL, "spinfi_ifr_sel", spinfi_ifr_parents, 
0x00c0, 0, 3, 7),
-   MUX_GATE(CLK_TOP_HDMI_SEL, "hdmi_sel", hdmi_parents, 0x00c0, 8, 2, 15),
+   MUX_GATE_FLAGS(CLK_TOP_HDMI_SEL, "hdmi_sel", hdmi_parents, 0x00c0, 8, 
2, 15, 0),
MUX_GATE(CLK_TOP_DPILVDS_SEL, "dpilvds_sel", dpilvds_parents, 0x00c0, 
24, 3, 31),
/* CLK_CFG_13 */
MUX_GATE(CLK_TOP_MSDC50_2_H_SEL, "msdc50_2_h_sel", msdc50_2_h_parents, 
0x00d0, 0, 3, 7),
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index 32d2e45..b607996 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -83,7 +83,7 @@ struct mtk_composite {
signed char num_parents;
 };

-#define MUX_GATE(_id, _name, _parents, _reg, _shift, _width, _gate) {  \
+#define MUX_GATE_FLAGS(_id, _name, _parents, _reg, _shift, _width, _gate, 
_flags) {\
.id = _id,  \
.name = _name,  \
.mux_reg = _reg,\
@@ -94,9 +94,12 @@ struct mtk_composite {
.divider_shift = -1,\
.parent_names = _parents,   \
.num_parents = ARRAY_SIZE(_parents),\
-   .flags = CLK_SET_RATE_PARENT,   \
+   .flags = _flags,\
}

+#define MUX_GATE(_id, _name, _parents, _reg, _shift, _width, _gate)\
+   MUX_GATE_FLAGS(_id, _name, _parents, _reg, _shift, _width, _gate, 
CLK_SET_RATE_PARENT)
+
 #define MUX(_id, _name, _parents, _reg, _shift, _width) {  \
.id = _id,  \
.name = _name,  \
-- 
2.6.2



[PATCH v7 09/14] arm64: dts: mt8173: Add HDMI related nodes

2015-11-30 Thread Philipp Zabel
From: CK Hu 

This patch adds the device nodes for the HDMI encoder, HDMI PHY,
and HDMI CEC modules.

Signed-off-by: CK Hu 
Signed-off-by: Cawa Cheng 
Signed-off-by: Jie Qiu 
Signed-off-by: Daniel Kurtz 
Signed-off-by: Philipp Zabel 
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 71 
 1 file changed, 71 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index e185f88..13a11ee 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -199,6 +199,30 @@
 ,
 ;

+   hdmi_pin: xxx {
+
+   /*hdmi htplg pin*/
+   pins1 {
+   pinmux = 
;
+   input-enable;
+   bias-pull-down;
+   };
+
+   /*hdmi flt 5v pin*/
+   pins2 {
+   pinmux = 
;
+   input-enable;
+   bias-pull-up;
+   };
+
+   /*hdmi 5v pin*/
+   pins3 {
+   pinmux = 
;
+   output-enable;
+   bias-pull-up;
+   };
+   };
+
i2c0_pins_a: i2c0 {
pins1 {
pinmux = 
,
@@ -277,6 +301,13 @@
clock-names = "spi", "wrap";
};

+   cec: cec at 10013000 {
+   compatible = "mediatek,mt8173-cec";
+   reg = <0 0x10013000 0 0xbc>;
+   interrupts = ;
+   clocks = < CLK_INFRA_CEC>;
+   };
+
sysirq: intpol-controller at 10200620 {
compatible = "mediatek,mt8173-sysirq",
 "mediatek,mt6577-sysirq";
@@ -303,6 +334,16 @@
#clock-cells = <1>;
};

+   hdmi_phy: hdmi-phy at 10209100 {
+   compatible = "mediatek,mt8173-hdmi-phy";
+   reg = <0 0x10209100 0 0x24>;
+   clocks = < CLK_APMIXED_HDMI_REF>;
+   clock-names = "pll_ref";
+   mediatek,ibias = <0xa>;
+   mediatek,ibias_up = <0x1c>;
+   #phy-cells = <0>;
+   };
+
mipi_tx0: mipi-dphy at 10215000 {
compatible = "mediatek,mt8173-mipi-tx";
reg = <0 0x10215000 0 0x1000>;
@@ -823,6 +864,36 @@
clock-names = "apb", "smi";
};

+   hdmi0: hdmi at 14025000 {
+   compatible = "mediatek,mt8173-hdmi";
+   reg = <0 0x14025000 0 0x400>;
+   interrupts = ;
+   clocks = < CLK_MM_HDMI_PIXEL>,
+< CLK_MM_HDMI_PLLCK>,
+< CLK_MM_HDMI_AUDIO>,
+< CLK_MM_HDMI_SPDIF>;
+   clock-names = "pixel", "pll", "bclk", "spdif";
+   pinctrl-names = "default";
+   pinctrl-0 = <_pin>;
+   phys = <_phy>;
+   phy-names = "hdmi";
+   mediatek,syscon-hdmi = < 0x900>;
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   reg = <0>;
+
+   hdmi0_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+   };
+   };
+
larb4: larb at 14027000 {
compatible = "mediatek,mt8173-smi-larb";
reg = <0 0x14027000 0 0x1000>;
-- 
2.6.2



[PATCH v7 08/14] arm64: dts: mt8173: Add display subsystem related nodes

2015-11-30 Thread Philipp Zabel
From: CK Hu 

This patch adds the device nodes for the DISP function blocks
comprising the display subsystem.

Signed-off-by: CK Hu 
Signed-off-by: Cawa Cheng 
Signed-off-by: Jie Qiu 
Signed-off-by: Daniel Kurtz 
Signed-off-by: Philipp Zabel 
---
TODO:
 - The power-domain property should be added to all blocks
   that are in the MM power domain.
 - The iommus property should be removed from the mmsys node.
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 211 +++
 1 file changed, 211 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 68010d9..e185f88 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -26,6 +26,23 @@
#address-cells = <2>;
#size-cells = <2>;

+   aliases {
+   ovl0 = 
+   ovl1 = 
+   rdma0 = 
+   rdma1 = 
+   rdma2 = 
+   wdma0 = 
+   wdma1 = 
+   color0 = 
+   color1 = 
+   split0 = 
+   split1 = 
+   dpi0 = 
+   dsi0 = 
+   dsi1 = 
+   };
+
cpus {
#address-cells = <1>;
#size-cells = <0>;
@@ -286,6 +303,18 @@
#clock-cells = <1>;
};

+   mipi_tx0: mipi-dphy at 10215000 {
+   compatible = "mediatek,mt8173-mipi-tx";
+   reg = <0 0x10215000 0 0x1000>;
+   #phy-cells = <0>;
+   };
+
+   mipi_tx1: mipi-dphy at 10216000 {
+   compatible = "mediatek,mt8173-mipi-tx";
+   reg = <0 0x10216000 0 0x1000>;
+   #phy-cells = <0>;
+   };
+
gic: interrupt-controller at 1022 {
compatible = "arm,gic-400";
#interrupt-cells = <3>;
@@ -432,6 +461,14 @@
status = "disabled";
};

+   hdmiddc0: i2c at 11012000 {
+   compatible = "mediatek,mt8173-hdmi-ddc";
+   interrupts = ;
+   reg = <0 0x11012000 0 0x1C>;
+   clocks = < CLK_PERI_I2C5>;
+   clock-names = "ddc-i2c";
+   };
+
i2c6: i2c at 11013000 {
compatible = "mediatek,mt8173-i2c";
reg = <0 0x11013000 0 0x70>,
@@ -568,7 +605,167 @@
mmsys: clock-controller at 1400 {
compatible = "mediatek,mt8173-mmsys", "syscon";
reg = <0 0x1400 0 0x1000>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
#clock-cells = <1>;
+
+   /* FIXME - remove iommus here */
+   iommus = < M4U_LARB0_ID M4U_PORT_DISP_OVL0>,
+< M4U_LARB4_ID M4U_PORT_DISP_OVL1>;
+   };
+
+   ovl0: ovl at 1400c000 {
+   compatible = "mediatek,mt8173-disp-ovl";
+   reg = <0 0x1400c000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_MM_DISP_OVL0>;
+   iommus = < M4U_LARB0_ID M4U_PORT_DISP_OVL0>;
+   mediatek,larb = <>;
+   };
+
+   ovl1: ovl at 1400d000 {
+   compatible = "mediatek,mt8173-disp-ovl";
+   reg = <0 0x1400d000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_MM_DISP_OVL1>;
+   iommus = < M4U_LARB4_ID M4U_PORT_DISP_OVL1>;
+   mediatek,larb = <>;
+   };
+
+   rdma0: rdma at 1400e000 {
+   compatible = "mediatek,mt8173-disp-rdma";
+   reg = <0 0x1400e000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_MM_DISP_RDMA0>;
+   iommus = < M4U_LARB0_ID M4U_PORT_DISP_RDMA0>;
+   mediatek,larb = <>;
+   };
+
+   rdma1: rdma at 1400f000 {
+   compatible = "mediatek,mt8173-disp-rdma";
+   reg = <0 0x1400f000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_MM_DISP_RDMA1>;
+   iommus = < M4U_LARB4_ID M4U_PORT_DISP_RDMA1>;
+   mediatek,larb = <>;
+   };
+
+   rdma2: rdma at 1401 {
+   compatible = "mediatek,mt8173-disp-rdma";
+   reg = <0 0x1401 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_MM_DISP_RDMA2>;
+   iommus = < M4U_LARB4_ID 

[PATCH v7 07/14] drm/mediatek: enable hdmi output control bit

2015-11-30 Thread Philipp Zabel
From: Jie Qiu 

MT8173 HDMI hardware has a output control bit to enable/disable HDMI
output. Because of security reason, so this bit can ONLY be controlled
in ARM supervisor mode. Now the only way to enter ARM supervisor is the
ARM trusted firmware. So atf provides a API for HDMI driver to call to
setup this HDMI control bit to enable HDMI output in supervisor mode.

Signed-off-by: Jie Qiu 
Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/mediatek/mtk_hdmi_hw.c   | 11 +++
 drivers/gpu/drm/mediatek/mtk_hdmi_regs.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_hw.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi_hw.c
index 7652266..8bee167 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi_hw.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi_hw.c
@@ -19,8 +19,15 @@
 #include 
 #include 
 #include 
+#include 
 #include 

+static int (*invoke_psci_fn)(u64, u64, u64, u64);
+typedef int (*psci_initcall_t)(const struct device_node *);
+
+asmlinkage int __invoke_psci_fn_hvc(u64, u64, u64, u64);
+asmlinkage int __invoke_psci_fn_smc(u64, u64, u64, u64);
+
 static u32 mtk_hdmi_read(struct mtk_hdmi *hdmi, u32 offset)
 {
return readl(hdmi->regs + offset);
@@ -170,6 +177,10 @@ void mtk_hdmi_hw_vid_black(struct mtk_hdmi *hdmi,

 void mtk_hdmi_hw_make_reg_writable(struct mtk_hdmi *hdmi, bool enable)
 {
+   invoke_psci_fn = __invoke_psci_fn_smc;
+   invoke_psci_fn(MTK_SIP_SET_AUTHORIZED_SECURE_REG,
+  0x14000904, 0x8000, 0);
+
regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20,
   HDMI_PCLK_FREE_RUN, enable ? HDMI_PCLK_FREE_RUN : 0);
regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C,
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_regs.h 
b/drivers/gpu/drm/mediatek/mtk_hdmi_regs.h
index de7ee22..8d7d60a 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi_regs.h
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi_regs.h
@@ -218,4 +218,5 @@
 #define MHL_SYNC_AUTO_EN   BIT(30)
 #define HDMI_PCLK_FREE_RUN BIT(31)

+#define MTK_SIP_SET_AUTHORIZED_SECURE_REG 0x8201
 #endif
-- 
2.6.2



[PATCH v7 06/14] drm/mediatek: Add HDMI support

2015-11-30 Thread Philipp Zabel
From: Jie Qiu 

This patch adds drivers for the HDMI bridge connected to the DPI0
display subsystem function block, for the HDMI DDC block, and for
the HDMI PHY to support HDMI output.

Signed-off-by: Jie Qiu 
Signed-off-by: Philipp Zabel 
---
Changes since v6:
 - Removed mtk_hdmi_audio_data / mtk-hdmi-codec platform device creation
   for now, this will be reworked.
---
 drivers/gpu/drm/mediatek/Kconfig |   6 +
 drivers/gpu/drm/mediatek/Makefile|   8 +
 drivers/gpu/drm/mediatek/mtk_cec.c   | 245 +
 drivers/gpu/drm/mediatek/mtk_cec.h   |  25 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.c   |   1 +
 drivers/gpu/drm/mediatek/mtk_drm_hdmi_drv.c  | 609 +
 drivers/gpu/drm/mediatek/mtk_hdmi.c  | 484 +
 drivers/gpu/drm/mediatek/mtk_hdmi.h  | 113 
 drivers/gpu/drm/mediatek/mtk_hdmi_ddc_drv.c  | 362 +
 drivers/gpu/drm/mediatek/mtk_hdmi_hw.c   | 757 +++
 drivers/gpu/drm/mediatek/mtk_hdmi_hw.h   |  76 +++
 drivers/gpu/drm/mediatek/mtk_hdmi_phy.c  | 340 
 drivers/gpu/drm/mediatek/mtk_hdmi_phy.h  |  20 +
 drivers/gpu/drm/mediatek/mtk_hdmi_phy_regs.h | 118 +
 drivers/gpu/drm/mediatek/mtk_hdmi_regs.h | 221 
 include/drm/mediatek/mtk_hdmi_audio.h| 137 +
 16 files changed, 3522 insertions(+)
 create mode 100644 drivers/gpu/drm/mediatek/mtk_cec.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_cec.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_hdmi_drv.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi_ddc_drv.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi_hw.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi_hw.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi_phy.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi_phy.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi_phy_regs.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_hdmi_regs.h
 create mode 100644 include/drm/mediatek/mtk_hdmi_audio.h

diff --git a/drivers/gpu/drm/mediatek/Kconfig b/drivers/gpu/drm/mediatek/Kconfig
index 5343cf1..85af51c 100644
--- a/drivers/gpu/drm/mediatek/Kconfig
+++ b/drivers/gpu/drm/mediatek/Kconfig
@@ -14,3 +14,9 @@ config DRM_MEDIATEK
  This driver provides kernel mode setting and
  buffer management to userspace.

+config DRM_MEDIATEK_HDMI
+   tristate "DRM HDMI Support for Mediatek SoCs"
+   depends on DRM_MEDIATEK
+   select GENERIC_PHY
+   help
+ DRM/KMS HDMI driver for Mediatek SoCs
diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index cee9b23..d02cc19 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -12,3 +12,11 @@ mediatek-drm-y := mtk_disp_ovl.o \

 obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o

+mediatek-drm-hdmi-objs := mtk_drm_hdmi_drv.o \
+ mtk_cec.o \
+ mtk_hdmi_ddc_drv.o \
+ mtk_hdmi.o \
+ mtk_hdmi_hw.o \
+ mtk_hdmi_phy.o
+
+obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mediatek-drm-hdmi.o
diff --git a/drivers/gpu/drm/mediatek/mtk_cec.c 
b/drivers/gpu/drm/mediatek/mtk_cec.c
new file mode 100644
index 000..c339d2f
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/mtk_cec.c
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Jie Qiu 
+ *
+ * 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.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_cec.h"
+
+#define TR_CONFIG  0x00
+#define CLEAR_CEC_IRQ  BIT(15)
+
+#define CEC_CKGEN  0x04
+#define CEC_32K_PDNBIT(19)
+#define PDNBIT(16)
+
+#define RX_EVENT   0x54
+#define HDMI_PORD  BIT(25)
+#define HDMI_HTPLG BIT(24)
+#define HDMI_PORD_INT_EN   BIT(9)
+#define HDMI_HTPLG_INT_EN  BIT(8)
+
+#define RX_GEN_WD  0x58
+#define HDMI_PORD_INT_32K_STATUS   BIT(26)
+#define RX_RISC_INT_32K_STATUS BIT(25)
+#define HDMI_HTPLG_INT_32K_STATUS  BIT(24)
+#define HDMI_PORD_INT_32K_CLR  BIT(18)
+#define RX_INT_32K_CLR BIT(17)
+#define HDMI_HTPLG_INT_32K_CLR BIT(16)
+#define HDMI_PORD_INT_32K_STA_MASK BIT(10)
+#define RX_RISC_INT_32K_STA_MASK   BIT(9)
+#define 

[PATCH v7 05/14] dt-bindings: drm/mediatek: Add Mediatek HDMI dts binding

2015-11-30 Thread Philipp Zabel
Add the device tree binding documentation for Mediatek HDMI,
HDMI PHY and HDMI DDC devices.

Signed-off-by: Philipp Zabel 
Acked-by: Rob Herring 
---
 .../bindings/display/mediatek/mediatek,hdmi.txt| 142 +
 1 file changed, 142 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt

diff --git 
a/Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt 
b/Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt
new file mode 100644
index 000..e3dde29
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,hdmi.txt
@@ -0,0 +1,142 @@
+Mediatek HDMI Encoder
+=
+
+The Mediatek HDMI encoder can generate HDMI 1.4a or MHL 2.0 signals from
+its parallel input.
+
+Required properties:
+- compatible: Should be "mediatek,-hdmi".
+- reg: Physical base address and length of the controller's registers
+- interrupts: The interrupt signal from the function block.
+- clocks: device clocks
+  See Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
+- clock-names: must contain "pixel", "pll", "bclk", and "spdif".
+- phys: phandle link to the HDMI PHY node.
+  See Documentation/devicetree/bindings/phy/phy-bindings.txt for details.
+- phy-names: must contain "hdmi"
+- mediatek,syscon-hdmi: phandle link and register offset to the system
+  configuration registers. For mt8173 this must be offset 0x900 into the
+  MMSYS_CONFIG region: < 0x900>.
+- ports: A node containing input and output port nodes with endpoint
+  definitions as documented in Documentation/devicetree/bindings/graph.txt.
+- port at 0: The input port in the ports node should be connected to a DPI 
output
+  port.
+- port at 1: The output port in the ports node should be connected to the input
+  port of a connector node that contains a ddc-i2c-bus property, or to the
+  input port of an attached bridge chip, such as a SlimPort transmitter.
+
+HDMI CEC
+
+
+The HDMI CEC controller handles hotplug detection and CEC communication.
+
+Required properties:
+- compatible: Should be "mediatek,-cec"
+- reg: Physical base address and length of the controller's registers
+- interrupts: The interrupt signal from the function block.
+- clocks: device clock
+
+HDMI DDC
+
+
+The HDMI DDC i2c controller is used to interface with the HDMI DDC pins.
+The Mediatek's I2C controller is used to interface with I2C devices.
+
+Required properties:
+- compatible: Should be "mediatek,-hdmi-ddc"
+- reg: Physical base address and length of the controller's registers
+- clocks: device clock
+- clock-names: Should be "ddc-i2c".
+
+HDMI PHY
+
+
+The HDMI PHY serializes the HDMI encoder's three channel 10-bit parallel
+output and drives the HDMI pads.
+
+Required properties:
+- compatible: "mediatek,-hdmi-phy"
+- reg: Physical base address and length of the module's registers
+- clocks: PLL reference clock
+- clock-names: must contain "pll_ref"
+- #phy-cells: must be <0>.
+
+Optional properties:
+- mediatek,ibias: TX DRV bias current for <1.65Gbps, defaults to 0xa
+- mediatek,ibias_up: TX DRV bias current for >1.65Gbps, defaults to 0x1c
+
+Example:
+
+cec: cec at 10013000 {
+   compatible = "mediatek,mt8173-cec";
+   reg = <0 0x10013000 0 0xbc>;
+   interrupts = ;
+   clocks = < CLK_INFRA_CEC>;
+};
+
+hdmi_phy: hdmi-phy at 10209100 {
+   compatible = "mediatek,mt8173-hdmi-phy";
+   reg = <0 0x10209100 0 0x24>;
+   clocks = < CLK_APMIXED_HDMI_REF>;
+   clock-names = "pll_ref";
+   mediatek,ibias = <0xa>;
+   mediatek,ibias_up = <0x1c>;
+   #phy-cells = <0>;
+};
+
+hdmi_ddc0: i2c at 11012000 {
+   compatible = "mediatek,mt8173-hdmi-ddc";
+   reg = <0 0x11012000 0 0x1c>;
+   interrupts = ;
+   clocks = < CLK_PERI_I2C5>;
+   clock-names = "ddc-i2c";
+};
+
+hdmi0: hdmi at 14025000 {
+   compatible = "mediatek,mt8173-hdmi";
+   reg = <0 0x14025000 0 0x400>;
+   interrupts = ;
+   clocks = < CLK_MM_HDMI_PIXEL>,
+< CLK_MM_HDMI_PLLCK>,
+< CLK_MM_HDMI_AUDIO>,
+< CLK_MM_HDMI_SPDIF>;
+   clock-names = "pixel", "pll", "bclk", "spdif";
+   pinctrl-names = "default";
+   pinctrl-0 = <_pin>;
+   phys = <_phy>;
+   phy-names = "hdmi";
+   mediatek,syscon-hdmi = < 0x900>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port at 0 {
+   reg = <0>;
+
+   hdmi0_in: endpoint {
+   remote-endpoint = <_out>;
+   };
+   };
+
+   port at 1 {
+   reg = <1>;
+
+   hdmi0_out: endpoint {
+   remote-endpoint = <_con_in>;
+   };
+   };
+   };
+};
+
+connector {
+   compatible = "hdmi-connector";
+   type = "a";

[PATCH v7 04/14] drm/mediatek: Add DPI sub driver

2015-11-30 Thread Philipp Zabel
From: Jie Qiu 

Add DPI connector/encoder to support HDMI output via the
attached HDMI bridge.

Signed-off-by: Jie Qiu 
Signed-off-by: Philipp Zabel 
---
Changes since v6:
 - Added mtk_dpi_power_on/off refcounting and mtk_ddp_component start/stop
   callbacks to keep pixel clock enabled until crtc_disable
---
 drivers/gpu/drm/mediatek/Makefile   |   3 +-
 drivers/gpu/drm/mediatek/mtk_dpi.c  | 744 
 drivers/gpu/drm/mediatek/mtk_dpi.h  |  84 
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h | 228 ++
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  |   1 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.h  |   1 +
 6 files changed, 1060 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dpi.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dpi.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dpi_regs.h

diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index 573f209..cee9b23 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -7,7 +7,8 @@ mediatek-drm-y := mtk_disp_ovl.o \
  mtk_drm_gem.o \
  mtk_drm_plane.o \
  mtk_dsi.o \
- mtk_mipi_tx.o
+ mtk_mipi_tx.o \
+ mtk_dpi.o

 obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o

diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c 
b/drivers/gpu/drm/mediatek/mtk_dpi.c
new file mode 100644
index 000..1a2cd9f
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
@@ -0,0 +1,744 @@
+/*
+ * Copyright (c) 2014 MediaTek Inc.
+ * Author: Jie Qiu 
+ *
+ * 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.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_dpi.h"
+#include "mtk_dpi_regs.h"
+
+enum mtk_dpi_polarity {
+   MTK_DPI_POLARITY_RISING,
+   MTK_DPI_POLARITY_FALLING,
+};
+
+struct mtk_dpi_polarities {
+   enum mtk_dpi_polarity de_pol;
+   enum mtk_dpi_polarity ck_pol;
+   enum mtk_dpi_polarity hsync_pol;
+   enum mtk_dpi_polarity vsync_pol;
+};
+
+struct mtk_dpi_sync_param {
+   u32 sync_width;
+   u32 front_porch;
+   u32 back_porch;
+   bool shift_half_line;
+};
+
+struct mtk_dpi_yc_limit {
+   u16 y_top;
+   u16 y_bottom;
+   u16 c_top;
+   u16 c_bottom;
+};
+
+static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask)
+{
+   u32 tmp = readl(dpi->regs + offset) & ~mask;
+
+   tmp |= (val & mask);
+   writel(tmp, dpi->regs + offset);
+}
+
+static void mtk_dpi_sw_reset(struct mtk_dpi *dpi, bool reset)
+{
+   mtk_dpi_mask(dpi, DPI_RET, reset ? RST : 0, RST);
+}
+
+static void mtk_dpi_enable(struct mtk_dpi *dpi)
+{
+   mtk_dpi_mask(dpi, DPI_EN, EN, EN);
+}
+
+static void mtk_dpi_disable(struct mtk_dpi *dpi)
+{
+   mtk_dpi_mask(dpi, DPI_EN, 0, EN);
+}
+
+static void mtk_dpi_config_hsync(struct mtk_dpi *dpi,
+struct mtk_dpi_sync_param *sync)
+{
+   mtk_dpi_mask(dpi, DPI_TGEN_HWIDTH,
+ sync->sync_width << HPW, HPW_MASK);
+   mtk_dpi_mask(dpi, DPI_TGEN_HPORCH,
+ sync->back_porch << HBP, HBP_MASK);
+   mtk_dpi_mask(dpi, DPI_TGEN_HPORCH, sync->front_porch << HFP,
+ HFP_MASK);
+}
+
+static void mtk_dpi_config_vsync(struct mtk_dpi *dpi,
+struct mtk_dpi_sync_param *sync,
+u32 width_addr, u32 porch_addr)
+{
+   mtk_dpi_mask(dpi, width_addr,
+sync->sync_width << VSYNC_WIDTH_SHIFT,
+VSYNC_WIDTH_MASK);
+   mtk_dpi_mask(dpi, width_addr,
+sync->shift_half_line << VSYNC_HALF_LINE_SHIFT,
+VSYNC_HALF_LINE_MASK);
+   mtk_dpi_mask(dpi, porch_addr,
+sync->back_porch << VSYNC_BACK_PORCH_SHIFT,
+VSYNC_BACK_PORCH_MASK);
+   mtk_dpi_mask(dpi, porch_addr,
+sync->front_porch << VSYNC_FRONT_PORCH_SHIFT,
+VSYNC_FRONT_PORCH_MASK);
+}
+
+static void mtk_dpi_config_vsync_lodd(struct mtk_dpi *dpi,
+ struct mtk_dpi_sync_param *sync)
+{
+   mtk_dpi_config_vsync(dpi, sync, DPI_TGEN_VWIDTH, DPI_TGEN_VPORCH);
+}
+
+static void mtk_dpi_config_vsync_leven(struct mtk_dpi *dpi,
+  struct mtk_dpi_sync_param *sync)
+{
+   mtk_dpi_config_vsync(dpi, sync, DPI_TGEN_VWIDTH_LEVEN,
+

[PATCH v7 03/14] drm/mediatek: Add DSI sub driver

2015-11-30 Thread Philipp Zabel
From: CK Hu 

This patch add a drm encoder/connector driver for the MIPI DSI function
block of the Mediatek display subsystem and a phy driver for the MIPI TX
D-PHY control module.

Signed-off-by: Jitao Shi 
Signed-off-by: Philipp Zabel 
---
Changes since v6:
 - Added mtk_dsi_poweron/off refcounting and mtk_ddp_component start/stop
   callbacks to keep pixel clock enabled until crtc_disable
---
 drivers/gpu/drm/mediatek/Makefile  |   4 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c |   2 +
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |   2 +
 drivers/gpu/drm/mediatek/mtk_dsi.c | 838 +
 drivers/gpu/drm/mediatek/mtk_dsi.h |  57 +++
 drivers/gpu/drm/mediatek/mtk_mipi_tx.c | 377 +++
 drivers/gpu/drm/mediatek/mtk_mipi_tx.h |  21 +
 7 files changed, 1300 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dsi.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_dsi.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_mipi_tx.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_mipi_tx.h

diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
index bd6e8df..573f209 100644
--- a/drivers/gpu/drm/mediatek/Makefile
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -5,7 +5,9 @@ mediatek-drm-y := mtk_disp_ovl.o \
  mtk_drm_drv.o \
  mtk_drm_fb.o \
  mtk_drm_gem.o \
- mtk_drm_plane.o
+ mtk_drm_plane.o \
+ mtk_dsi.o \
+ mtk_mipi_tx.o

 obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index a34c765..739c3e9 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -521,6 +521,8 @@ static struct platform_driver mtk_drm_platform_driver = {
 static struct platform_driver * const mtk_drm_drivers[] = {
_drm_platform_driver,
_disp_ovl_driver,
+   _dsi_driver,
+   _mipi_tx_driver,
 };

 static int __init mtk_drm_init(void)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
index df421cd..3b5b254 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
@@ -49,5 +49,7 @@ struct mtk_drm_private {
 };

 extern struct platform_driver mtk_disp_ovl_driver;
+extern struct platform_driver mtk_dsi_driver;
+extern struct platform_driver mtk_mipi_tx_driver;

 #endif /* MTK_DRM_DRV_H */
diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
b/drivers/gpu/drm/mediatek/mtk_dsi.c
new file mode 100644
index 000..5b7eea4
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -0,0 +1,838 @@
+/*
+ * Copyright (c) 2015 MediaTek Inc.
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "mtk_dsi.h"
+#include "mtk_mipi_tx.h"
+
+#define DSI_VIDEO_FIFO_DEPTH   (1920 / 4)
+#define DSI_HOST_FIFO_DEPTH64
+
+#define DSI_START  0x00
+
+#define DSI_CON_CTRL   0x10
+#define DSI_RESET  BIT(0)
+#define DSI_EN BIT(1)
+
+#define DSI_MODE_CTRL  0x14
+#define MODE   (3)
+#define CMD_MODE   0
+#define SYNC_PULSE_MODE1
+#define SYNC_EVENT_MODE2
+#define BURST_MODE 3
+#define FRM_MODE   BIT(16)
+#define MIX_MODE   BIT(17)
+
+#define DSI_TXRX_CTRL  0x18
+#define VC_NUM (2 << 0)
+#define LANE_NUM   (0xf << 2)
+#define DIS_EOTBIT(6)
+#define NULL_ENBIT(7)
+#define TE_FREERUN BIT(8)
+#define EXT_TE_EN  BIT(9)
+#define EXT_TE_EDGEBIT(10)
+#define MAX_RTN_SIZE   (0xf << 12)
+#define HSTX_CKLP_EN   BIT(16)
+
+#define DSI_PSCTRL 0x1c
+#define DSI_PS_WC  0x3fff
+#define DSI_PS_SEL (3 << 16)
+#define PACKED_PS_16BIT_RGB565 (0 << 16)
+#define LOOSELY_PS_18BIT_RGB666(1 << 16)
+#define PACKED_PS_18BIT_RGB666 (2 << 16)
+#define PACKED_PS_24BIT_RGB888 (3 << 16)
+
+#define DSI_VSA_NL 0x20
+#define DSI_VBP_NL 0x24
+#define DSI_VFP_NL 

[PATCH v7 02/14] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.

2015-11-30 Thread Philipp Zabel
From: CK Hu 

This patch adds an initial DRM driver for the Mediatek MT8173 DISP
subsystem. It currently supports two fixed output streams from the
OVL0/OVL1 sources to the DSI0/DPI0 sinks, respectively.

Signed-off-by: CK Hu 
Signed-off-by: YT Shen 
Signed-off-by: Philipp Zabel 
---
Changes since v6:
 - Split disp_ovl driver from mtk_drm_crtc code
 - Added crtc and plane state atomic reset functions
 - Toned down debug messages
 - Improved error handling for hardware initialization
 - Get/put smi_larb in crtc_enable/disable
 - Added memory barrier before marking crtc state as ready
 - Changed crtc_disable to wait for vblank
 - Renamed component power_on/off to start/stop
 - Made component ops optional
 - Moved crtc creation from disp_ovl driver bind callback into mtk_drm_kms_init
 - Various fixes
 - Added support for DRIVER_PRIME feature
 - Moved DISP_OVL, DSI, DPI and component initialization into the respective 
drivers
---
 drivers/gpu/drm/Kconfig |   2 +
 drivers/gpu/drm/Makefile|   1 +
 drivers/gpu/drm/mediatek/Kconfig|  16 +
 drivers/gpu/drm/mediatek/Makefile   |  11 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 301 +++
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 565 
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h |  31 ++
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 355 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp.h  |  41 ++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 275 ++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 148 
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 562 +++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h  |  53 +++
 drivers/gpu/drm/mediatek/mtk_drm_fb.c   | 135 +++
 drivers/gpu/drm/mediatek/mtk_drm_fb.h   |  28 ++
 drivers/gpu/drm/mediatek/mtk_drm_gem.c  | 227 +++
 drivers/gpu/drm/mediatek/mtk_drm_gem.h  |  55 +++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c| 238 
 drivers/gpu/drm/mediatek/mtk_drm_plane.h|  58 +++
 19 files changed, 3102 insertions(+)
 create mode 100644 drivers/gpu/drm/mediatek/Kconfig
 create mode 100644 drivers/gpu/drm/mediatek/Makefile
 create mode 100644 drivers/gpu/drm/mediatek/mtk_disp_ovl.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_crtc.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_drv.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_drv.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_fb.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.h
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_plane.c
 create mode 100644 drivers/gpu/drm/mediatek/mtk_drm_plane.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index c4bf9a1..8fdb0c2 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -266,3 +266,5 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
 source "drivers/gpu/drm/imx/Kconfig"

 source "drivers/gpu/drm/vc4/Kconfig"
+
+source "drivers/gpu/drm/mediatek/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 1e9ff4c..607a49f 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -71,6 +71,7 @@ obj-$(CONFIG_DRM_MSM) += msm/
 obj-$(CONFIG_DRM_TEGRA) += tegra/
 obj-$(CONFIG_DRM_STI) += sti/
 obj-$(CONFIG_DRM_IMX) += imx/
+obj-$(CONFIG_DRM_MEDIATEK) += mediatek/
 obj-y  += i2c/
 obj-y  += panel/
 obj-y  += bridge/
diff --git a/drivers/gpu/drm/mediatek/Kconfig b/drivers/gpu/drm/mediatek/Kconfig
new file mode 100644
index 000..5343cf1
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/Kconfig
@@ -0,0 +1,16 @@
+config DRM_MEDIATEK
+   tristate "DRM Support for Mediatek SoCs"
+   depends on DRM
+   depends on ARCH_MEDIATEK || (ARM && COMPILE_TEST)
+   select MTK_SMI
+   select DRM_PANEL
+   select DRM_MIPI_DSI
+   select DRM_PANEL_SIMPLE
+   select DRM_KMS_HELPER
+   select IOMMU_DMA
+   help
+ Choose this option if you have a Mediatek SoCs.
+ The module will be called mediatek-drm
+ This driver provides kernel mode setting and
+ buffer management to userspace.
+
diff --git a/drivers/gpu/drm/mediatek/Makefile 
b/drivers/gpu/drm/mediatek/Makefile
new file mode 100644
index 000..bd6e8df
--- /dev/null
+++ b/drivers/gpu/drm/mediatek/Makefile
@@ -0,0 +1,11 @@
+mediatek-drm-y := mtk_disp_ovl.o \
+ mtk_drm_crtc.o \
+ mtk_drm_ddp.o \
+ 

[PATCH v7 01/14] dt-bindings: drm/mediatek: Add Mediatek display subsystem dts binding

2015-11-30 Thread Philipp Zabel
From: CK Hu 

Add device tree binding documentation for the display subsystem in
Mediatek MT8173 SoCs.

Signed-off-by: CK Hu 
Signed-off-by: Philipp Zabel 
Acked-by: Rob Herring 
---
Changes since v6:
 - Clarify single clock in clocks property
 - Improve iommus property description
---
 .../bindings/display/mediatek/mediatek,disp.txt| 187 +
 .../bindings/display/mediatek/mediatek,dpi.txt |  35 
 .../bindings/display/mediatek/mediatek,dsi.txt |  53 ++
 3 files changed, 275 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
 create mode 100644 
Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt
 create mode 100644 
Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt

diff --git 
a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt 
b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
new file mode 100644
index 000..e1b3ce9
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
@@ -0,0 +1,187 @@
+Mediatek display subsystem
+==
+
+The Mediatek display subsystem consists of various DISP function blocks in the
+MMSYS register space. The connections between them can be configured by output
+and input selectors in the MMSYS_CONFIG register space. Pixel clock and start
+of frame signal are distributed to the other function blocks by a DISP_MUTEX
+function block.
+
+All DISP device tree nodes must be siblings to the central MMSYS_CONFIG node.
+For a description of the MMSYS_CONFIG binding, see
+Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt.
+
+DISP function blocks
+
+
+A display stream starts at a source function block that reads pixel data from
+memory and ends with a sink function block that drives pixels on a display
+interface, or writes pixels back to memory. All DISP function blocks have
+their own register space, interrupt, and clock gate. The blocks that can
+access memory additionally have to list the IOMMU and local arbiter they are
+connected to.
+
+For a description of the display interface sink function blocks, see
+Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt and
+Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt.
+
+Required properties (all function blocks):
+- compatible: "mediatek,-disp-", one of
+   "mediatek,-disp-ovl"   - overlay (4 layers, blending, csc)
+   "mediatek,-disp-rdma"  - read DMA / line buffer
+   "mediatek,-disp-wdma"  - write DMA
+   "mediatek,-disp-color" - color processor
+   "mediatek,-disp-aal"   - adaptive ambient light controller
+   "mediatek,-disp-gamma" - gamma correction
+   "mediatek,-disp-ufoe"  - data compression engine
+   "mediatek,-dsi"- DSI controller, see mediatek,dsi.txt
+   "mediatek,-dpi"- DPI controller, see mediatek,dpi.txt
+   "mediatek,-disp-mutex" - display mutex
+   "mediatek,-disp-od"- overdrive
+- reg: Physical base address and length of the function block register space
+- interrupts: The interrupt signal from the function block.
+- clocks: device clocks
+  See Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
+  For most function blocks this is just a single clock input. Only the DSI and
+  DPI controller nodes have multiple clock inputs. These are documented in
+  mediatek,dsi.txt and mediatek,dpi.txt, respectively.
+
+Required properties (DMA function blocks):
+- compatible: Should be one of
+   "mediatek,-disp-ovl"
+   "mediatek,-disp-rdma"
+   "mediatek,-disp-wdma"
+- larb: Should contain a phandle pointing to the local arbiter device as 
defined
+  in Documentation/devicetree/bindings/soc/mediatek/mediatek,smi-larb.txt
+- iommus: Should point to the respective IOMMU block with local arbiter id and
+  master port, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
+  for details.
+
+Examples:
+
+mmsys: clock-controller at 1400 {
+   compatible = "mediatek,mt8173-mmsys", "syscon";
+   reg = <0 0x1400 0 0x1000>;
+   power-domains = < MT8173_POWER_DOMAIN_MM>;
+   #clock-cells = <1>;
+};
+
+ovl0: ovl at 1400c000 {
+   compatible = "mediatek,mt8173-disp-ovl";
+   reg = <0 0x1400c000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_MM_DISP_OVL0>;
+   iommus = < M4U_LARB0_ID M4U_PORT_DISP_OVL0>;
+   mediatek,larb = <>;
+};
+
+ovl1: ovl at 1400d000 {
+   compatible = "mediatek,mt8173-disp-ovl";
+   reg = <0 0x1400d000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_MM_DISP_OVL1>;
+   iommus = < M4U_LARB4_ID M4U_PORT_DISP_OVL1>;
+   mediatek,larb = <>;
+};
+
+rdma0: rdma at 1400e000 {
+   compatible = "mediatek,mt8173-disp-rdma";
+   reg = <0 0x1400e000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_MM_DISP_RDMA0>;
+   iommus = < 

[PATCH v7 00/14] MT8173 DRM support

2015-11-30 Thread Philipp Zabel
Hi,

this MT8173 DRM update addresses some issues, mostly reported by Tomasz
Figa, Daniel Kurtz, and YT Shen. It also adds is PRIME support and
two new patches to export drm_atomic_helper's wait_for_fences and use it
in mtk_atomic_complete.

Changes since v6:
 - Improved binding documentation
 - Split disp_ovl driver from mtk_drm_crtc code
 - Added crtc and plane state atomic reset functions
 - Toned down debug messages
 - Improved error handling for hardware initialization
 - Get/put smi_larb in crtc_enable/disable
 - Added memory barrier before marking crtc state as ready
 - Changed crtc_disable to wait for vblank
 - Renamed component power_on/off to start/stop
 - Made component ops optional
 - Moved crtc creation from disp_ovl driver bind callback into mtk_drm_kms_init
 - Added support for DRIVER_PRIME feature
 - Moved DISP_OVL, DSI, DPI and component initialization into the respective 
drivers
 - Added DPI/DSI poweron/off refcounting and mtk_ddp_component start/stop
   callbacks to keep pixel clock enabled until crtc_disable, as suggested by CK
 - Removed mtk_hdmi_audio_data / mtk-hdmi-codec platform device creation
   for now, hdmi audio will be reworked.

The following patches are still needed to apply this on top of v4.4-rc1:

https://patchwork.kernel.org/patch/6825601/ ("arm64: dts: mt8173: add MT8173 
display PWM driver support node"),
https://patchwork.kernel.org/patch/7138531/ ("arm64: dts: mediatek: add xHCI & 
usb phy for mt8173"),
https://patchwork.kernel.org/patch/6928651/ ("dts: mt8173: Add iommu/smi nodes 
for mt8173"), and

And to build:

https://patchwork.kernel.org/patch/6928621/ ("memory: mediatek: Add SMI 
driver"),

regards
Philipp

CK Hu (5):
  dt-bindings: drm/mediatek: Add Mediatek display subsystem dts binding
  drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.
  drm/mediatek: Add DSI sub driver
  arm64: dts: mt8173: Add display subsystem related nodes
  arm64: dts: mt8173: Add HDMI related nodes

Daniel Kurtz (1):
  drm/atomic-helper: Export drm_atomic_helper_wait_for_fences

Jie Qiu (3):
  drm/mediatek: Add DPI sub driver
  drm/mediatek: Add HDMI support
  drm/mediatek: enable hdmi output control bit

Philipp Zabel (5):
  dt-bindings: drm/mediatek: Add Mediatek HDMI dts binding
  clk: mediatek: make dpi0_sel and hdmi_sel not propagate rate changes
  clk: mediatek: Add hdmi_ref HDMI PHY PLL reference clock output
  dt-bindings: hdmi-connector: add DDC I2C bus phandle documentation
  drm/mediatek: Add fence control, wait on GPU fence

 .../bindings/display/connector/hdmi-connector.txt  |   1 +
 .../bindings/display/mediatek/mediatek,disp.txt| 187 +
 .../bindings/display/mediatek/mediatek,dpi.txt |  35 +
 .../bindings/display/mediatek/mediatek,dsi.txt |  53 ++
 .../bindings/display/mediatek/mediatek,hdmi.txt| 142 
 arch/arm64/boot/dts/mediatek/mt8173.dtsi   | 282 +++
 drivers/clk/mediatek/clk-mt8173.c  |   9 +-
 drivers/clk/mediatek/clk-mtk.h |   7 +-
 drivers/gpu/drm/Kconfig|   2 +
 drivers/gpu/drm/Makefile   |   1 +
 drivers/gpu/drm/drm_atomic_helper.c|   7 +-
 drivers/gpu/drm/mediatek/Kconfig   |  22 +
 drivers/gpu/drm/mediatek/Makefile  |  22 +
 drivers/gpu/drm/mediatek/mtk_cec.c | 245 ++
 drivers/gpu/drm/mediatek/mtk_cec.h |  25 +
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c| 301 
 drivers/gpu/drm/mediatek/mtk_dpi.c | 744 ++
 drivers/gpu/drm/mediatek/mtk_dpi.h |  84 +++
 drivers/gpu/drm/mediatek/mtk_dpi_regs.h| 228 ++
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c| 597 +++
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h|  32 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 355 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp.h |  41 +
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c| 275 +++
 drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h| 148 
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 568 ++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |  56 ++
 drivers/gpu/drm/mediatek/mtk_drm_fb.c  | 135 
 drivers/gpu/drm/mediatek/mtk_drm_fb.h  |  28 +
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 227 ++
 drivers/gpu/drm/mediatek/mtk_drm_gem.h |  55 ++
 drivers/gpu/drm/mediatek/mtk_drm_hdmi_drv.c| 609 +++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c   | 254 +++
 drivers/gpu/drm/mediatek/mtk_drm_plane.h   |  58 ++
 drivers/gpu/drm/mediatek/mtk_dsi.c | 838 +
 drivers/gpu/drm/mediatek/mtk_dsi.h |  57 ++
 drivers/gpu/drm/mediatek/mtk_hdmi.c| 484 
 drivers/gpu/drm/mediatek/mtk_hdmi.h| 113 +++
 drivers/gpu/drm/mediatek/mtk_hdmi_ddc_drv.c   

[RESEND] drm: imx: imx-tve: Fix module autoload for OF platform driver

2015-11-30 Thread Luis de Bethencourt
On 30/11/15 21:28, Philipp Zabel wrote:
> Hi Luis,
> 
> thanks for the reminder.
>

No problem. I was worried I was bothering.

> Am Montag, den 30.11.2015, 15:02 + schrieb Luis de Bethencourt:
>> This platform driver has a OF device ID table but the OF module
>> alias information is not created so module autoloading won't work.
>>
>> Signed-off-by: Luis de Bethencourt 
>> ---
>>
>> Hi,
>>
>> This is a resend of a patch from October 20th [0]
> 
> Sorry to have missed it, I was in the middle of a vacation then.
> I've applied it to my fixes branch now.
> 

I understand, we all have a few emails that fall between the cracks.

Thank you very much for reviewing and applying.
Luis

>> I am adding Andrew Morton to the CC list as was recommended at the Korea 
>> Linux
>> Forum.
>>
>> This patch adds the missing MODULE_DEVICE_TABLE() for OF to export
>> that information so modules have the correct aliases built-in and
>> autoloading works correctly.
>>
>> A longer explanation by Javier Canillas can be found here:
>> https://lkml.org/lkml/2015/7/30/519
>> A multitude of similar patches have been merged for other drivers, search
>> the git log for "module autoload for OF platform driver".
>>
>> Thanks,
>> Luis
> 
> regards
> Philipp
> 



[PATCH] drm: Fix an unwanted master inheritance

2015-11-30 Thread Thomas Hellstrom
Hi,

I'm not completely sure that many drivers except vmwgfx care about
inter-master DRM
information leaks, of which this is one. (For example I think most
drivers allow a bo flinked by a driver in one master realm (one user) to
be opened by a client in another master realm (another user)).

I think the common opinion is to ignore this and push for general
render-node usage. Should that not be the case, we can always forward
this. Note, however, that the impact for this particular issue should be
quite low because it requires the cooperation of a user-space client
with root privileges that is sloppy with timing

/Thomas

On 11/30/2015 08:53 PM, Lukas Wunner wrote:
> Hi,
>
> On Mon, Nov 30, 2015 at 04:27:50PM +0100, Thomas Hellstrom wrote:
>> while probably all other drivers don't care, except that it's a security
>> issue
> Hm, I don't know what the security policy is for DRM-related issues
> but shouldn't this be cc'ed to security at kernel.org so that it gets the
> attention of security folks at distro vendors and is assigned a CVE?
>
> Best regards,
>
> Lukas




[PATCH] drm: Fix an unwanted master inheritance

2015-11-30 Thread Lukas Wunner
Hi,

On Mon, Nov 30, 2015 at 04:27:50PM +0100, Thomas Hellstrom wrote:
> while probably all other drivers don't care, except that it's a security
> issue

Hm, I don't know what the security policy is for DRM-related issues
but shouldn't this be cc'ed to security at kernel.org so that it gets the
attention of security folks at distro vendors and is assigned a CVE?

Best regards,

Lukas


[PATCH v3 2/5] drm/dsi: Try to match non-DT dsi devices

2015-11-30 Thread kbuild test robot
Hi Archit,

[auto build test ERROR on: v4.4-rc3]
[also build test ERROR on: next-20151127]

url:
https://github.com/0day-ci/linux/commits/Archit-Taneja/drm-dsi-DSI-for-devices-with-different-control-bus/20151130-200725
config: x86_64-allyesdebian (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/gpu/drm/drm_mipi_dsi.c: In function 'of_mipi_dsi_device_add':
>> drivers/gpu/drm/drm_mipi_dsi.c:168:6: error: implicit declaration of 
>> function 'of_modalias_node' [-Werror=implicit-function-declaration]
 if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
 ^
   cc1: some warnings being treated as errors

vim +/of_modalias_node +168 drivers/gpu/drm/drm_mipi_dsi.c

   162  {
   163  struct device *dev = host->dev;
   164  struct mipi_dsi_device_info info = { };
   165  int ret;
   166  u32 reg;
   167  
 > 168  if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
   169  dev_err(dev, "modalias failure on %s\n", 
node->full_name);
   170  return ERR_PTR(-EINVAL);
   171  }

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
-- next part --
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 36065 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/49ef2ff6/attachment-0001.obj>


[Bug 76490] Hang during boot when DPM is on (R9 270X)

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=76490

--- Comment #71 from Maxim Sheviakov  ---
(In reply to Tobias Droste from comment #70)
> (In reply to Benjamin Bellec from comment #68)
> > If I have to read the VBIOS and add I quirk in the kernel, why the kernel
> > can't do this by himself ?
> > 
> > Moreover, I saw the previous quirk in the kernel, the max memory clock is
> > often set to "12". I guess it stands for 1.2GHz QDR which is equivalent
> > to 4.8GHz. My card, like all the R7 370 are supposed to work at 5.6GHz so
> > this is a serious lost of performance.
> > 
> > At the moment I will just return my card.
> 
> For the record:
> 
> This stuff *can't* be read from the VBIOS and has to be found by trial and
> error.
> You also don't have to google the steps, they are described in comment #48.
> 
> But otherwise you are right, It will limit your card and replacing it with
> another one seems like the only option you have right now. At least that's
> what I did too, because I don't see this bug fixed in the near future.

Hmm, nice point. By the way, is the MCLK kinda divided by four? So, if Memory
Clock is 5600MHz, I'll have to do 5600/4*1 to get the correct value? It's
like, 12 value = 1.2GHz*4 = Original frequency = 4800MHz, right? If that's
it, I'll fix my quirk (AGAIN, LOL) and try using 970MHz and 5600MHz written as
needed, 'cause my GPU is MSI R7 370 Armor 2X, and looks like values in quirk
are *kinda* low for it.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/3c70b6b8/attachment.html>


[Bug 93147] [regression bisected] Stuttering in games caused by commit 4dfd6486 "drm: Use vblank timestamps to guesstimate how many vblanks were missed"

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=93147

--- Comment #5 from Ville Syrjala  ---
(In reply to Michel Dänzer from comment #4)
> I recently ran into this with armagetronad. I've now confirmed that
> reverting these changes fixes that as well, thanks Dave for saving me the
> time to track this down!
> 
> Ville, any ideas what's going on / how to fix it? If not, please revert
> these changes.

I'm guessing this is the stuff Mario was trying to fix. Oh FFS, apparently he
didn't cc dri-devel so the entire discussion has all been in private :( Though
you were cc:d on most of it I think. Maybe I can bounce the entire thing onto
the list...

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/e2fdee07/attachment.html>


[Bug 93032] [radeonsi] Civilization Beyond Earth segfaults

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=93032

--- Comment #14 from Paulo Dias  ---
according to the interwebs:

64-bit GDB can debug either 32 or 64-bit processes.

so, i believe the lack of a proper trace might be:

1 - lack of symbols in the 32bits game binary
2 - my inability to generate a proper trace
3 - both

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/9cb7bdd8/attachment.html>


[Bug 93178] Textures are filled with garbage

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=93178

--- Comment #1 from Józef Kucia  ---
Created attachment 120219
  --> https://bugs.freedesktop.org/attachment.cgi?id=120219=edit
The expected image to be rendered for frame 1 in the attached apitrace

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/5a815adf/attachment.html>


[Bug 93178] Textures are filled with garbage

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=93178

Ilia Mirkin  changed:

   What|Removed |Added

 Attachment #120218|text/plain  |image/png
  mime type||

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/bcfc3e04/attachment.html>


[Bug 93178] Textures are filled with garbage

2015-11-30 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=93178

Bug ID: 93178
   Summary: Textures are filled with garbage
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/radeonsi
  Assignee: dri-devel at lists.freedesktop.org
  Reporter: joseph.kucia at gmail.com
QA Contact: dri-devel at lists.freedesktop.org

Created attachment 120218
  --> https://bugs.freedesktop.org/attachment.cgi?id=120218=edit
Frame 1 rendered on Radeonsi

The following apitrace renders garbage (see the attached screenshot) when
replayed on radeonsi. The same apitrace is rendered correctly on nouveau and
nvidia. The cause of the problem seems to be textures filled with garbage.

apitrace: https://drive.google.com/file/d/0Bz0HXJUyjAh3Z0Z2SW9tNUJ3bXM/view

OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD CAPE VERDE (DRM 2.43.0, LLVM 3.8.0)
OpenGL core profile version string: 4.1 (Core Profile) Mesa
11.2.0-devel (git-2571a76)
OpenGL core profile shading language version string: 4.10
OpenGL core profile context flags: (none)

AMD Radeon R9 M375

04:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI]
Venus XTX [Radeon HD 8890M / R9 M275X/M375X] (rev ff)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/6c848465/attachment.html>


[PATCH 02/20] drm: Kbuild: add admgpu_drm.h to the installed headers

2015-11-30 Thread Alex Deucher
On Mon, Nov 30, 2015 at 9:10 AM, Gabriel Laskar  wrote:
> Signed-off-by: Gabriel Laskar 
> CC: Emil Velikov 
> CC: Mikko Rapeli 

Acked-by: Alex Deucher 

>
> ---
>  include/uapi/drm/Kbuild | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/include/uapi/drm/Kbuild b/include/uapi/drm/Kbuild
> index 38d4370..159551f 100644
> --- a/include/uapi/drm/Kbuild
> +++ b/include/uapi/drm/Kbuild
> @@ -3,6 +3,7 @@ header-y += drm.h
>  header-y += drm_fourcc.h
>  header-y += drm_mode.h
>  header-y += drm_sarea.h
> +header-y += amdgpu_drm.h
>  header-y += exynos_drm.h
>  header-y += i810_drm.h
>  header-y += i915_drm.h
> --
> 2.6.2
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm: Fix an unwanted master inheritance

2015-11-30 Thread Thomas Hellstrom
On 11/30/2015 05:09 PM, Daniel Vetter wrote:
> On Mon, Nov 30, 2015 at 04:27:50PM +0100, Thomas Hellstrom wrote:
>> Hi,
>>
>> On 11/30/2015 04:00 PM, Daniel Vetter wrote:
>>> On Mon, Nov 30, 2015 at 04:44:21AM -0800, Thomas Hellstrom wrote:
 A client calling drmSetMaster() using a file descriptor that was opened
 when another client was master would inherit the latter client's master
 object and all it's authenticated clients.

 This is unwanted behaviour, and when this happens, instead allocate a
 brand new master object for the client calling drmSetMaster().

 Signed-off-by: Thomas Hellstrom 
>>> Imo makes sense. It would be great to have a testcase for this, and for
>>> non-kms stuff igt now has support for generic testcases that can be run on
>>> any driver. See for example intel-gpu-tools/tests/core_get_auth_client.c.
>>>
>>> I or Daniel Stone can help out (on irc or mail) with that.
>>> -Daniel
>> Given that this crashes the kernel by vmwgfx throwing a BUG on some
>> versions of SLE,
>> while probably all other drivers don't care, except that it's a security
>> issue, A generic test case involving DRM clients leaking information
>> between master realms would unfortunately be too resource consuming to
>> put together for our minimal driver team ;).
>>
>> Although I used the attached C program run as root to trigger the
>> behavior and unconditional kernel crash on vmwgfx. On the affected SLE
>> versions, fd1 would represent Xorg, fd2 would represent plymouthd.
>>
>> /Thomas
>>
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>>
>> int main()
>> {
>> int fd1, fd2;
>>
>> fd1 = open("/dev/dri/card0", O_RDWR);
>> if (fd1 < 0)
>>  exit(-1);
>>
>> fd2 = open("/dev/dri/card0", O_RDWR);
>> if (fd2 < 0)
>>  exit(-1);
> I think if you open fd3 here an auth it with fd1 ...
>
>> (void) drmDropMaster(fd1);
>> (void) drmSetMaster(fd2);
> and then check whether fd1 is still authenticated (and fail if so) it
> should work as a testcase. Converting it over to igt would be trivial, I
> can do that if you want. We also already have auth testcases in igt, so
> should be at most a bit of copypasting to get it together.
>
> Or did I miss a needed detail in how to repro this?
> -Daniel

Yes, an authenticated fd is always authenticated, no matter what master
is current. And core DRM leaves data isolation between master realms to
subsystems or drivers.

What we could do is to obtain an auth magic for fd3 from fd1 and try to
use it with fd2 to authenticate after master switch. That should work
without this patch, but not with is.

/Thomas


>
>> close(fd2);
>> close(fd1);
>> }
>




ANNOUNCE: introcuding kmsxx, tests and python wrappers

2015-11-30 Thread Tomi Valkeinen
Hi,

Here's something we've been working on and using on our environment, and
I think it's now in a state where others may find it usable too:

https://github.com/tomba/kmsxx

libkmsxx is a small C++11 library for kernel mode setting. It tries to
implement as little extra as possible while bringing the kms API in a
C++ form to the user. It only implements a subset of what libdrm supports.

The repository also contains small utils, test tools and python wrappers.

The focus with libkmsxx has been mainly on testing, enabling us to write
small test apps easily by minimizing the amount of code needed to do KMS
operations, and to write python scripts to do tests which can easily be
modified. The code is definitely not production quality code, but we've
tried to keep the code clean.

At the moment we have these tests/utils:

kmsprint - print information about DRM objects
testpat - set modes and show test pattern on crtcs/planes
kmsview - view raw images
db - simple double-buffering test
kmscube - rotating 3D cube on crtcs/planes

Some highlights:

Testpat is a tool to setup modes and planes, and have a test pattern on
the screen. It "guesses" what you want to do, which means you don't
usually need to fill in all the details:

XR24 framebuffer on first connected connector in the default mode:
testpat -f XR24

XR24 framebuffer on a 400x400 plane on the first connected connector in
the default mode:
testpat -p 400x400 -f XR24

Test pattern on the second connector with default mode:
testpat -c @1

With the python wrappers and a base script (iact.py) which sets up a
bunch of helper variables/funcs for you, you can have an interactive
python shell where you can do things like:

  for x in range(0, crtc.width() - fb.width()): set_plane(x,
int((sin(x/50) + 1) * 100)); sleep(0.01)

 Tomi

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/74915b7a/attachment.sig>


[PATCH v3 5/5] drm/dsi: Get DSI host by DT device node

2015-11-30 Thread Archit Taneja
mipi_dsi_devices are inherently aware of their host because they
share a parent-child hierarchy in the device tree.

non-dsi drivers that create dsi device don't have this data. In order to
get this information, they require to a phandle to the dsi host in the
device tree.

Maintain a list of all the hosts DSI that are currently registered.

This list will be used to find the mipi_dsi_host corresponding to the
device_node passed in of_find_mipi_dsi_host_by_node.

Reviewed-by: Andrzej Hajda 
Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_mipi_dsi.c | 38 ++
 include/drm/drm_mipi_dsi.h |  3 +++
 2 files changed, 41 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index f73e434..e9c17e25 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -205,6 +205,36 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct 
device_node *node)
return mipi_dsi_device_new(host, );
 }

+static DEFINE_MUTEX(host_lock);
+static LIST_HEAD(host_list);
+
+/**
+ * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a
+ *device tree node
+ * @node: device tree node
+ *
+ * Return: A pointer to the MIPI DSI host corresponding to @np or NULL if no
+ *such device exists (or has not been registered yet).
+ */
+struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node)
+{
+   struct mipi_dsi_host *host;
+
+   mutex_lock(_lock);
+
+   list_for_each_entry(host, _list, list) {
+   if (host->dev->of_node == node) {
+   mutex_unlock(_lock);
+   return host;
+   }
+   }
+
+   mutex_unlock(_lock);
+
+   return NULL;
+}
+EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);
+
 int mipi_dsi_host_register(struct mipi_dsi_host *host)
 {
struct device_node *node;
@@ -216,6 +246,10 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)
of_mipi_dsi_device_add(host, node);
}

+   mutex_lock(_lock);
+   list_add_tail(>list, _list);
+   mutex_unlock(_lock);
+
return 0;
 }
 EXPORT_SYMBOL(mipi_dsi_host_register);
@@ -232,6 +266,10 @@ static int mipi_dsi_remove_device_fn(struct device *dev, 
void *priv)
 void mipi_dsi_host_unregister(struct mipi_dsi_host *host)
 {
device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn);
+
+   mutex_lock(_lock);
+   list_del_init(>list);
+   mutex_unlock(_lock);
 }
 EXPORT_SYMBOL(mipi_dsi_host_unregister);

diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 410d8b5..e5c1df9 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -96,14 +96,17 @@ struct mipi_dsi_host_ops {
  * struct mipi_dsi_host - DSI host device
  * @dev: driver model device node for this DSI host
  * @ops: DSI host operations
+ * @list: list management
  */
 struct mipi_dsi_host {
struct device *dev;
const struct mipi_dsi_host_ops *ops;
+   struct list_head list;
 };

 int mipi_dsi_host_register(struct mipi_dsi_host *host);
 void mipi_dsi_host_unregister(struct mipi_dsi_host *host);
+struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);

 /* DSI mode flags */

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v3 4/5] drm/dsi: Add routine to unregister dsi device

2015-11-30 Thread Archit Taneja
A driver calling mipi_dsi_device_new might want to unregister the device
once it's done. It might also require it in an error handling path in
case something didn't go right.

Signed-off-by: Archit Taneja 
---
 include/drm/drm_mipi_dsi.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index cb084af..410d8b5 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -195,6 +195,11 @@ ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, 
const void *params,

 struct mipi_dsi_device *mipi_dsi_device_new(struct mipi_dsi_host *host,
struct mipi_dsi_device_info *info);
+static inline void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi)
+{
+   device_unregister(>dev);
+}
+
 /**
  * enum mipi_dsi_dcs_tear_mode - Tearing Effect Output Line mode
  * @MIPI_DSI_DCS_TEAR_MODE_VBLANK: the TE output line consists of V-Blanking
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v3 3/5] drm/dsi: Check for used channels

2015-11-30 Thread Archit Taneja
We don't check whether a previously registered mipi_dsi_device under the
same host shares the same virtual channel.

Before registering, check if any of the registered devices doesn't
already have the same virtual channel.

This wasn't crucial when all the devices under a host were populated via
DT. Now that we also support creating devices manually, we could end up
in a situation where a driver tries to create a device with a virtual
channel already taken by a device populated in DT.

Reviewed-by: Andrzej Hajda 
Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_mipi_dsi.c | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 143cce4..f73e434 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -119,6 +119,22 @@ static const struct device_type mipi_dsi_device_type = {
.release = mipi_dsi_dev_release,
 };

+static int __dsi_check_chan_busy(struct device *dev, void *data)
+{
+   struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
+   u32 *reg = data;
+
+   if (dsi && dsi->channel == *reg)
+   return -EBUSY;
+
+   return 0;
+}
+
+static int mipi_dsi_check_chan_busy(struct mipi_dsi_host *host, u32 reg)
+{
+   return device_for_each_child(host->dev, , __dsi_check_chan_busy);
+}
+
 struct mipi_dsi_device *mipi_dsi_device_new(struct mipi_dsi_host *host,
struct mipi_dsi_device_info *info)
 {
@@ -146,14 +162,20 @@ struct mipi_dsi_device *mipi_dsi_device_new(struct 
mipi_dsi_host *host,

dev_set_name(>dev, "%s.%d", dev_name(host->dev), info->reg);

+   ret = mipi_dsi_check_chan_busy(host, info->reg);
+   if (ret)
+   goto err;
+
ret = device_register(>dev);
if (ret) {
dev_err(dev, "failed to register device: %d\n", ret);
-   kfree(dsi);
-   return ERR_PTR(ret);
+   goto err;
}

return dsi;
+err:
+   kfree(dsi);
+   return ERR_PTR(ret);
 }
 EXPORT_SYMBOL(mipi_dsi_device_new);

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v3 2/5] drm/dsi: Try to match non-DT dsi devices

2015-11-30 Thread Archit Taneja
Add a device name field in mipi_dsi_device. This name is different from
the actual dev name (which is of the format "hostname.reg"). When the
device is created via DT, this name is set to the modalias string.
In the non-DT case, the driver creating the DSI device provides the
name by populating a filed in mipi_dsi_device_info.

Matching for DT case would be as it was before. For the non-DT case,
we compare the device and driver names. Other buses (like i2c/spi)
perform a non-DT match by comparing the device name and entries in the
driver's id_table. Such a mechanism isn't used for the dsi bus.

Reviewed-by: Andrzej Hajda 
Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_mipi_dsi.c | 25 -
 include/drm/drm_mipi_dsi.h |  6 ++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 82bcdcd..143cce4 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -45,9 +45,26 @@
  * subset of the MIPI DCS command set.
  */

+static const struct device_type mipi_dsi_device_type;
+
 static int mipi_dsi_device_match(struct device *dev, struct device_driver *drv)
 {
-   return of_driver_match_device(dev, drv);
+   struct mipi_dsi_device *dsi;
+
+   if (dev->type == _dsi_device_type)
+   dsi = to_mipi_dsi_device(dev);
+   else
+   return 0;
+
+   /* attempt OF style match */
+   if (of_driver_match_device(dev, drv))
+   return 1;
+
+   /* compare dsi device and driver names */
+   if (!strcmp(dsi->name, drv->name))
+   return 1;
+
+   return 0;
 }

 static const struct dev_pm_ops mipi_dsi_device_pm_ops = {
@@ -125,6 +142,7 @@ struct mipi_dsi_device *mipi_dsi_device_new(struct 
mipi_dsi_host *host,
dsi->dev.type = _dsi_device_type;
dsi->dev.of_node = info->node;
dsi->channel = info->reg;
+   strlcpy(dsi->name, info->type, sizeof(dsi->name));

dev_set_name(>dev, "%s.%d", dev_name(host->dev), info->reg);

@@ -147,6 +165,11 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct 
device_node *node)
int ret;
u32 reg;

+   if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
+   dev_err(dev, "modalias failure on %s\n", node->full_name);
+   return ERR_PTR(-EINVAL);
+   }
+
ret = of_property_read_u32(node, "reg", );
if (ret) {
dev_err(dev, "device node %s has no valid reg property: %d\n",
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 90f4f3c..cb084af 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -139,8 +139,11 @@ enum mipi_dsi_pixel_format {
MIPI_DSI_FMT_RGB565,
 };

+#define DSI_DEV_NAME_SIZE  20
+
 /**
  * struct mipi_dsi_device_info - template for creating a mipi_dsi_device
+ * @type: dsi peripheral chip type
  * @reg: DSI virtual channel assigned to peripheral
  * @node: pointer to OF device node
  *
@@ -148,6 +151,7 @@ enum mipi_dsi_pixel_format {
  * DSI device
  */
 struct mipi_dsi_device_info {
+   char type[DSI_DEV_NAME_SIZE];
u32 reg;
struct device_node *node;
 };
@@ -156,6 +160,7 @@ struct mipi_dsi_device_info {
  * struct mipi_dsi_device - DSI peripheral device
  * @host: DSI host for this peripheral
  * @dev: driver model device node for this peripheral
+ * @name: dsi peripheral chip type
  * @channel: virtual channel assigned to the peripheral
  * @format: pixel format for video mode
  * @lanes: number of active data lanes
@@ -165,6 +170,7 @@ struct mipi_dsi_device {
struct mipi_dsi_host *host;
struct device dev;

+   char name[DSI_DEV_NAME_SIZE];
unsigned int channel;
unsigned int lanes;
enum mipi_dsi_pixel_format format;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v3 1/5] drm/dsi: Refactor device creation

2015-11-30 Thread Archit Taneja
Simplify the mipi dsi device creation process. device_initialize and
device_add don't need to be called separately when creating
mipi_dsi_device's. Use device_register instead to simplify things.

Create a helper function mipi_dsi_device_new which takes in struct
mipi_dsi_device_info and mipi_dsi_host. It clubs the functions
mipi_dsi_device_alloc and mipi_dsi_device_add into one.

mipi_dsi_device_info acts as a template to populate the dsi device
information. This is populated by of_mipi_dsi_device_add and passed to
mipi_dsi_device_new.

Later on, we'll provide mipi_dsi_device_new as a standalone way to create
a dsi device not available via DT.

The new device creation process tries to closely follow what's been done
in i2c_new_device in i2c-core.

Reviewed-by: Andrzej Hajda 
Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/drm_mipi_dsi.c | 61 +-
 include/drm/drm_mipi_dsi.h | 15 +++
 2 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 2d5ca8ee..82bcdcd 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -102,9 +102,18 @@ static const struct device_type mipi_dsi_device_type = {
.release = mipi_dsi_dev_release,
 };

-static struct mipi_dsi_device *mipi_dsi_device_alloc(struct mipi_dsi_host 
*host)
+struct mipi_dsi_device *mipi_dsi_device_new(struct mipi_dsi_host *host,
+   struct mipi_dsi_device_info *info)
 {
struct mipi_dsi_device *dsi;
+   struct device *dev = host->dev;
+   int ret;
+
+   if (info->reg > 3) {
+   dev_err(dev, "device node has invalid reg property: %u\n",
+   info->reg);
+   return ERR_PTR(-EINVAL);
+   }

dsi = kzalloc(sizeof(*dsi), GFP_KERNEL);
if (!dsi)
@@ -114,26 +123,27 @@ static struct mipi_dsi_device 
*mipi_dsi_device_alloc(struct mipi_dsi_host *host)
dsi->dev.bus = _dsi_bus_type;
dsi->dev.parent = host->dev;
dsi->dev.type = _dsi_device_type;
+   dsi->dev.of_node = info->node;
+   dsi->channel = info->reg;

-   device_initialize(>dev);
-
-   return dsi;
-}
-
-static int mipi_dsi_device_add(struct mipi_dsi_device *dsi)
-{
-   struct mipi_dsi_host *host = dsi->host;
+   dev_set_name(>dev, "%s.%d", dev_name(host->dev), info->reg);

-   dev_set_name(>dev, "%s.%d", dev_name(host->dev),  dsi->channel);
+   ret = device_register(>dev);
+   if (ret) {
+   dev_err(dev, "failed to register device: %d\n", ret);
+   kfree(dsi);
+   return ERR_PTR(ret);
+   }

-   return device_add(>dev);
+   return dsi;
 }
+EXPORT_SYMBOL(mipi_dsi_device_new);

 static struct mipi_dsi_device *
 of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
 {
-   struct mipi_dsi_device *dsi;
struct device *dev = host->dev;
+   struct mipi_dsi_device_info info = { };
int ret;
u32 reg;

@@ -144,31 +154,10 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct 
device_node *node)
return ERR_PTR(-EINVAL);
}

-   if (reg > 3) {
-   dev_err(dev, "device node %s has invalid reg property: %u\n",
-   node->full_name, reg);
-   return ERR_PTR(-EINVAL);
-   }
-
-   dsi = mipi_dsi_device_alloc(host);
-   if (IS_ERR(dsi)) {
-   dev_err(dev, "failed to allocate DSI device %s: %ld\n",
-   node->full_name, PTR_ERR(dsi));
-   return dsi;
-   }
-
-   dsi->dev.of_node = of_node_get(node);
-   dsi->channel = reg;
+   info.reg = reg;
+   info.node = of_node_get(node);

-   ret = mipi_dsi_device_add(dsi);
-   if (ret) {
-   dev_err(dev, "failed to add DSI device %s: %d\n",
-   node->full_name, ret);
-   kfree(dsi);
-   return ERR_PTR(ret);
-   }
-
-   return dsi;
+   return mipi_dsi_device_new(host, );
 }

 int mipi_dsi_host_register(struct mipi_dsi_host *host)
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index f1d8d0d..90f4f3c 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -140,6 +140,19 @@ enum mipi_dsi_pixel_format {
 };

 /**
+ * struct mipi_dsi_device_info - template for creating a mipi_dsi_device
+ * @reg: DSI virtual channel assigned to peripheral
+ * @node: pointer to OF device node
+ *
+ * This is populated and passed to mipi_dsi_device_new to create a new
+ * DSI device
+ */
+struct mipi_dsi_device_info {
+   u32 reg;
+   struct device_node *node;
+};
+
+/**
  * struct mipi_dsi_device - DSI peripheral device
  * @host: DSI host for this peripheral
  * @dev: driver model device node for this peripheral
@@ -174,6 +187,8 @@ ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, 
const 

[PATCH v3 0/5] drm/dsi: DSI for devices with different control bus

2015-11-30 Thread Archit Taneja
We are currently restricted when it comes to supporting DSI on devices
that have a non-DSI control bus. For example, DSI encoder chips are
available in the market that are configured via i2c. Configuring their
registers via DSI bus is either optional or not available at all.

These devices still need to pass DSI parameters (data lanes, mode flags
etc) to the DSI host they are connected to. We don't have a way to do
that at the moment.

After some discussions on the previous RFC[1], we decided to support this
by providing additional API in drm_mipi_dsi which lets us create new DSI
devices without the need of them to have a DT node.

[1]: https://lkml.org/lkml/2015/6/30/42

Changes from v2 to v3:

- Incorporated misc comments by Andrzej. Changed from RFC to a PATCH set.
- Fixed htmldocs warnings.

Archit Taneja (5):
  drm/dsi: Refactor device creation
  drm/dsi: Try to match non-DT dsi devices
  drm/dsi: Check for used channels
  drm/dsi: Add routine to unregister dsi device
  drm/dsi: Get DSI host by DT device node

 drivers/gpu/drm/drm_mipi_dsi.c | 136 +++--
 include/drm/drm_mipi_dsi.h |  29 +
 2 files changed, 133 insertions(+), 32 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH 1/2] drm: Avoid calling the cursor_set2 callback from the drm_mode_cursor ioctl

2015-11-30 Thread Daniel Vetter
On Mon, Nov 30, 2015 at 04:52:22PM +0100, Thomas Hellstrom wrote:
> On 11/30/2015 03:55 PM, Daniel Vetter wrote:
> > On Mon, Nov 30, 2015 at 02:35:53PM +0100, Thomas Hellstrom wrote:
> >> On 11/29/2015 10:18 AM, Daniel Vetter wrote:
> >>> On Fri, Nov 27, 2015 at 01:24:11PM +0100, Thomas Hellstrom wrote:
>  On 11/27/2015 01:02 PM, Ville Syrjälä wrote:
> > On Fri, Nov 27, 2015 at 12:42:15PM +0100, Thomas Hellstrom wrote:
> >> On 11/27/2015 11:11 AM, Daniel Vetter wrote:
> >>> On Thu, Nov 26, 2015 at 10:52:14AM -0800, Thomas Hellstrom wrote:
>  If the drm_mode_cursor_ioctl is called and the cursor_set2 callback 
>  is
>  implemented, the cursor hotspot is set to (0,0) which is incompatible
>  with vmwgfx where the hotspot should instead remain unchanged.
> 
>  So if the driver implements both cursor_set2 and cursor_set, prefer 
>  calling
>  the latter from the drm_mode_cursor ioctl.
> 
>  Signed-off-by: Thomas Hellstrom 
> >>> That looks like papering over a bug in the client - it simply 
> >>> shouldn't
> >>> mix these two if it expects the hotspot to stick around. There was 
> >>> also
> >>> recently a big discussion about hotspot behaviour, and the conclusion 
> >>> was
> >>> that qxl got it all wrong. Since that was specifically added for qxl 
> >>> I'm
> >>> not sure how well this was ever tested ...
> >> No, this is not the case, This is for old Xorg userspace that first 
> >> sets
> >> the hotspot using our ancient
> >> driver-private ioctl and then calls drm_mode_cursor() to update the 
> >> cursor.
> >>
> >> Now if we were to implement cursor_set2, which is apparently needed to
> >> get gnome-shell/Wayland cursors in the right place, without this fix, 
> >> it
> >> would break old Xorg, so we don't have much choice in this case from
> >> what I can tell.
> >>
> >> The root problem here is that the drm_mode_cursor() behaviour in the
> >> presence of cursor_set2 didn't take the existing vmware hotspot
> >> semantics into account.
> >>> Ugh. I think the simplest solution is to not mix up the two hotspots, i.e.
> >>> separately keep track of both the legacy vmwgfx hotspot and the drm core
> >>> hotspot. Then in the actual cursor set code add them. A bit of ugly in the
> >>> vmwgfx code (but not much), instead of leaking that driver private legacy
> >>> ioctl semantics into drm core. Would that work?
> >>>
> >>>
> >> Hmm.
> >>
> >> Yes it would probably work. Good idea.
> >> I guess we just need to make sure that both hotspots are reset to (0,0)
> >> at master drop.
> > Resetting kms state is an entire different can of worms topic. On one hand
> > we don't want it, since if you apply changes from the default (at early
> > boot or maybe with kernel cmdline options) we want userspace to take over
> > all those settings. Otoh if your compositor dies and leaves a mess behind
> > we should reset to /something/, but due to the above it's undefined what
> > the reset values should be. At least in general. The other problem is
> > trying to figure out when exactly you should restore - we already have
> > plenty fun trying to decide when to restore fbcon, with a pile of hacks.
> >
> > With atomic at least userspace can take a full snapshot of all kms state,
> > even if it doesn't understand all the properties. Only requirement is that
> > all tunables are exported as properties. Then it can always restore that
> > snapshot. Given that I'm leaning towars "this should be solved in
> > userspace by some priveldged daemon like logind". Means old userspace is
> > out of luck if X dies (at least for all the properties that don't get
> > naturally overwritten), but that's been the case since forever.
> >
> > Trying to do that in the kernel is imo something that's not really
> > possible - the kernel knows too little about overall system state and
> > configuration.
> 
> You're probably right, but in this particular case a master using the
> legacy vmware hotspot would be severely confused by another master using
> the drm core hotspot, and vice versa even if both thought they did
> everything right and reset "their" hotspot at master_set().
> 
> Another option would of course be to use some heuristic to try to
> determine what hotspot is the "correct" one to use, instead of adding them.

Yeah, a one-off for vmwgfx shouldn't cause problems, since we already have
the master hooks for vmwgfx anyway. Just wanted to add that doing this in
generic code is imo fraught with peril and long-term probably not
something where we want to go to. I think it's perfectly fine if you add a
bit of code to vmwgfx to reset things and make the interplay with
vmw-legacy and drm hotspot work.

Cheers, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH] drm: Fix an unwanted master inheritance

2015-11-30 Thread Daniel Vetter
On Mon, Nov 30, 2015 at 04:27:50PM +0100, Thomas Hellstrom wrote:
> Hi,
> 
> On 11/30/2015 04:00 PM, Daniel Vetter wrote:
> > On Mon, Nov 30, 2015 at 04:44:21AM -0800, Thomas Hellstrom wrote:
> >> A client calling drmSetMaster() using a file descriptor that was opened
> >> when another client was master would inherit the latter client's master
> >> object and all it's authenticated clients.
> >>
> >> This is unwanted behaviour, and when this happens, instead allocate a
> >> brand new master object for the client calling drmSetMaster().
> >>
> >> Signed-off-by: Thomas Hellstrom 
> > Imo makes sense. It would be great to have a testcase for this, and for
> > non-kms stuff igt now has support for generic testcases that can be run on
> > any driver. See for example intel-gpu-tools/tests/core_get_auth_client.c.
> >
> > I or Daniel Stone can help out (on irc or mail) with that.
> > -Daniel
> 
> Given that this crashes the kernel by vmwgfx throwing a BUG on some
> versions of SLE,
> while probably all other drivers don't care, except that it's a security
> issue, A generic test case involving DRM clients leaking information
> between master realms would unfortunately be too resource consuming to
> put together for our minimal driver team ;).
> 
> Although I used the attached C program run as root to trigger the
> behavior and unconditional kernel crash on vmwgfx. On the affected SLE
> versions, fd1 would represent Xorg, fd2 would represent plymouthd.
> 
> /Thomas
> 

> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> 
> int main()
> {
> int fd1, fd2;
> 
> fd1 = open("/dev/dri/card0", O_RDWR);
> if (fd1 < 0)
>   exit(-1);
> 
> fd2 = open("/dev/dri/card0", O_RDWR);
> if (fd2 < 0)
>   exit(-1);

I think if you open fd3 here an auth it with fd1 ...

> (void) drmDropMaster(fd1);
> (void) drmSetMaster(fd2);

and then check whether fd1 is still authenticated (and fail if so) it
should work as a testcase. Converting it over to igt would be trivial, I
can do that if you want. We also already have auth testcases in igt, so
should be at most a bit of copypasting to get it together.

Or did I miss a needed detail in how to repro this?
-Daniel

> 
> close(fd2);
> close(fd1);
> }


-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 1/2] drm: Avoid calling the cursor_set2 callback from the drm_mode_cursor ioctl

2015-11-30 Thread Thomas Hellstrom
On 11/30/2015 03:55 PM, Daniel Vetter wrote:
> On Mon, Nov 30, 2015 at 02:35:53PM +0100, Thomas Hellstrom wrote:
>> On 11/29/2015 10:18 AM, Daniel Vetter wrote:
>>> On Fri, Nov 27, 2015 at 01:24:11PM +0100, Thomas Hellstrom wrote:
 On 11/27/2015 01:02 PM, Ville Syrjälä wrote:
> On Fri, Nov 27, 2015 at 12:42:15PM +0100, Thomas Hellstrom wrote:
>> On 11/27/2015 11:11 AM, Daniel Vetter wrote:
>>> On Thu, Nov 26, 2015 at 10:52:14AM -0800, Thomas Hellstrom wrote:
 If the drm_mode_cursor_ioctl is called and the cursor_set2 callback is
 implemented, the cursor hotspot is set to (0,0) which is incompatible
 with vmwgfx where the hotspot should instead remain unchanged.

 So if the driver implements both cursor_set2 and cursor_set, prefer 
 calling
 the latter from the drm_mode_cursor ioctl.

 Signed-off-by: Thomas Hellstrom 
>>> That looks like papering over a bug in the client - it simply shouldn't
>>> mix these two if it expects the hotspot to stick around. There was also
>>> recently a big discussion about hotspot behaviour, and the conclusion 
>>> was
>>> that qxl got it all wrong. Since that was specifically added for qxl I'm
>>> not sure how well this was ever tested ...
>> No, this is not the case, This is for old Xorg userspace that first sets
>> the hotspot using our ancient
>> driver-private ioctl and then calls drm_mode_cursor() to update the 
>> cursor.
>>
>> Now if we were to implement cursor_set2, which is apparently needed to
>> get gnome-shell/Wayland cursors in the right place, without this fix, it
>> would break old Xorg, so we don't have much choice in this case from
>> what I can tell.
>>
>> The root problem here is that the drm_mode_cursor() behaviour in the
>> presence of cursor_set2 didn't take the existing vmware hotspot
>> semantics into account.
>>> Ugh. I think the simplest solution is to not mix up the two hotspots, i.e.
>>> separately keep track of both the legacy vmwgfx hotspot and the drm core
>>> hotspot. Then in the actual cursor set code add them. A bit of ugly in the
>>> vmwgfx code (but not much), instead of leaking that driver private legacy
>>> ioctl semantics into drm core. Would that work?
>>>
>>>
>> Hmm.
>>
>> Yes it would probably work. Good idea.
>> I guess we just need to make sure that both hotspots are reset to (0,0)
>> at master drop.
> Resetting kms state is an entire different can of worms topic. On one hand
> we don't want it, since if you apply changes from the default (at early
> boot or maybe with kernel cmdline options) we want userspace to take over
> all those settings. Otoh if your compositor dies and leaves a mess behind
> we should reset to /something/, but due to the above it's undefined what
> the reset values should be. At least in general. The other problem is
> trying to figure out when exactly you should restore - we already have
> plenty fun trying to decide when to restore fbcon, with a pile of hacks.
>
> With atomic at least userspace can take a full snapshot of all kms state,
> even if it doesn't understand all the properties. Only requirement is that
> all tunables are exported as properties. Then it can always restore that
> snapshot. Given that I'm leaning towars "this should be solved in
> userspace by some priveldged daemon like logind". Means old userspace is
> out of luck if X dies (at least for all the properties that don't get
> naturally overwritten), but that's been the case since forever.
>
> Trying to do that in the kernel is imo something that's not really
> possible - the kernel knows too little about overall system state and
> configuration.

You're probably right, but in this particular case a master using the
legacy vmware hotspot would be severely confused by another master using
the drm core hotspot, and vice versa even if both thought they did
everything right and reset "their" hotspot at master_set().

Another option would of course be to use some heuristic to try to
determine what hotspot is the "correct" one to use, instead of adding them.

/Thomas





> -Daniel



[PATCH] drm/radeon: constify radeon_asic_ring structures

2015-11-30 Thread Alex Deucher
On Sun, Nov 29, 2015 at 2:10 PM, Christian König
 wrote:
> On 29.11.2015 17:12, Julia Lawall wrote:
>>
>> The radeon_asic_ring structures are never modified, so declare them as
>> const.
>>
>> Done with the help of Coccinelle.
>>
>> Signed-off-by: Julia Lawall 
>
>
> Nice clean, patch is Reviewed-by: Christian König  amd.com>

Applied.  thanks!

Alex


>
>
>>
>> ---
>>   drivers/gpu/drm/radeon/radeon.h  |2 -
>>   drivers/gpu/drm/radeon/radeon_asic.c |   38
>> +--
>>   2 files changed, 20 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/radeon.h
>> b/drivers/gpu/drm/radeon/radeon.h
>> index b6cbd81..cf09102 100644
>> --- a/drivers/gpu/drm/radeon/radeon.h
>> +++ b/drivers/gpu/drm/radeon/radeon.h
>> @@ -1889,7 +1889,7 @@ struct radeon_asic {
>> void (*pad_ib)(struct radeon_ib *ib);
>> } vm;
>> /* ring specific callbacks */
>> -   struct radeon_asic_ring *ring[RADEON_NUM_RINGS];
>> +   const struct radeon_asic_ring *ring[RADEON_NUM_RINGS];
>> /* irqs */
>> struct {
>> int (*set)(struct radeon_device *rdev);
>> diff --git a/drivers/gpu/drm/radeon/radeon_asic.c
>> b/drivers/gpu/drm/radeon/radeon_asic.c
>> index 1d4d452..7d5a36d 100644
>> --- a/drivers/gpu/drm/radeon/radeon_asic.c
>> +++ b/drivers/gpu/drm/radeon/radeon_asic.c
>> @@ -179,7 +179,7 @@ void radeon_agp_disable(struct radeon_device *rdev)
>>* ASIC
>>*/
>>   -static struct radeon_asic_ring r100_gfx_ring = {
>> +static const struct radeon_asic_ring r100_gfx_ring = {
>> .ib_execute = _ring_ib_execute,
>> .emit_fence = _fence_ring_emit,
>> .emit_semaphore = _semaphore_ring_emit,
>> @@ -329,7 +329,7 @@ static struct radeon_asic r200_asic = {
>> },
>>   };
>>   -static struct radeon_asic_ring r300_gfx_ring = {
>> +static const struct radeon_asic_ring r300_gfx_ring = {
>> .ib_execute = _ring_ib_execute,
>> .emit_fence = _fence_ring_emit,
>> .emit_semaphore = _semaphore_ring_emit,
>> @@ -343,7 +343,7 @@ static struct radeon_asic_ring r300_gfx_ring = {
>> .set_wptr = _gfx_set_wptr,
>>   };
>>   -static struct radeon_asic_ring rv515_gfx_ring = {
>> +static const struct radeon_asic_ring rv515_gfx_ring = {
>> .ib_execute = _ring_ib_execute,
>> .emit_fence = _fence_ring_emit,
>> .emit_semaphore = _semaphore_ring_emit,
>> @@ -901,7 +901,7 @@ static struct radeon_asic r520_asic = {
>> },
>>   };
>>   -static struct radeon_asic_ring r600_gfx_ring = {
>> +static const struct radeon_asic_ring r600_gfx_ring = {
>> .ib_execute = _ring_ib_execute,
>> .emit_fence = _fence_ring_emit,
>> .emit_semaphore = _semaphore_ring_emit,
>> @@ -914,7 +914,7 @@ static struct radeon_asic_ring r600_gfx_ring = {
>> .set_wptr = _gfx_set_wptr,
>>   };
>>   -static struct radeon_asic_ring r600_dma_ring = {
>> +static const struct radeon_asic_ring r600_dma_ring = {
>> .ib_execute = _dma_ring_ib_execute,
>> .emit_fence = _dma_fence_ring_emit,
>> .emit_semaphore = _dma_semaphore_ring_emit,
>> @@ -999,7 +999,7 @@ static struct radeon_asic r600_asic = {
>> },
>>   };
>>   -static struct radeon_asic_ring rv6xx_uvd_ring = {
>> +static const struct radeon_asic_ring rv6xx_uvd_ring = {
>> .ib_execute = _v1_0_ib_execute,
>> .emit_fence = _v1_0_fence_emit,
>> .emit_semaphore = _v1_0_semaphore_emit,
>> @@ -1198,7 +1198,7 @@ static struct radeon_asic rs780_asic = {
>> },
>>   };
>>   -static struct radeon_asic_ring rv770_uvd_ring = {
>> +static const struct radeon_asic_ring rv770_uvd_ring = {
>> .ib_execute = _v1_0_ib_execute,
>> .emit_fence = _v2_2_fence_emit,
>> .emit_semaphore = _v2_2_semaphore_emit,
>> @@ -1305,7 +1305,7 @@ static struct radeon_asic rv770_asic = {
>> },
>>   };
>>   -static struct radeon_asic_ring evergreen_gfx_ring = {
>> +static const struct radeon_asic_ring evergreen_gfx_ring = {
>> .ib_execute = _ring_ib_execute,
>> .emit_fence = _fence_ring_emit,
>> .emit_semaphore = _semaphore_ring_emit,
>> @@ -1318,7 +1318,7 @@ static struct radeon_asic_ring evergreen_gfx_ring =
>> {
>> .set_wptr = _gfx_set_wptr,
>>   };
>>   -static struct radeon_asic_ring evergreen_dma_ring = {
>> +static const struct radeon_asic_ring evergreen_dma_ring = {
>> .ib_execute = _dma_ring_ib_execute,
>> .emit_fence = _dma_fence_ring_emit,
>> .emit_semaphore = _dma_semaphore_ring_emit,
>> @@ -1612,7 +1612,7 @@ static struct radeon_asic btc_asic = {
>> },
>>   };
>>   -static struct radeon_asic_ring cayman_gfx_ring = {
>> +static const struct radeon_asic_ring cayman_gfx_ring = {
>> .ib_execute = _ring_ib_execute,
>> .ib_parse = _ib_parse,
>> .emit_fence = _fence_ring_emit,
>> @@ -1627,7 +1627,7 @@ static struct radeon_asic_ring cayman_gfx_ring = {
>> .set_wptr 

[PATCH] drm: Fix an unwanted master inheritance

2015-11-30 Thread Thomas Hellstrom
Hi,

On 11/30/2015 04:00 PM, Daniel Vetter wrote:
> On Mon, Nov 30, 2015 at 04:44:21AM -0800, Thomas Hellstrom wrote:
>> A client calling drmSetMaster() using a file descriptor that was opened
>> when another client was master would inherit the latter client's master
>> object and all it's authenticated clients.
>>
>> This is unwanted behaviour, and when this happens, instead allocate a
>> brand new master object for the client calling drmSetMaster().
>>
>> Signed-off-by: Thomas Hellstrom 
> Imo makes sense. It would be great to have a testcase for this, and for
> non-kms stuff igt now has support for generic testcases that can be run on
> any driver. See for example intel-gpu-tools/tests/core_get_auth_client.c.
>
> I or Daniel Stone can help out (on irc or mail) with that.
> -Daniel

Given that this crashes the kernel by vmwgfx throwing a BUG on some
versions of SLE,
while probably all other drivers don't care, except that it's a security
issue, A generic test case involving DRM clients leaking information
between master realms would unfortunately be too resource consuming to
put together for our minimal driver team ;).

Although I used the attached C program run as root to trigger the
behavior and unconditional kernel crash on vmwgfx. On the affected SLE
versions, fd1 would represent Xorg, fd2 would represent plymouthd.

/Thomas

-- next part --
A non-text attachment was scrubbed...
Name: drm_master_bug.c
Type: text/x-csrc
Size: 415 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20151130/6371a8f2/attachment.c>


[PATCH v2 0/3] drm: fix i2c adapter device driver user counter

2015-11-30 Thread Vladimir Zapolskiy
David, Russell,

ping. No response for more than 2 months.

On 02.11.2015 17:10, Vladimir Zapolskiy wrote:
> David, Russell,
> 
> ping.
> 
> On 12.10.2015 16:15, Vladimir Zapolskiy wrote:
>> David, Russell,
>>
>> ping.
>>
>> On 23.09.2015 00:46, Vladimir Zapolskiy wrote:
>>> of_find_i2c_adapter_by_node() call requires quite often missing
>>> put_device(), and i2c_put_adapter() releases a device locked by
>>> i2c_get_adapter() only.
>>>
>>> Below is a common error reproduction scenario as a result of the
>>> misusage described above (this is run on iMX6 platform with
>>> HDMI and I2C bus drivers compiled as kernel modules for clearness):
>>>
>>> root at mx6q:~# lsmod | grep i2c
>>> i2c_imx15348  0
>>> root at mx6q:~# lsmod | grep dw_hdmi_imx
>>> dw_hdmi_imx 3567  0
>>> dw_hdmi15850  1 dw_hdmi_imx
>>> imxdrm  8610  3 dw_hdmi_imx,imx_ipuv3_crtc,imx_ldb
>>> root at mx6q:~# rmmod dw_hdmi_imx
>>> root at mx6q:~# lsmod | grep i2c
>>> i2c_imx15348  -1
>>>
>>>  ^
>>>
>>> root at mx6q:~# rmmod i2c_imx
>>> rmmod: ERROR: Module i2c_imx is in use
>>>
>>> To fix existing users of these interfaces use of_get_i2c_adapter_by_node()
>>> interface, which is similar to i2c_get_adapter() in sense that an I2C bus
>>> device driver found and locked by a user can be correctly unlocked by
>>> i2c_put_adapter() call.
>>>
>>> Changes from v1 to v2:
>>> - none, this series is a straightforward bugfix, v1 was a blend of
>>>   I2C core changes, bugfixes and improvements
>>>
>>> The change is based on dri/drm-next.
>>>
>>> Vladimir Zapolskiy (3):
>>>   drm: dw_hdmi: use of_get_i2c_adapter_by_node interface
>>>   drm: tilcdc: use of_get_i2c_adapter_by_node interface
>>>   drm: tegra: use of_get_i2c_adapter_by_node interface
>>>
>>>  drivers/gpu/drm/bridge/dw_hdmi.c   | 14 +-
>>>  drivers/gpu/drm/tegra/output.c | 23 ---
>>>  drivers/gpu/drm/tilcdc/tilcdc_tfp410.c |  6 ++
>>>  3 files changed, 23 insertions(+), 20 deletions(-)
>>>
>>
> 

--
With best wishes,
Vladimir



[PATCH] drm: Fix an unwanted master inheritance

2015-11-30 Thread Daniel Vetter
On Mon, Nov 30, 2015 at 04:44:21AM -0800, Thomas Hellstrom wrote:
> A client calling drmSetMaster() using a file descriptor that was opened
> when another client was master would inherit the latter client's master
> object and all it's authenticated clients.
> 
> This is unwanted behaviour, and when this happens, instead allocate a
> brand new master object for the client calling drmSetMaster().
> 
> Signed-off-by: Thomas Hellstrom 

Imo makes sense. It would be great to have a testcase for this, and for
non-kms stuff igt now has support for generic testcases that can be run on
any driver. See for example intel-gpu-tools/tests/core_get_auth_client.c.

I or Daniel Stone can help out (on irc or mail) with that.
-Daniel

> ---
>  drivers/gpu/drm/drm_drv.c  | 12 +++
>  drivers/gpu/drm/drm_fops.c | 80 
> ++
>  include/drm/drmP.h |  6 
>  3 files changed, 70 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 9362609..1f072ba 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -160,6 +160,18 @@ int drm_setmaster_ioctl(struct drm_device *dev, void 
> *data,
>   goto out_unlock;
>   }
>  
> + if (!file_priv->allowed_master) {
> + struct drm_master *saved_master = file_priv->master;
> +
> + ret = drm_new_set_master(dev, file_priv);
> + if (ret)
> + file_priv->master = saved_master;
> + else
> + drm_master_put(_master);
> +
> + goto out_unlock;
> + }
> +
>   file_priv->minor->master = drm_master_get(file_priv->master);
>   file_priv->is_master = 1;
>   if (dev->driver->master_set) {
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index c59ce4d..4b5c11c 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -126,6 +126,56 @@ static int drm_cpu_valid(void)
>  }
>  
>  /**
> + * drm_new_set_master - Allocate a new master object and become master for 
> the
> + * associated master realm.
> + *
> + * @dev: The associated device.
> + * @fpriv: File private identifying the client.
> + *
> + * This function must be called with dev::struct_mutex held. Returns negative
> + * error code on failure, zero on success.
> + */
> +int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv)
> +{
> + int ret;
> +
> + lockdep_assert_held_once(>master_mutex);
> + /* create a new master */
> + fpriv->minor->master = drm_master_create(fpriv->minor);
> + if (!fpriv->minor->master)
> + return -ENOMEM;
> +
> + fpriv->is_master = 1;
> + fpriv->allowed_master = 1;
> +
> + /* take another reference for the copy in the local file priv */
> + fpriv->master = drm_master_get(fpriv->minor->master);
> +
> + fpriv->authenticated = 1;
> +
> + if (dev->driver->master_create) {
> + ret = dev->driver->master_create(dev, fpriv->master);
> + if (ret) {
> + /* drop both references if this fails */
> + drm_master_put(>minor->master);
> + drm_master_put(>master);
> + return ret;
> + }
> + }
> + if (dev->driver->master_set) {
> + ret = dev->driver->master_set(dev, fpriv, true);
> + if (ret) {
> + /* drop both references if this fails */
> + drm_master_put(>minor->master);
> + drm_master_put(>master);
> + return ret;
> + }
> + }
> +
> + return 0;
> +}
> +
> +/**
>   * Called whenever a process opens /dev/drm.
>   *
>   * \param filp file pointer.
> @@ -189,35 +239,9 @@ static int drm_open_helper(struct file *filp, struct 
> drm_minor *minor)
>   mutex_lock(>master_mutex);
>   if (drm_is_primary_client(priv) && !priv->minor->master) {
>   /* create a new master */
> - priv->minor->master = drm_master_create(priv->minor);
> - if (!priv->minor->master) {
> - ret = -ENOMEM;
> + ret = drm_new_set_master(dev, priv);
> + if (ret)
>   goto out_close;
> - }
> -
> - priv->is_master = 1;
> - /* take another reference for the copy in the local file priv */
> - priv->master = drm_master_get(priv->minor->master);
> - priv->authenticated = 1;
> -
> - if (dev->driver->master_create) {
> - ret = dev->driver->master_create(dev, priv->master);
> - if (ret) {
> - /* drop both references if this fails */
> - drm_master_put(>minor->master);
> - drm_master_put(>master);
> - goto out_close;
> - }
> -   

[PATCH 1/2] drm: Avoid calling the cursor_set2 callback from the drm_mode_cursor ioctl

2015-11-30 Thread Daniel Vetter
On Mon, Nov 30, 2015 at 02:35:53PM +0100, Thomas Hellstrom wrote:
> On 11/29/2015 10:18 AM, Daniel Vetter wrote:
> > On Fri, Nov 27, 2015 at 01:24:11PM +0100, Thomas Hellstrom wrote:
> >> On 11/27/2015 01:02 PM, Ville Syrjälä wrote:
> >>> On Fri, Nov 27, 2015 at 12:42:15PM +0100, Thomas Hellstrom wrote:
>  On 11/27/2015 11:11 AM, Daniel Vetter wrote:
> > On Thu, Nov 26, 2015 at 10:52:14AM -0800, Thomas Hellstrom wrote:
> >> If the drm_mode_cursor_ioctl is called and the cursor_set2 callback is
> >> implemented, the cursor hotspot is set to (0,0) which is incompatible
> >> with vmwgfx where the hotspot should instead remain unchanged.
> >>
> >> So if the driver implements both cursor_set2 and cursor_set, prefer 
> >> calling
> >> the latter from the drm_mode_cursor ioctl.
> >>
> >> Signed-off-by: Thomas Hellstrom 
> > That looks like papering over a bug in the client - it simply shouldn't
> > mix these two if it expects the hotspot to stick around. There was also
> > recently a big discussion about hotspot behaviour, and the conclusion 
> > was
> > that qxl got it all wrong. Since that was specifically added for qxl I'm
> > not sure how well this was ever tested ...
>  No, this is not the case, This is for old Xorg userspace that first sets
>  the hotspot using our ancient
>  driver-private ioctl and then calls drm_mode_cursor() to update the 
>  cursor.
> 
>  Now if we were to implement cursor_set2, which is apparently needed to
>  get gnome-shell/Wayland cursors in the right place, without this fix, it
>  would break old Xorg, so we don't have much choice in this case from
>  what I can tell.
> 
>  The root problem here is that the drm_mode_cursor() behaviour in the
>  presence of cursor_set2 didn't take the existing vmware hotspot
>  semantics into account.
> > Ugh. I think the simplest solution is to not mix up the two hotspots, i.e.
> > separately keep track of both the legacy vmwgfx hotspot and the drm core
> > hotspot. Then in the actual cursor set code add them. A bit of ugly in the
> > vmwgfx code (but not much), instead of leaking that driver private legacy
> > ioctl semantics into drm core. Would that work?
> >
> >
> Hmm.
> 
> Yes it would probably work. Good idea.
> I guess we just need to make sure that both hotspots are reset to (0,0)
> at master drop.

Resetting kms state is an entire different can of worms topic. On one hand
we don't want it, since if you apply changes from the default (at early
boot or maybe with kernel cmdline options) we want userspace to take over
all those settings. Otoh if your compositor dies and leaves a mess behind
we should reset to /something/, but due to the above it's undefined what
the reset values should be. At least in general. The other problem is
trying to figure out when exactly you should restore - we already have
plenty fun trying to decide when to restore fbcon, with a pile of hacks.

With atomic at least userspace can take a full snapshot of all kms state,
even if it doesn't understand all the properties. Only requirement is that
all tunables are exported as properties. Then it can always restore that
snapshot. Given that I'm leaning towars "this should be solved in
userspace by some priveldged daemon like logind". Means old userspace is
out of luck if X dies (at least for all the properties that don't get
naturally overwritten), but that's been the case since forever.

Trying to do that in the kernel is imo something that's not really
possible - the kernel knows too little about overall system state and
configuration.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH v2 14/22] drm/exynos: fimd: fix dma burst size setting for small plane size

2015-11-30 Thread Daniel Stone
Hi,

On 30 November 2015 at 13:53, Marek Szyprowski  
wrote:
> This patch fixes trashed display of buffers cropped to very small width.
> Even if DMA is unstable and causes tearing when changing the burst size,
> it is still better than displaying a garbage.
>
> Signed-off-by: Marek Szyprowski 

Reviewed-by: Daniel Stone 

Cheers,
Daniel


[PATCH 1/3] drm/amdgpu: use $(src) in Makefile

2015-11-30 Thread Alex Deucher
On Tue, Nov 24, 2015 at 3:55 AM, Jammy Zhou  wrote:
> This can solve the path problem when compile amdgpu with DKMS.
>
> Signed-off-by: Jammy Zhou 
> Acked-by: Alex Deucher 

Applied and rebased for drm-next.  I'll adapt the acp, powerplay, etc.
changes as those components make it upstream.

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/Makefile | 14 --
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile 
> b/drivers/gpu/drm/amd/amdgpu/Makefile
> index 156b726..0540a20 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Makefile
> +++ b/drivers/gpu/drm/amd/amdgpu/Makefile
> @@ -2,12 +2,14 @@
>  # Makefile for the drm device driver.  This driver provides support for the
>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>
> -ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/amd/include/asic_reg \
> -   -Idrivers/gpu/drm/amd/include \
> -   -Idrivers/gpu/drm/amd/amdgpu \
> -   -Idrivers/gpu/drm/amd/scheduler \
> -   -Idrivers/gpu/drm/amd/powerplay/inc \
> -   -Idrivers/gpu/drm/amd/acp/include
> +FULL_AMD_PATH=$(src)/..
> +
> +ccflags-y := -Iinclude/drm -I$(FULL_AMD_PATH)/include/asic_reg \
> +   -I$(FULL_AMD_PATH)/include \
> +   -I$(FULL_AMD_PATH)/amdgpu \
> +   -I$(FULL_AMD_PATH)/scheduler \
> +   -I$(FULL_AMD_PATH)/powerplay/inc \
> +   -I$(FULL_AMD_PATH)/acp/include
>
>  amdgpu-y := amdgpu_drv.o
>
> --
> 1.9.1
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/atomic-helper: Grab connection_mutex while duplicating state

2015-11-30 Thread Matt Roper
Callers of drm_atomic_helper_duplicate_state() may not have grabbed
locks before calling this function.  We're not supposed to iterate over
connectors without holding connection_mutex (since MST allows new
connectors to be spawned at hotplug), so make sure we grab that
ourselves before invoking drm_for_each_connector().  Failure to grab
this lock would cause us to stumble over the assertion added in commit:

commit 7a3f3d6667f5f9ffd1517f6b21d64bbf5312042c
Author: Daniel Vetter 
Date:   Thu Jul 9 23:44:28 2015 +0200

drm: Check locking in drm_for_each_connector

Cc: Daniel Vetter 
Cc: Maarten Lankhorst 
Signed-off-by: Matt Roper 
---
 drivers/gpu/drm/drm_atomic_helper.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 3731a26..e5d0b21 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2478,6 +2478,10 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev,
}
}

+   err = drm_modeset_lock(>mode_config.connection_mutex, ctx);
+   if (err)
+   goto free;
+
drm_for_each_connector(conn, dev) {
struct drm_connector_state *conn_state;

-- 
2.1.4



[PATCH 20/20] drm: via: remove userland header

2015-11-30 Thread Gabriel Laskar
via_drmclient.h comes from userland drivers, it should not be in the
kernel public headers. Moreover, this does not compile if taken outside
of the drivers.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/via_drm.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/uapi/drm/via_drm.h b/include/uapi/drm/via_drm.h
index fd11a5b..12507e0 100644
--- a/include/uapi/drm/via_drm.h
+++ b/include/uapi/drm/via_drm.h
@@ -33,10 +33,6 @@
 #ifndef _VIA_DEFINES_
 #define _VIA_DEFINES_

-#ifndef __KERNEL__
-#include "via_drmclient.h"
-#endif
-
 #define VIA_NR_SAREA_CLIPRECTS 8
 #define VIA_NR_XVMC_PORTS   10
 #define VIA_NR_XVMC_LOCKS   5
-- 
2.6.2



[PATCH 19/20] drm: fix inclusion of drm.h in via_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/via_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/via_drm.h b/include/uapi/drm/via_drm.h
index 45bc80c..fd11a5b 100644
--- a/include/uapi/drm/via_drm.h
+++ b/include/uapi/drm/via_drm.h
@@ -24,7 +24,7 @@
 #ifndef _VIA_DRM_H_
 #define _VIA_DRM_H_

-#include 
+#include "drm.h"

 /* WARNING: These defines must be the same as what the Xserver uses.
  * if you change them, you must change the defines in the Xserver.
-- 
2.6.2



[PATCH 18/20] drm: fix inclusion of drm.h in vmwgfx_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/vmwgfx_drm.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/uapi/drm/vmwgfx_drm.h b/include/uapi/drm/vmwgfx_drm.h
index 05b2049..2454543 100644
--- a/include/uapi/drm/vmwgfx_drm.h
+++ b/include/uapi/drm/vmwgfx_drm.h
@@ -28,9 +28,7 @@
 #ifndef __VMWGFX_DRM_H__
 #define __VMWGFX_DRM_H__

-#ifndef __KERNEL__
-#include 
-#endif
+#include "drm.h"

 #define DRM_VMW_MAX_SURFACE_FACES 6
 #define DRM_VMW_MAX_MIP_LEVELS 24
-- 
2.6.2



[PATCH 17/20] drm: fix inclusion of drm.h in virtgpu_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/virtgpu_drm.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h
index 4bcfbe6..c74f1f9 100644
--- a/include/uapi/drm/virtgpu_drm.h
+++ b/include/uapi/drm/virtgpu_drm.h
@@ -24,8 +24,7 @@
 #ifndef VIRTGPU_DRM_H
 #define VIRTGPU_DRM_H

-#include 
-#include "drm/drm.h"
+#include "drm.h"

 /* Please note that modifications to all structs defined here are
  * subject to backwards-compatibility constraints.
-- 
2.6.2



[PATCH 16/20] drm: fix inclusion of drm.h in tegra_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/tegra_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/tegra_drm.h b/include/uapi/drm/tegra_drm.h
index 5391780..27d0b05 100644
--- a/include/uapi/drm/tegra_drm.h
+++ b/include/uapi/drm/tegra_drm.h
@@ -23,7 +23,7 @@
 #ifndef _UAPI_TEGRA_DRM_H_
 #define _UAPI_TEGRA_DRM_H_

-#include 
+#include "drm.h"

 #define DRM_TEGRA_GEM_CREATE_TILED (1 << 0)
 #define DRM_TEGRA_GEM_CREATE_BOTTOM_UP (1 << 1)
-- 
2.6.2



[PATCH 15/20] drm: fix inclusion of drm.h in savage_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/savage_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/savage_drm.h b/include/uapi/drm/savage_drm.h
index 9dc9dc1..5741474 100644
--- a/include/uapi/drm/savage_drm.h
+++ b/include/uapi/drm/savage_drm.h
@@ -26,7 +26,7 @@
 #ifndef __SAVAGE_DRM_H__
 #define __SAVAGE_DRM_H__

-#include 
+#include "drm.h"

 #ifndef __SAVAGE_SAREA_DEFINES__
 #define __SAVAGE_SAREA_DEFINES__
-- 
2.6.2



[PATCH 14/20] drm: fix inclusion of drm.h in r128_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/r128_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/r128_drm.h b/include/uapi/drm/r128_drm.h
index 76b0aa3..7a44c65 100644
--- a/include/uapi/drm/r128_drm.h
+++ b/include/uapi/drm/r128_drm.h
@@ -33,7 +33,7 @@
 #ifndef __R128_DRM_H__
 #define __R128_DRM_H__

-#include 
+#include "drm.h"

 /* WARNING: If you change any of these defines, make sure to change the
  * defines in the X server file (r128_sarea.h)
-- 
2.6.2



[PATCH 13/20] drm: fix inclusion of drm.h in qxl_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/qxl_drm.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/uapi/drm/qxl_drm.h b/include/uapi/drm/qxl_drm.h
index ebebd36..4387b57 100644
--- a/include/uapi/drm/qxl_drm.h
+++ b/include/uapi/drm/qxl_drm.h
@@ -24,8 +24,7 @@
 #ifndef QXL_DRM_H
 #define QXL_DRM_H

-#include 
-#include "drm/drm.h"
+#include "drm.h"

 /* Please note that modifications to all structs defined here are
  * subject to backwards-compatibility constraints.
-- 
2.6.2



[PATCH 12/20] drm: fix inclusion of drm.h in omap_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/omap_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/omap_drm.h b/include/uapi/drm/omap_drm.h
index 1d0b117..0750c01 100644
--- a/include/uapi/drm/omap_drm.h
+++ b/include/uapi/drm/omap_drm.h
@@ -20,7 +20,7 @@
 #ifndef __OMAP_DRM_H__
 #define __OMAP_DRM_H__

-#include 
+#include "drm.h"

 /* Please note that modifications to all structs defined here are
  * subject to backwards-compatibility constraints.
-- 
2.6.2



[PATCH 11/20] drm: fix inclusion of drm.h in msm_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/msm_drm.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index 75a232b..e995ffb 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -18,8 +18,7 @@
 #ifndef __MSM_DRM_H__
 #define __MSM_DRM_H__

-#include 
-#include 
+#include "drm.h"

 /* Please note that modifications to all structs defined here are
  * subject to backwards-compatibility constraints:
-- 
2.6.2



[PATCH 10/20] drm: fix inclusion of drm.h in mga_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/mga_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/mga_drm.h b/include/uapi/drm/mga_drm.h
index 2375bfd..fca8170 100644
--- a/include/uapi/drm/mga_drm.h
+++ b/include/uapi/drm/mga_drm.h
@@ -35,7 +35,7 @@
 #ifndef __MGA_DRM_H__
 #define __MGA_DRM_H__

-#include 
+#include "drm.h"

 /* WARNING: If you change any of these defines, make sure to change the
  * defines in the Xserver file (mga_sarea.h)
-- 
2.6.2



[PATCH 09/20] drm: fix inclusion of drm.h in exynos_sarea.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/i915_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 484a9fb..07dcba2 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -27,7 +27,7 @@
 #ifndef _UAPI_I915_DRM_H_
 #define _UAPI_I915_DRM_H_

-#include 
+#include "drm.h"

 /* Please note that modifications to all structs defined here are
  * subject to backwards-compatibility constraints.
-- 
2.6.2



[PATCH 08/20] drm: fix inclusion of drm.h in i810_drm.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for
the libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/i810_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/i810_drm.h b/include/uapi/drm/i810_drm.h
index 34736ef..bdb0287 100644
--- a/include/uapi/drm/i810_drm.h
+++ b/include/uapi/drm/i810_drm.h
@@ -1,7 +1,7 @@
 #ifndef _I810_DRM_H_
 #define _I810_DRM_H_

-#include 
+#include "drm.h"

 /* WARNING: These defines must be the same as what the Xserver uses.
  * if you change them, you must change the defines in the Xserver.
-- 
2.6.2



[PATCH 07/20] drm: fix inclusion of drm.h in exynos_sarea.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/exynos_drm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
index 5575ed1..a5b2dd9 100644
--- a/include/uapi/drm/exynos_drm.h
+++ b/include/uapi/drm/exynos_drm.h
@@ -15,7 +15,7 @@
 #ifndef _UAPI_EXYNOS_DRM_H_
 #define _UAPI_EXYNOS_DRM_H_

-#include 
+#include "drm.h"

 /**
  * User-desired buffer creation information structure.
-- 
2.6.2



[PATCH 06/20] drm: fix inclusion of drm.h in drm_sarea.h

2015-11-30 Thread Gabriel Laskar
Using `#include "drm.h"` instead of `#include ` allow drm
headers to be moved in another directory without changes, like for the
libdrm imports.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/drm_sarea.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/drm_sarea.h b/include/uapi/drm/drm_sarea.h
index 413a564..1d1a858 100644
--- a/include/uapi/drm/drm_sarea.h
+++ b/include/uapi/drm/drm_sarea.h
@@ -32,7 +32,7 @@
 #ifndef _DRM_SAREA_H_
 #define _DRM_SAREA_H_

-#include 
+#include "drm.h"

 /* SAREA area needs to be at least a page */
 #if defined(__alpha__)
-- 
2.6.2



[PATCH 05/20] drm: drm_mode.h fix includes

2015-11-30 Thread Gabriel Laskar
Instead of using linux/types.h, drm headers should use drm.h, in order
to handle the portability issues in only one place.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/drm_mode.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 6c11ca4..9c9f61d 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -27,7 +27,7 @@
 #ifndef _DRM_MODE_H
 #define _DRM_MODE_H

-#include 
+#include "drm.h"

 #define DRM_DISPLAY_INFO_LEN   32
 #define DRM_CONNECTOR_NAME_LEN 32
-- 
2.6.2



[PATCH 04/20] drm: drm_fourcc.h fix includes

2015-11-30 Thread Gabriel Laskar
Instead of using linux/types.h, drm headers should use drm.h, in order
to handle the portability issues in only one place.

Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/drm_fourcc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 8c5e8b9..86abf67 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -24,7 +24,7 @@
 #ifndef DRM_FOURCC_H
 #define DRM_FOURCC_H

-#include 
+#include "drm.h"

 #define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
 ((__u32)(c) << 16) | ((__u32)(d) << 24))
-- 
2.6.2



[PATCH 03/20] drm: include drm.h in armada_drm.h

2015-11-30 Thread Gabriel Laskar
Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/armada_drm.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/uapi/drm/armada_drm.h b/include/uapi/drm/armada_drm.h
index 8dec3fd..6de7f01 100644
--- a/include/uapi/drm/armada_drm.h
+++ b/include/uapi/drm/armada_drm.h
@@ -9,6 +9,8 @@
 #ifndef DRM_ARMADA_IOCTL_H
 #define DRM_ARMADA_IOCTL_H

+#include "drm.h"
+
 #define DRM_ARMADA_GEM_CREATE  0x00
 #define DRM_ARMADA_GEM_MMAP0x02
 #define DRM_ARMADA_GEM_PWRITE  0x03
-- 
2.6.2



[PATCH 02/20] drm: Kbuild: add admgpu_drm.h to the installed headers

2015-11-30 Thread Gabriel Laskar
Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/Kbuild | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/drm/Kbuild b/include/uapi/drm/Kbuild
index 38d4370..159551f 100644
--- a/include/uapi/drm/Kbuild
+++ b/include/uapi/drm/Kbuild
@@ -3,6 +3,7 @@ header-y += drm.h
 header-y += drm_fourcc.h
 header-y += drm_mode.h
 header-y += drm_sarea.h
+header-y += amdgpu_drm.h
 header-y += exynos_drm.h
 header-y += i810_drm.h
 header-y += i915_drm.h
-- 
2.6.2



[PATCH 01/20] drm: use __u{32, 64} instead of uint{32, 64}_t in virtgpu_drm.h

2015-11-30 Thread Gabriel Laskar
Signed-off-by: Gabriel Laskar 
CC: Emil Velikov 
CC: Mikko Rapeli 

---
 include/uapi/drm/virtgpu_drm.h | 98 +-
 1 file changed, 49 insertions(+), 49 deletions(-)

diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h
index fc9e2d6..4bcfbe6 100644
--- a/include/uapi/drm/virtgpu_drm.h
+++ b/include/uapi/drm/virtgpu_drm.h
@@ -30,7 +30,7 @@
 /* Please note that modifications to all structs defined here are
  * subject to backwards-compatibility constraints.
  *
- * Do not use pointers, use uint64_t instead for 32 bit / 64 bit user/kernel
+ * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel
  * compatibility Keep fields aligned to their size
  */

@@ -45,88 +45,88 @@
 #define DRM_VIRTGPU_GET_CAPS  0x09

 struct drm_virtgpu_map {
-   uint64_t offset; /* use for mmap system call */
-   uint32_t handle;
-   uint32_t pad;
+   __u64 offset; /* use for mmap system call */
+   __u32 handle;
+   __u32 pad;
 };

 struct drm_virtgpu_execbuffer {
-   uint32_tflags;  /* for future use */
-   uint32_t size;
-   uint64_t command; /* void* */
-   uint64_t bo_handles;
-   uint32_t num_bo_handles;
-   uint32_t pad;
+   __u32   flags;  /* for future use */
+   __u32 size;
+   __u64 command; /* void* */
+   __u64 bo_handles;
+   __u32 num_bo_handles;
+   __u32 pad;
 };

 #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */

 struct drm_virtgpu_getparam {
-   uint64_t param;
-   uint64_t value;
+   __u64 param;
+   __u64 value;
 };

 /* NO_BO flags? NO resource flag? */
 /* resource flag for y_0_top */
 struct drm_virtgpu_resource_create {
-   uint32_t target;
-   uint32_t format;
-   uint32_t bind;
-   uint32_t width;
-   uint32_t height;
-   uint32_t depth;
-   uint32_t array_size;
-   uint32_t last_level;
-   uint32_t nr_samples;
-   uint32_t flags;
-   uint32_t bo_handle; /* if this is set - recreate a new resource 
attached to this bo ? */
-   uint32_t res_handle;  /* returned by kernel */
-   uint32_t size;/* validate transfer in the host */
-   uint32_t stride;  /* validate transfer in the host */
+   __u32 target;
+   __u32 format;
+   __u32 bind;
+   __u32 width;
+   __u32 height;
+   __u32 depth;
+   __u32 array_size;
+   __u32 last_level;
+   __u32 nr_samples;
+   __u32 flags;
+   __u32 bo_handle; /* if this is set - recreate a new resource attached 
to this bo ? */
+   __u32 res_handle;  /* returned by kernel */
+   __u32 size;/* validate transfer in the host */
+   __u32 stride;  /* validate transfer in the host */
 };

 struct drm_virtgpu_resource_info {
-   uint32_t bo_handle;
-   uint32_t res_handle;
-   uint32_t size;
-   uint32_t stride;
+   __u32 bo_handle;
+   __u32 res_handle;
+   __u32 size;
+   __u32 stride;
 };

 struct drm_virtgpu_3d_box {
-   uint32_t x;
-   uint32_t y;
-   uint32_t z;
-   uint32_t w;
-   uint32_t h;
-   uint32_t d;
+   __u32 x;
+   __u32 y;
+   __u32 z;
+   __u32 w;
+   __u32 h;
+   __u32 d;
 };

 struct drm_virtgpu_3d_transfer_to_host {
-   uint32_t bo_handle;
+   __u32 bo_handle;
struct drm_virtgpu_3d_box box;
-   uint32_t level;
-   uint32_t offset;
+   __u32 level;
+   __u32 offset;
 };

 struct drm_virtgpu_3d_transfer_from_host {
-   uint32_t bo_handle;
+   __u32 bo_handle;
struct drm_virtgpu_3d_box box;
-   uint32_t level;
-   uint32_t offset;
+   __u32 level;
+   __u32 offset;
 };

 #define VIRTGPU_WAIT_NOWAIT 1 /* like it */
 struct drm_virtgpu_3d_wait {
-   uint32_t handle; /* 0 is an invalid handle */
-   uint32_t flags;
+   __u32 handle; /* 0 is an invalid handle */
+   __u32 flags;
 };

 struct drm_virtgpu_get_caps {
-   uint32_t cap_set_id;
-   uint32_t cap_set_ver;
-   uint64_t addr;
-   uint32_t size;
-   uint32_t pad;
+   __u32 cap_set_id;
+   __u32 cap_set_ver;
+   __u64 addr;
+   __u32 size;
+   __u32 pad;
 };

 #define DRM_IOCTL_VIRTGPU_MAP \
-- 
2.6.2



[PATCH v2 22/22] drm/exynos: add support for plane rotation, scalling and colospace convesion

2015-11-30 Thread Marek Szyprowski
This patch adds generic plane rotation property for all supported
drivers. This has been implemented with additional help from Exynos IPP
(Exynos Image Post-Processing subsystem) with temporary framebuffers.
Besides rotation, scaling and color space conversion are also supported.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/Kconfig|   8 +
 drivers/gpu/drm/exynos/Makefile   |   1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |   9 +
 drivers/gpu/drm/exynos/exynos_drm_ipp.c   | 154 ++-
 drivers/gpu/drm/exynos/exynos_drm_ipp.h   |   4 +
 drivers/gpu/drm/exynos/exynos_drm_plane.c |  28 +-
 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.c | 369 ++
 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.h |  73 +
 8 files changed, 641 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_plane_ipp.h

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 83efca941388..e7d414aefbdc 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -104,6 +104,14 @@ config DRM_EXYNOS_IPP
help
  Choose this option if you want to use IPP feature for DRM.

+config DRM_EXYNOS_PLANE_IPP
+   depends on DRM_EXYNOS_IPP
+   bool "Use IPP framework for implementing unsupported plane properties"
+   help
+ Choose this option if you want to let IPP framework to provide plane
+ properties (like rotation, overlay scaling and more pixel formats),
+ which are not supported by hardware CRTC drivers.
+
 config DRM_EXYNOS_FIMC
bool "FIMC"
depends on DRM_EXYNOS_IPP && MFD_SYSCON
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 6496532aaa91..92c3f7cac7a9 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -19,6 +19,7 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI)   += exynos_hdmi.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)+= exynos_drm_vidi.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_G2D) += exynos_drm_g2d.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_IPP) += exynos_drm_ipp.o
+exynosdrm-$(CONFIG_DRM_EXYNOS_PLANE_IPP)   += exynos_drm_plane_ipp.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)+= exynos_drm_fimc.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR) += exynos_drm_rotator.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_GSC) += exynos_drm_gsc.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 670f6d06a2a9..b17e419935db 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -70,6 +70,13 @@ struct exynos_drm_plane_state {
unsigned int h_ratio;
unsigned int v_ratio;
struct drm_framebuffer *fb;
+   unsigned int rotation;
+
+   unsigned int ipp_needed;
+   uint32_t ipp_pixel_format;
+   struct exynos_drm_rect ipp_src;
+   struct exynos_drm_rect ipp_dst;
+   struct drm_framebuffer *ipp_fb;
 };

 static inline struct exynos_drm_plane_state *
@@ -93,6 +100,8 @@ struct exynos_drm_plane {
const struct exynos_drm_plane_config *config;
unsigned int zpos;
struct drm_framebuffer *pending_fb;
+   struct drm_framebuffer *ipp_cur_fb;
+   struct drm_framebuffer *ipp_next_fb;
 };

 #define EXYNOS_DRM_PLANE_CAP_DOUBLE(1 << 0)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c 
b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 44a6689e0f4c..231cfbfe036c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include "exynos_drm_drv.h"
+#include "exynos_drm_fb.h"
 #include "exynos_drm_gem.h"
 #include "exynos_drm_ipp.h"
 #include "exynos_drm_iommu.h"
@@ -1513,7 +1514,7 @@ static int ipp_send_event(struct exynos_drm_ippdrv 
*ippdrv,

spin_lock_irqsave(_dev->event_lock, flags);
list_move_tail(>base.link, >base.file_priv->event_list);
-   wake_up_interruptible(>base.file_priv->event_wait);
+   wake_up(>base.file_priv->event_wait);
spin_unlock_irqrestore(_dev->event_lock, flags);
mutex_unlock(_node->event_lock);

@@ -1579,6 +1580,157 @@ err_completion:
complete(_node->start_complete);
 }

+static struct drm_exynos_ipp_mem_node
+   *ipp_get_internal_mem_node(struct drm_device *drm_dev,
+   struct drm_exynos_ipp_cmd_node *c_node,
+   __u32 prop_id, enum drm_exynos_ops_id ops_id,
+   struct drm_framebuffer *fb)
+{
+   struct drm_exynos_ipp_mem_node *m_node;
+   struct drm_exynos_ipp_buf_info *buf_info;
+   int i;
+
+   m_node = kzalloc(sizeof(*m_node), GFP_KERNEL);
+   if (!m_node)
+   return ERR_PTR(-ENOMEM);
+
+   buf_info = _node->buf_info;
+
+   m_node->ops_id = ops_id;
+   m_node->prop_id = prop_id;
+   

[PATCH v2 21/22] drm/exynos: ipp: make framework context global

2015-11-30 Thread Marek Szyprowski
IPP framework stored global context in driver data of its platform device.
This patch moves it to global variable to simplify access. There exists
only one such framework, so there is no drawback of this change.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_ipp.c | 50 ++---
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c 
b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index 0404e18d84cc..44a6689e0f4c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -42,7 +42,6 @@
  * 7. need to power_on implement power and sysmmu ctrl.
  */

-#define get_ipp_context(dev)   platform_get_drvdata(to_platform_device(dev))
 #define ipp_is_m2m_cmd(c)  (c == IPP_CMD_M2M)

 /*
@@ -95,6 +94,7 @@ struct ipp_context {
struct workqueue_struct *cmd_workq;
 };

+static struct ipp_context *ctx;
 static LIST_HEAD(exynos_drm_ippdrv_list);
 static DEFINE_MUTEX(exynos_drm_ippdrv_lock);
 static BLOCKING_NOTIFIER_HEAD(exynos_drm_ippnb_list);
@@ -226,9 +226,6 @@ static struct exynos_drm_ippdrv *ipp_find_drv_by_handle(u32 
prop_id)
 int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void *data,
struct drm_file *file)
 {
-   struct drm_exynos_file_private *file_priv = file->driver_priv;
-   struct device *dev = file_priv->ipp_dev;
-   struct ipp_context *ctx = get_ipp_context(dev);
struct drm_exynos_ipp_prop_list *prop_list = data;
struct exynos_drm_ippdrv *ippdrv;
int count = 0;
@@ -320,9 +317,6 @@ static struct drm_exynos_ipp_event_work 
*ipp_create_event_work(void)
 int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
struct drm_file *file)
 {
-   struct drm_exynos_file_private *file_priv = file->driver_priv;
-   struct device *dev = file_priv->ipp_dev;
-   struct ipp_context *ctx = get_ipp_context(dev);
struct drm_exynos_ipp_property *property = data;
struct exynos_drm_ippdrv *ippdrv;
struct drm_exynos_ipp_cmd_node *c_node;
@@ -803,22 +797,18 @@ static int ipp_set_mem_node(struct exynos_drm_ippdrv 
*ippdrv,
return ret;
 }

-static void ipp_handle_cmd_work(struct device *dev,
-   struct exynos_drm_ippdrv *ippdrv,
-   struct drm_exynos_ipp_cmd_work *cmd_work,
-   struct drm_exynos_ipp_cmd_node *c_node)
+static void ipp_handle_cmd_work(struct exynos_drm_ippdrv *ippdrv,
+   struct drm_exynos_ipp_cmd_work *cmd_work,
+   struct drm_exynos_ipp_cmd_node *c_node)
 {
-   struct ipp_context *ctx = get_ipp_context(dev);
-
cmd_work->ippdrv = ippdrv;
cmd_work->c_node = c_node;
queue_work(ctx->cmd_workq, _work->work);
 }

-static int ipp_queue_buf_with_run(struct device *dev,
-   struct drm_exynos_ipp_cmd_node *c_node,
-   struct drm_exynos_ipp_mem_node *m_node,
-   struct drm_exynos_ipp_queue_buf *qbuf)
+static int ipp_queue_buf_with_run(struct drm_exynos_ipp_cmd_node *c_node,
+ struct drm_exynos_ipp_mem_node *m_node,
+ struct drm_exynos_ipp_queue_buf *qbuf)
 {
struct exynos_drm_ippdrv *ippdrv;
struct drm_exynos_ipp_property *property;
@@ -859,7 +849,7 @@ static int ipp_queue_buf_with_run(struct device *dev,
struct drm_exynos_ipp_cmd_work *cmd_work = c_node->start_work;

cmd_work->ctrl = IPP_CTRL_PLAY;
-   ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
+   ipp_handle_cmd_work(ippdrv, cmd_work, c_node);
} else {
ret = ipp_set_mem_node(ippdrv, c_node, m_node);
if (ret) {
@@ -893,9 +883,6 @@ static void ipp_clean_queue_buf(struct drm_device *drm_dev,
 int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
struct drm_file *file)
 {
-   struct drm_exynos_file_private *file_priv = file->driver_priv;
-   struct device *dev = file_priv->ipp_dev;
-   struct ipp_context *ctx = get_ipp_context(dev);
struct drm_exynos_ipp_queue_buf *qbuf = data;
struct drm_exynos_ipp_cmd_node *c_node;
struct drm_exynos_ipp_mem_node *m_node;
@@ -950,7 +937,7 @@ int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, 
void *data,
 * M2M case run play control for streaming feature.
 * other case set address and waiting.
 */
-   ret = ipp_queue_buf_with_run(dev, c_node, m_node, qbuf);
+   ret = ipp_queue_buf_with_run(c_node, m_node, qbuf);
if (ret) {
DRM_ERROR("failed to run command.\n");
goto err_clean_node;
@@ -1024,10 +1011,7 @@ err_status:
 int exynos_drm_ipp_cmd_ctrl(struct drm_device 

[PATCH v2 20/22] drm/exynos: gem: simplify access to exynos gem object

2015-11-30 Thread Marek Szyprowski
Replace calls to exynos_drm_gem_get_{dma_addr,size}, by a simpler
function exynos_drm_gem_get(). This lets the caller to get access to
exynos_drm_gem object and extract any information about GEM object
without searching object tree for getting each parameter.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_g2d.c | 48 +-
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 52 +
 drivers/gpu/drm/exynos/exynos_drm_gem.h | 23 +--
 drivers/gpu/drm/exynos/exynos_drm_ipp.c | 41 ++
 drivers/gpu/drm/exynos/exynos_drm_ipp.h |  2 +-
 5 files changed, 52 insertions(+), 114 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c 
b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index c17efdb238a6..7c83e64f9f1c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -179,7 +179,7 @@ struct g2d_buf_desc {
 struct g2d_buf_info {
unsigned intmap_nr;
enum g2d_reg_type   reg_types[MAX_REG_TYPE_NR];
-   unsigned long   handles[MAX_REG_TYPE_NR];
+   void*obj[MAX_REG_TYPE_NR];
unsigned inttypes[MAX_REG_TYPE_NR];
struct g2d_buf_desc descs[MAX_REG_TYPE_NR];
 };
@@ -360,11 +360,10 @@ add_to_list:
 }

 static void g2d_userptr_put_dma_addr(struct drm_device *drm_dev,
-   unsigned long obj,
+   void *obj,
bool force)
 {
-   struct g2d_cmdlist_userptr *g2d_userptr =
-   (struct g2d_cmdlist_userptr *)obj;
+   struct g2d_cmdlist_userptr *g2d_userptr = obj;
struct page **pages;

if (!obj)
@@ -407,7 +406,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
unsigned long userptr,
unsigned long size,
struct drm_file *filp,
-   unsigned long *obj)
+   void **obj)
 {
struct drm_exynos_file_private *file_priv = filp->driver_priv;
struct exynos_drm_g2d_private *g2d_priv = file_priv->g2d_priv;
@@ -434,7 +433,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
 */
if (g2d_userptr->size == size) {
atomic_inc(_userptr->refcount);
-   *obj = (unsigned long)g2d_userptr;
+   *obj = g2d_userptr;

return _userptr->dma_addr;
}
@@ -517,7 +516,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct 
drm_device *drm_dev,
g2d_userptr->in_pool = true;
}

-   *obj = (unsigned long)g2d_userptr;
+   *obj = g2d_userptr;

return _userptr->dma_addr;

@@ -549,9 +548,7 @@ static void g2d_userptr_free_all(struct drm_device *drm_dev,

list_for_each_entry_safe(g2d_userptr, n, _priv->userptr_list, list)
if (g2d_userptr->in_pool)
-   g2d_userptr_put_dma_addr(drm_dev,
-   (unsigned long)g2d_userptr,
-   true);
+   g2d_userptr_put_dma_addr(drm_dev, g2d_userptr, true);

g2d->current_pool = 0;
 }
@@ -706,26 +703,23 @@ static int g2d_map_cmdlist_gem(struct g2d_data *g2d,
buf_desc = _info->descs[reg_type];

if (buf_info->types[reg_type] == BUF_TYPE_GEM) {
-   unsigned long size;
+   struct exynos_drm_gem *exynos_gem;

-   size = exynos_drm_gem_get_size(drm_dev, handle, file);
-   if (!size) {
+   exynos_gem = exynos_drm_gem_get(drm_dev, handle, file);
+   if (IS_ERR(exynos_gem)) {
ret = -EFAULT;
goto err;
}

if (!g2d_check_buf_desc_is_valid(buf_desc, reg_type,
-   size)) {
+exynos_gem->size)) {
+   exynos_drm_gem_put(drm_dev, exynos_gem);
ret = -EFAULT;
goto err;
}

-   addr = exynos_drm_gem_get_dma_addr(drm_dev, handle,
-   file);
-   if (IS_ERR(addr)) {
-   ret = -EFAULT;
-   goto err;
-   }
+   addr = _gem->dma_addr;
+   

[PATCH v2 19/22] drm/exynos: fix to calculate offset of each plane for ipp gsc

2015-11-30 Thread Marek Szyprowski
From: Seung-Woo Kim 

NV12 and YUV420 formats are needed to calculate offset of each plane
in a gem buffer for ipp gsc. Without proper offset, only Y plane
can be processed, so result shows green frame. This patch fixes to
calculate offset for cbcr planes for NV12 and YUV420 formats.

Signed-off-by: Seung-Woo Kim 
Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 116 
 1 file changed, 116 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c 
b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
index 7aecd23cfa11..2882b9347cc8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -486,6 +486,98 @@ static void gsc_handle_irq(struct gsc_context *ctx, bool 
enable,
gsc_write(cfg, GSC_IRQ);
 }

+static int gsc_set_planar_addr(struct drm_exynos_ipp_buf_info *buf_info,
+   u32 fmt, struct drm_exynos_sz *sz)
+{
+   dma_addr_t *base[EXYNOS_DRM_PLANAR_MAX];
+   uint64_t size[EXYNOS_DRM_PLANAR_MAX];
+   uint64_t ofs[EXYNOS_DRM_PLANAR_MAX];
+   bool bypass = false;
+   uint64_t tsize = 0;
+   int i;
+
+   for_each_ipp_planar(i) {
+   base[i] = _info->base[i];
+   size[i] = buf_info->size[i];
+   ofs[i] = 0;
+   tsize += size[i];
+   DRM_DEBUG_KMS("base[%d][0x%lx]s[%d][%llu]\n",
+   i, (unsigned long)*base[i], i, size[i]);
+   }
+
+   if (!tsize) {
+   DRM_INFO("failed to get buffer size.\n");
+   return 0;
+   }
+
+   switch (fmt) {
+   case DRM_FORMAT_NV12:
+   case DRM_FORMAT_NV21:
+   case DRM_FORMAT_NV16:
+   case DRM_FORMAT_NV61:
+   ofs[0] = sz->hsize * sz->vsize;
+   ofs[1] = ofs[0] >> 1;
+   if (*base[0] && *base[1]) {
+   if (size[0] + size[1] < ofs[0] + ofs[1])
+   goto err_info;
+   bypass = true;
+   }
+   break;
+   case DRM_FORMAT_YUV410:
+   case DRM_FORMAT_YVU410:
+   case DRM_FORMAT_YUV411:
+   case DRM_FORMAT_YVU411:
+   case DRM_FORMAT_YUV420:
+   case DRM_FORMAT_YVU420:
+   case DRM_FORMAT_YUV422:
+   case DRM_FORMAT_YVU422:
+   case DRM_FORMAT_YUV444:
+   case DRM_FORMAT_YVU444:
+   ofs[0] = sz->hsize * sz->vsize;
+   ofs[1] = ofs[2] = ofs[0] >> 2;
+   if (*base[0] && *base[1] && *base[2]) {
+   if (size[0]+size[1]+size[2] < ofs[0]+ofs[1]+ofs[2])
+   goto err_info;
+   bypass = true;
+   }
+   break;
+   case DRM_FORMAT_XRGB:
+   ofs[0] = sz->hsize * sz->vsize << 2;
+   if (*base[0]) {
+   if (size[0] < ofs[0])
+   goto err_info;
+   }
+   bypass = true;
+   break;
+   default:
+   bypass = true;
+   break;
+   }
+
+   if (!bypass) {
+   *base[1] = *base[0] + ofs[0];
+   if (ofs[1] && ofs[2])
+   *base[2] = *base[1] + ofs[1];
+   }
+
+   DRM_DEBUG_KMS("y[0x%lx],cb[0x%lx],cr[0x%lx]\n", (unsigned long)*base[0],
+   (unsigned long)*base[1], (unsigned long)*base[2]);
+
+   return 0;
+
+err_info:
+   DRM_ERROR("invalid size for fmt[0x%x]\n", fmt);
+
+   for_each_ipp_planar(i) {
+   base[i] = _info->base[i];
+   size[i] = buf_info->size[i];
+
+   DRM_ERROR("base[%d][0x%lx]s[%d][%llu]ofs[%d][%llu]\n",
+   i, (unsigned long)*base[i], i, size[i], i, ofs[i]);
+   }
+
+   return -EINVAL;
+}

 static int gsc_src_set_fmt(struct device *dev, u32 fmt)
 {
@@ -715,6 +807,8 @@ static int gsc_src_set_addr(struct device *dev,
struct exynos_drm_ippdrv *ippdrv = >ippdrv;
struct drm_exynos_ipp_cmd_node *c_node = ippdrv->c_node;
struct drm_exynos_ipp_property *property;
+   struct drm_exynos_ipp_config *config;
+   int ret;

if (!c_node) {
DRM_ERROR("failed to get c_node.\n");
@@ -734,6 +828,13 @@ static int gsc_src_set_addr(struct device *dev,
/* address register set */
switch (buf_type) {
case IPP_BUF_ENQUEUE:
+   config = >config[EXYNOS_DRM_OPS_SRC];
+   ret = gsc_set_planar_addr(buf_info, config->fmt, >sz);
+   if (ret) {
+   dev_err(dev, "failed to set plane src addr.\n");
+   return ret;
+   }
+
gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
GSC_IN_BASE_ADDR_Y(buf_id));
gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
@@ -1170,6 +1271,8 @@ static int gsc_dst_set_addr(struct device *dev,

[PATCH v2 18/22] drm/exynos: fix to calculate offset of each plane for ipp fimc

2015-11-30 Thread Marek Szyprowski
From: Seung-Woo Kim 

NV12 and YUV420 formats are need to calculate offset of each plane
for ipp fimc in a gem buffer. Without proper offset, only Y plane
can be processed, so result shows green frame.
This patch fixes to calculate offset for cbcr planes for NV12 and
YUV420 formats.

Signed-off-by: Seung-Woo Kim 
Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_fimc.c | 106 +++
 drivers/gpu/drm/exynos/exynos_drm_ipp.c  |  15 -
 drivers/gpu/drm/exynos/exynos_drm_ipp.h  |   2 +
 3 files changed, 121 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
index c747824f3c98..72a7ca188be5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -403,6 +403,97 @@ static void fimc_handle_lastend(struct fimc_context *ctx, 
bool enable)
fimc_write(ctx, cfg, EXYNOS_CIOCTRL);
 }

+static int fimc_set_planar_addr(struct drm_exynos_ipp_buf_info *buf_info,
+   u32 fmt, struct drm_exynos_sz *sz)
+{
+   dma_addr_t *base[EXYNOS_DRM_PLANAR_MAX];
+   uint64_t size[EXYNOS_DRM_PLANAR_MAX];
+   uint64_t ofs[EXYNOS_DRM_PLANAR_MAX];
+   bool bypass = false;
+   uint64_t tsize = 0;
+   int i;
+
+   for_each_ipp_planar(i) {
+   base[i] = _info->base[i];
+   size[i] = buf_info->size[i];
+   ofs[i] = 0;
+   tsize += size[i];
+   }
+
+   if (!tsize) {
+   DRM_INFO("%s:failed to get buffer size.\n", __func__);
+   return 0;
+   }
+
+   switch (fmt) {
+   case DRM_FORMAT_NV12:
+   case DRM_FORMAT_NV21:
+   case DRM_FORMAT_NV16:
+   case DRM_FORMAT_NV61:
+   ofs[0] = sz->hsize * sz->vsize;
+   ofs[1] = ofs[0] >> 1;
+   if (*base[0] && *base[1]) {
+   if (size[0] + size[1] < ofs[0] + ofs[1])
+   goto err_info;
+   bypass = true;
+   }
+   break;
+   case DRM_FORMAT_YUV410:
+   case DRM_FORMAT_YVU410:
+   case DRM_FORMAT_YUV411:
+   case DRM_FORMAT_YVU411:
+   case DRM_FORMAT_YUV420:
+   case DRM_FORMAT_YVU420:
+   case DRM_FORMAT_YUV422:
+   case DRM_FORMAT_YVU422:
+   case DRM_FORMAT_YUV444:
+   case DRM_FORMAT_YVU444:
+   ofs[0] = sz->hsize * sz->vsize;
+   ofs[1] = ofs[2] = ofs[0] >> 2;
+   if (*base[0] && *base[1] && *base[2]) {
+   if (size[0]+size[1]+size[2] < ofs[0]+ofs[1]+ofs[2])
+   goto err_info;
+   bypass = true;
+   }
+   break;
+   case DRM_FORMAT_XRGB:
+   case DRM_FORMAT_ARGB:
+   ofs[0] = sz->hsize * sz->vsize << 2;
+   if (*base[0]) {
+   if (size[0] < ofs[0])
+   goto err_info;
+   }
+   bypass = true;
+   break;
+   default:
+   bypass = true;
+   break;
+   }
+
+   if (!bypass) {
+   *base[1] = *base[0] + ofs[0];
+   if (ofs[1] && ofs[2])
+   *base[2] = *base[1] + ofs[1];
+   }
+
+   DRM_DEBUG_KMS("%s:y[0x%x],cb[0x%x],cr[0x%x]\n", __func__,
+   *base[0], *base[1], *base[2]);
+
+   return 0;
+
+err_info:
+   DRM_ERROR("invalid size for fmt[0x%x]\n", fmt);
+
+   for_each_ipp_planar(i) {
+   base[i] = _info->base[i];
+   size[i] = buf_info->size[i];
+
+   DRM_ERROR("buf[%d] - base[0x%x] sz[%llu] ofs[%llu]\n",
+   i, *base[i], size[i], ofs[i]);
+   }
+
+   return -EINVAL;
+}

 static int fimc_src_set_fmt_order(struct fimc_context *ctx, u32 fmt)
 {
@@ -689,6 +780,7 @@ static int fimc_src_set_addr(struct device *dev,
struct drm_exynos_ipp_cmd_node *c_node = ippdrv->c_node;
struct drm_exynos_ipp_property *property;
struct drm_exynos_ipp_config *config;
+   int ret;

if (!c_node) {
DRM_ERROR("failed to get c_node.\n");
@@ -709,6 +801,12 @@ static int fimc_src_set_addr(struct device *dev,
switch (buf_type) {
case IPP_BUF_ENQUEUE:
config = >config[EXYNOS_DRM_OPS_SRC];
+   ret = fimc_set_planar_addr(buf_info, config->fmt, >sz);
+   if (ret) {
+   dev_err(dev, "failed to set plane src addr.\n");
+   return ret;
+   }
+
fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_Y],
EXYNOS_CIIYSA0);

@@ -1148,6 +1246,7 @@ static int fimc_dst_set_addr(struct device *dev,
struct drm_exynos_ipp_cmd_node *c_node = ippdrv->c_node;
struct drm_exynos_ipp_property *property;
struct 

[PATCH v2 17/22] drm/exynos: gem: set default alignment for dumb GEM buffers

2015-11-30 Thread Marek Szyprowski
This patch forces all GEM buffers to have pitch aligned at least to 8
pixels. This is a common requirement for various Exynos IPP blocks,
which otherwise won't be able to operate on buffers of random size.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.h | 2 ++
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index bb2e449a20c3..670f6d06a2a9 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -24,6 +24,8 @@

 #define DEFAULT_WIN0

+#define EXYNOS_DRM_PITCH_ALIGN 8
+
 #define to_exynos_crtc(x)  container_of(x, struct exynos_drm_crtc, base)
 #define to_exynos_plane(x) container_of(x, struct exynos_drm_plane, base)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c 
b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 252eb301470c..b5db6e6cc043 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -417,7 +417,7 @@ int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
 *  with DRM_IOCTL_MODE_CREATE_DUMB command.
 */

-   args->pitch = args->width * ((args->bpp + 7) / 8);
+   args->pitch = roundup(args->width, EXYNOS_DRM_PITCH_ALIGN) * 
((args->bpp + 7) / 8);
args->size = args->pitch * args->height;

if (is_drm_iommu_supported(dev))
-- 
1.9.2



[PATCH v2 16/22] drm/exynos: add fb pointer to exynos_drm_plane_state

2015-11-30 Thread Marek Szyprowski
Add framebuffer pointer to exynos_drm_plane_state and tell drivers to use
it. This lets common plane code to set temporary framebuffer in the
future and drivers will use it without additional changes.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 2 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c| 2 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.h   | 8 ++--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  | 2 +-
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 2 ++
 drivers/gpu/drm/exynos/exynos_mixer.c | 4 ++--
 6 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 189ee5ca0a7a..1f705bede7dd 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -269,7 +269,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
struct decon_context *ctx = crtc->ctx;
-   struct drm_framebuffer *fb = state->base.fb;
+   struct drm_framebuffer *fb = state->fb;
unsigned int win = plane->zpos;
unsigned int bpp = fb->bits_per_pixel >> 3;
unsigned int pitch = fb->pitches[0];
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index c47f9af8170b..17aa11702a40 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -402,7 +402,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
struct decon_context *ctx = crtc->ctx;
-   struct drm_framebuffer *fb = state->base.fb;
+   struct drm_framebuffer *fb = state->fb;
int padding;
unsigned long val, alpha;
unsigned int last_x;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 82bbd7f4b316..bb2e449a20c3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -53,9 +53,12 @@ struct exynos_drm_rect {
  *   (clipped to visible part).
  * @h_ratio: horizontal scaling ratio, 16.16 fixed point
  * @v_ratio: vertical scaling ratio, 16.16 fixed point
+ * @fb: framebuffer with image data to be displayed (drivers should use this
+ *  instead of .base->fb)
  *
- * this structure consists plane state data that will be applied to hardware
- * specific overlay info.
+ * This structure consists plane state data that will be applied to hardware
+ * specific overlay info. Some data is duplicated (comparing with base state)
+ * to let common code to modify it for internal use.
  */

 struct exynos_drm_plane_state {
@@ -64,6 +67,7 @@ struct exynos_drm_plane_state {
struct exynos_drm_rect src;
unsigned int h_ratio;
unsigned int v_ratio;
+   struct drm_framebuffer *fb;
 };

 static inline struct exynos_drm_plane_state *
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 2e2247126581..0046495173f3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -650,7 +650,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
struct fimd_context *ctx = crtc->ctx;
-   struct drm_framebuffer *fb = state->base.fb;
+   struct drm_framebuffer *fb = state->fb;
dma_addr_t dma_addr;
unsigned long val, size, offset;
unsigned int last_x, last_y, buf_offsize, line_size;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c 
b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 427aeec78a28..8a1242b5a938 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -117,6 +117,8 @@ static void exynos_plane_mode_set(struct 
exynos_drm_plane_state *exynos_state)
exynos_state->crtc.w = actual_w;
exynos_state->crtc.h = actual_h;

+   exynos_state->fb = state->fb;
+
DRM_DEBUG_KMS("plane : offset_x/y(%d,%d), width/height(%d,%d)",
exynos_state->crtc.x, exynos_state->crtc.y,
exynos_state->crtc.w, exynos_state->crtc.h);
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index dfb35e2da4db..787aa03f4359 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -425,7 +425,7 @@ static void vp_video_buffer(struct mixer_context *ctx,
to_exynos_plane_state(plane->base.state);
struct drm_display_mode *mode = >base.crtc->state->adjusted_mode;
struct 

[PATCH v2 15/22] drm/exynos: gem: remove old unused prototypes

2015-11-30 Thread Marek Szyprowski
This patch removes old, unused function prototypes from exynos_drm_gem.h.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_gem.h | 28 
 1 file changed, 28 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h 
b/drivers/gpu/drm/exynos/exynos_drm_gem.h
index 37ab8b282db6..9ca5047959ec 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h
@@ -55,8 +55,6 @@ struct exynos_drm_gem {
struct sg_table *sgt;
 };

-struct page **exynos_gem_get_pages(struct drm_gem_object *obj, gfp_t gfpmask);
-
 /* destroy a buffer with gem object */
 void exynos_drm_gem_destroy(struct exynos_drm_gem *exynos_gem);

@@ -91,10 +89,6 @@ void exynos_drm_gem_put_dma_addr(struct drm_device *dev,
unsigned int gem_handle,
struct drm_file *filp);

-/* map user space allocated by malloc to pages. */
-int exynos_drm_gem_userptr_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-
 /* get buffer information to memory region allocated by gem. */
 int exynos_drm_gem_get_ioctl(struct drm_device *dev, void *data,
  struct drm_file *file_priv);
@@ -123,28 +117,6 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, 
struct vm_fault *vmf);
 /* set vm_flags and we can change the vm attribute to other one at here. */
 int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);

-static inline int vma_is_io(struct vm_area_struct *vma)
-{
-   return !!(vma->vm_flags & (VM_IO | VM_PFNMAP));
-}
-
-/* get a copy of a virtual memory region. */
-struct vm_area_struct *exynos_gem_get_vma(struct vm_area_struct *vma);
-
-/* release a userspace virtual memory area. */
-void exynos_gem_put_vma(struct vm_area_struct *vma);
-
-/* get pages from user space. */
-int exynos_gem_get_pages_from_userptr(unsigned long start,
-   unsigned int npages,
-   struct page **pages,
-   struct vm_area_struct *vma);
-
-/* drop the reference to pages. */
-void exynos_gem_put_pages_to_userptr(struct page **pages,
-   unsigned int npages,
-   struct vm_area_struct *vma);
-
 /* map sgt with dma region. */
 int exynos_gem_map_sgt_with_dma(struct drm_device *drm_dev,
struct sg_table *sgt,
-- 
1.9.2



[PATCH v2 14/22] drm/exynos: fimd: fix dma burst size setting for small plane size

2015-11-30 Thread Marek Szyprowski
This patch fixes trashed display of buffers cropped to very small width.
Even if DMA is unstable and causes tearing when changing the burst size,
it is still better than displaying a garbage.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c 
b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 70cd2681e343..2e2247126581 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -487,7 +487,7 @@ static void fimd_commit(struct exynos_drm_crtc *crtc)


 static void fimd_win_set_pixfmt(struct fimd_context *ctx, unsigned int win,
-   struct drm_framebuffer *fb)
+   uint32_t pixel_format, int width)
 {
unsigned long val;

@@ -498,11 +498,11 @@ static void fimd_win_set_pixfmt(struct fimd_context *ctx, 
unsigned int win,
 * So the request format is ARGB then change it to XRGB.
 */
if (ctx->driver_data->has_limited_fmt && !win) {
-   if (fb->pixel_format == DRM_FORMAT_ARGB)
-   fb->pixel_format = DRM_FORMAT_XRGB;
+   if (pixel_format == DRM_FORMAT_ARGB)
+   pixel_format = DRM_FORMAT_XRGB;
}

-   switch (fb->pixel_format) {
+   switch (pixel_format) {
case DRM_FORMAT_C8:
val |= WINCON0_BPPMODE_8BPP_PALETTE;
val |= WINCONx_BURSTLEN_8WORD;
@@ -538,17 +538,15 @@ static void fimd_win_set_pixfmt(struct fimd_context *ctx, 
unsigned int win,
break;
}

-   DRM_DEBUG_KMS("bpp = %d\n", fb->bits_per_pixel);
-
/*
-* In case of exynos, setting dma-burst to 16Word causes permanent
-* tearing for very small buffers, e.g. cursor buffer. Burst Mode
-* switching which is based on plane size is not recommended as
-* plane size varies alot towards the end of the screen and rapid
-* movement causes unstable DMA which results into iommu crash/tear.
+* Setting dma-burst to 16Word causes permanent tearing for very small
+* buffers, e.g. cursor buffer. Burst Mode switching which based on
+* plane size is not recommended as plane size varies alot towards the
+* end of the screen and rapid movement causes unstable DMA, but it is
+* still better to change dma-burst than displaying garbage.
 */

-   if (fb->width < MIN_FB_WIDTH_FOR_16WORD_BURST) {
+   if (width < MIN_FB_WIDTH_FOR_16WORD_BURST) {
val &= ~WINCONx_BURSTLEN_MASK;
val |= WINCONx_BURSTLEN_4WORD;
}
@@ -723,7 +721,7 @@ static void fimd_update_plane(struct exynos_drm_crtc *crtc,
DRM_DEBUG_KMS("osd size = 0x%x\n", (unsigned int)val);
}

-   fimd_win_set_pixfmt(ctx, win, fb);
+   fimd_win_set_pixfmt(ctx, win, fb->pixel_format, state->src.w);

/* hardware window 0 doesn't support color key. */
if (win != 0)
-- 
1.9.2



[PATCH v2 13/22] drm/exynos: fix clipping when scaling is enabled

2015-11-30 Thread Marek Szyprowski
This patch fixes calculation of src x/y offset for negative crtc x/y
values when scaling is enabled. This fixes possible IOMMU fault when
scaling is enabled.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c 
b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 9eaa8627175f..427aeec78a28 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -85,25 +85,26 @@ static void exynos_plane_mode_set(struct 
exynos_drm_plane_state *exynos_state)
src_w = state->src_w >> 16;
src_h = state->src_h >> 16;

+   /* set ratio */
+   exynos_state->h_ratio = (src_w << 16) / crtc_w;
+   exynos_state->v_ratio = (src_h << 16) / crtc_h;
+
+   /* clip to visible area */
actual_w = exynos_plane_get_size(crtc_x, crtc_w, mode->hdisplay);
actual_h = exynos_plane_get_size(crtc_y, crtc_h, mode->vdisplay);

if (crtc_x < 0) {
if (actual_w)
-   src_x -= crtc_x;
+   src_x += ((-crtc_x) * exynos_state->h_ratio) >> 16;
crtc_x = 0;
}

if (crtc_y < 0) {
if (actual_h)
-   src_y -= crtc_y;
+   src_y += ((-crtc_y) * exynos_state->v_ratio) >> 16;
crtc_y = 0;
}

-   /* set ratio */
-   exynos_state->h_ratio = (src_w << 16) / crtc_w;
-   exynos_state->v_ratio = (src_h << 16) / crtc_h;
-
/* set drm framebuffer data. */
exynos_state->src.x = src_x;
exynos_state->src.y = src_y;
-- 
1.9.2



[PATCH v2 12/22] drm/exynos: mixer: use ratio precalculated in exynos_state

2015-11-30 Thread Marek Szyprowski
Common plane code already calculates and checks for supported scalling
modes, so additional code in mixer driver can be now removed.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 33 +++--
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 4190285798ef..dfb35e2da4db 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -528,33 +528,6 @@ static void mixer_layer_update(struct mixer_context *ctx)
mixer_reg_writemask(res, MXR_CFG, ~0, MXR_CFG_LAYER_UPDATE);
 }

-static int mixer_setup_scale(const struct exynos_drm_plane *plane,
-   unsigned int *x_ratio, unsigned int *y_ratio)
-{
-   struct exynos_drm_plane_state *state =
-   to_exynos_plane_state(plane->base.state);
-
-   if (state->crtc.w != state->src.w) {
-   if (state->crtc.w == 2 * state->src.w)
-   *x_ratio = 1;
-   else
-   goto fail;
-   }
-
-   if (state->crtc.h != state->src.h) {
-   if (state->crtc.h == 2 * state->src.h)
-   *y_ratio = 1;
-   else
-   goto fail;
-   }
-
-   return 0;
-
-fail:
-   DRM_DEBUG_KMS("only 2x width/height scaling of plane supported\n");
-   return -ENOTSUPP;
-}
-
 static void mixer_graph_buffer(struct mixer_context *ctx,
   struct exynos_drm_plane *plane)
 {
@@ -594,9 +567,9 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
return;
}

-   /* check if mixer supports requested scaling setup */
-   if (mixer_setup_scale(plane, _ratio, _ratio))
-   return;
+   /* ratio is already checked by common plane code */
+   x_ratio = state->h_ratio == (1 << 15);
+   y_ratio = state->v_ratio == (1 << 15);

dst_x_offset = state->crtc.x;
dst_y_offset = state->crtc.y;
-- 
1.9.2



[PATCH v2 11/22] drm/exynos: add generic check for plane state

2015-11-30 Thread Marek Szyprowski
This patch adds generic check for plane state - display area dimensions,
so drivers can always assume that they get valid plane state to set.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  3 +++
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 31 +++
 drivers/gpu/drm/exynos/exynos_mixer.c |  3 +++
 3 files changed, 37 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h 
b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 6f8a296a3115..82bbd7f4b316 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -89,6 +89,9 @@ struct exynos_drm_plane {
struct drm_framebuffer *pending_fb;
 };

+#define EXYNOS_DRM_PLANE_CAP_DOUBLE(1 << 0)
+#define EXYNOS_DRM_PLANE_CAP_SCALE (1 << 1)
+
 /*
  * Exynos DRM plane configuration structure.
  *
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c 
b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index b620d7a76799..9eaa8627175f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -173,6 +173,36 @@ static struct drm_plane_funcs exynos_plane_funcs = {
.atomic_destroy_state = exynos_drm_plane_destroy_state,
 };

+static int
+exynos_drm_plane_check_size(const struct exynos_drm_plane_config *config,
+   struct exynos_drm_plane_state *state)
+{
+   bool width_ok = false, height_ok = false;
+
+   if (config->capabilities & EXYNOS_DRM_PLANE_CAP_SCALE)
+   return 0;
+
+   if (state->src.w == state->crtc.w)
+   width_ok = true;
+
+   if (state->src.h == state->crtc.h)
+   height_ok = true;
+
+   if ((config->capabilities & EXYNOS_DRM_PLANE_CAP_DOUBLE) &&
+   state->h_ratio == (1 << 15))
+   width_ok = true;
+
+   if ((config->capabilities & EXYNOS_DRM_PLANE_CAP_DOUBLE) &&
+   state->v_ratio == (1 << 15))
+   height_ok = true;
+
+   if (width_ok & height_ok)
+   return 0;
+
+   DRM_DEBUG_KMS("scaling mode is not supported");
+   return -ENOTSUPP;
+}
+
 static int exynos_plane_atomic_check(struct drm_plane *plane,
 struct drm_plane_state *state)
 {
@@ -187,6 +217,7 @@ static int exynos_plane_atomic_check(struct drm_plane 
*plane,
/* translate state into exynos_state */
exynos_plane_mode_set(exynos_state);

+   ret = exynos_drm_plane_check_size(exynos_plane->config, exynos_state);
return ret;
 }

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index a229f86d221a..4190285798ef 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -117,16 +117,19 @@ static const struct exynos_drm_plane_config 
plane_configs[MIXER_WIN_NR] = {
.type = DRM_PLANE_TYPE_PRIMARY,
.pixel_formats = mixer_formats,
.num_pixel_formats = ARRAY_SIZE(mixer_formats),
+   .capabilities = EXYNOS_DRM_PLANE_CAP_DOUBLE,
}, {
.zpos = 1,
.type = DRM_PLANE_TYPE_CURSOR,
.pixel_formats = mixer_formats,
.num_pixel_formats = ARRAY_SIZE(mixer_formats),
+   .capabilities = EXYNOS_DRM_PLANE_CAP_DOUBLE,
}, {
.zpos = 2,
.type = DRM_PLANE_TYPE_OVERLAY,
.pixel_formats = vp_formats,
.num_pixel_formats = ARRAY_SIZE(vp_formats),
+   .capabilities = EXYNOS_DRM_PLANE_CAP_SCALE,
},
 };

-- 
1.9.2



[PATCH v2 10/22] drm/exynos: introduce exynos_drm_plane_config structure

2015-11-30 Thread Marek Szyprowski
This patch adds common structure for keeping plane configuration and
capabilities data. This patch is inspired by similar code developed by
Tobias Jakobi.

Signed-off-by: Marek Szyprowski 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 18 ---
 drivers/gpu/drm/exynos/exynos7_drm_decon.c| 23 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.h   | 19 
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  | 25 ++-
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 34 +
 drivers/gpu/drm/exynos/exynos_drm_plane.h |  7 ++---
 drivers/gpu/drm/exynos/exynos_drm_vidi.c  | 25 ++-
 drivers/gpu/drm/exynos/exynos_mixer.c | 44 +++
 8 files changed, 121 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 12f558fc3ef6..189ee5ca0a7a 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -26,7 +26,6 @@
 #include "exynos_drm_iommu.h"

 #define WINDOWS_NR 3
-#define CURSOR_WIN 2
 #define MIN_FB_WIDTH_FOR_16WORD_BURST  128

 static const char * const decon_clks_name[] = {
@@ -57,6 +56,7 @@ struct decon_context {
struct drm_device   *drm_dev;
struct exynos_drm_crtc  *crtc;
struct exynos_drm_plane planes[WINDOWS_NR];
+   struct exynos_drm_plane_config  configs[WINDOWS_NR];
void __iomem*addr;
struct clk  *clks[ARRAY_SIZE(decon_clks_name)];
int pipe;
@@ -72,6 +72,12 @@ static const uint32_t decon_formats[] = {
DRM_FORMAT_ARGB,
 };

+static const enum drm_plane_type decon_win_types[WINDOWS_NR] = {
+   DRM_PLANE_TYPE_PRIMARY,
+   DRM_PLANE_TYPE_OVERLAY,
+   DRM_PLANE_TYPE_CURSOR,
+};
+
 static inline void decon_set_bits(struct decon_context *ctx, u32 reg, u32 mask,
  u32 val)
 {
@@ -484,7 +490,6 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
struct exynos_drm_private *priv = drm_dev->dev_private;
struct exynos_drm_plane *exynos_plane;
enum exynos_drm_output_type out_type;
-   enum drm_plane_type type;
unsigned int win;
int ret;

@@ -494,10 +499,13 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
for (win = ctx->first_win; win < WINDOWS_NR; win++) {
int tmp = (win == ctx->first_win) ? 0 : win;

-   type = exynos_plane_get_type(tmp, CURSOR_WIN);
+   ctx->configs[win].pixel_formats = decon_formats;
+   ctx->configs[win].num_pixel_formats = ARRAY_SIZE(decon_formats);
+   ctx->configs[win].zpos = win;
+   ctx->configs[win].type = decon_win_types[tmp];
+
ret = exynos_plane_init(drm_dev, >planes[win],
-   1 << ctx->pipe, type, decon_formats,
-   ARRAY_SIZE(decon_formats), win);
+   1 << ctx->pipe, >configs[win]);
if (ret)
return ret;
}
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 1c62de1a0839..c47f9af8170b 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -41,13 +41,13 @@
 #define MIN_FB_WIDTH_FOR_16WORD_BURST 128

 #define WINDOWS_NR 2
-#define CURSOR_WIN 1

 struct decon_context {
struct device   *dev;
struct drm_device   *drm_dev;
struct exynos_drm_crtc  *crtc;
struct exynos_drm_plane planes[WINDOWS_NR];
+   struct exynos_drm_plane_config  configs[WINDOWS_NR];
struct clk  *pclk;
struct clk  *aclk;
struct clk  *eclk;
@@ -82,6 +82,11 @@ static const uint32_t decon_formats[] = {
DRM_FORMAT_BGRA,
 };

+static const enum drm_plane_type decon_win_types[WINDOWS_NR] = {
+   DRM_PLANE_TYPE_PRIMARY,
+   DRM_PLANE_TYPE_CURSOR,
+};
+
 static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc)
 {
struct decon_context *ctx = crtc->ctx;
@@ -637,8 +642,7 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
struct decon_context *ctx = dev_get_drvdata(dev);
struct drm_device *drm_dev = data;
struct exynos_drm_plane *exynos_plane;
-   enum drm_plane_type type;
-   unsigned int zpos;
+   unsigned int i;
int ret;

ret = decon_ctx_initialize(ctx, drm_dev);
@@ -647,11 +651,14 @@ static int decon_bind(struct device *dev, struct device 
*master, void *data)
return ret;
}

-   for (zpos = 0; zpos < WINDOWS_NR; zpos++) {
-

[PATCH v2 09/22] drm/exynos: mixer: enable video overlay plane only when VP is available

2015-11-30 Thread Marek Szyprowski
Video overlay plane should be registered only when suitable hardware
sub-block (Video Processor) is available.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 84ee3396c429..8d2ce13eb725 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -1167,6 +1167,9 @@ static int mixer_bind(struct device *dev, struct device 
*manager, void *data)
const uint32_t *formats;
unsigned int fcount;

+   if (zpos == VP_DEFAULT_WIN && !ctx->vp_enabled)
+   continue;
+
if (zpos < VP_DEFAULT_WIN) {
formats = mixer_formats;
fcount = ARRAY_SIZE(mixer_formats);
-- 
1.9.2



[PATCH v2 08/22] drm/exynos: mixer: use crtc->state->adjusted_mode instead of crtc->mode

2015-11-30 Thread Marek Szyprowski
This patch replaces usage of crtc->mode with crtc->state->adjusted_mode
like it is already done in common plane code.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_mixer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c 
b/drivers/gpu/drm/exynos/exynos_mixer.c
index 154537a23c90..84ee3396c429 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -402,9 +402,9 @@ static void vp_video_buffer(struct mixer_context *ctx,
 {
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
+   struct drm_display_mode *mode = >base.crtc->state->adjusted_mode;
struct mixer_resources *res = >mixer_res;
struct drm_framebuffer *fb = state->base.fb;
-   struct drm_display_mode *mode = >base.crtc->mode;
unsigned long flags;
dma_addr_t luma_addr[2], chroma_addr[2];
bool tiled_mode = false;
@@ -539,9 +539,9 @@ static void mixer_graph_buffer(struct mixer_context *ctx,
 {
struct exynos_drm_plane_state *state =
to_exynos_plane_state(plane->base.state);
+   struct drm_display_mode *mode = >base.crtc->state->adjusted_mode;
struct mixer_resources *res = >mixer_res;
struct drm_framebuffer *fb = state->base.fb;
-   struct drm_display_mode *mode = >base.crtc->mode;
unsigned long flags;
unsigned int win = plane->zpos;
unsigned int x_ratio = 0, y_ratio = 0;
-- 
1.9.2



[PATCH v2 07/22] drm/exynos: introduce exynos_drm_plane_state structure

2015-11-30 Thread Marek Szyprowski
This patch introduces exynos_drm_plane_state structure, which subclasses
drm_plane_state and holds precalculated data suitable for configuring
Exynos hardware.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  21 ++---
 drivers/gpu/drm/exynos/exynos7_drm_decon.c|  21 ++---
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  56 +++-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  |  33 +++
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 125 +++---
 drivers/gpu/drm/exynos/exynos_mixer.c |  61 +++--
 6 files changed, 197 insertions(+), 120 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 320efc3d0659..12f558fc3ef6 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -260,9 +260,10 @@ static void decon_atomic_begin(struct exynos_drm_crtc 
*crtc,
 static void decon_update_plane(struct exynos_drm_crtc *crtc,
   struct exynos_drm_plane *plane)
 {
+   struct exynos_drm_plane_state *state =
+   to_exynos_plane_state(plane->base.state);
struct decon_context *ctx = crtc->ctx;
-   struct drm_plane_state *state = plane->base.state;
-   struct drm_framebuffer *fb = state->fb;
+   struct drm_framebuffer *fb = state->base.fb;
unsigned int win = plane->zpos;
unsigned int bpp = fb->bits_per_pixel >> 3;
unsigned int pitch = fb->pitches[0];
@@ -272,11 +273,11 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
if (test_bit(BIT_SUSPENDED, >flags))
return;

-   val = COORDINATE_X(plane->crtc_x) | COORDINATE_Y(plane->crtc_y);
+   val = COORDINATE_X(state->crtc.x) | COORDINATE_Y(state->crtc.y);
writel(val, ctx->addr + DECON_VIDOSDxA(win));

-   val = COORDINATE_X(plane->crtc_x + plane->crtc_w - 1) |
-   COORDINATE_Y(plane->crtc_y + plane->crtc_h - 1);
+   val = COORDINATE_X(state->crtc.x + state->crtc.w - 1) |
+   COORDINATE_Y(state->crtc.y + state->crtc.h - 1);
writel(val, ctx->addr + DECON_VIDOSDxB(win));

val = VIDOSD_Wx_ALPHA_R_F(0x0) | VIDOSD_Wx_ALPHA_G_F(0x0) |
@@ -289,15 +290,15 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,

writel(dma_addr, ctx->addr + DECON_VIDW0xADD0B0(win));

-   val = dma_addr + pitch * plane->crtc_h;
+   val = dma_addr + pitch * state->src.h;
writel(val, ctx->addr + DECON_VIDW0xADD1B0(win));

if (ctx->out_type != IFTYPE_HDMI)
-   val = BIT_VAL(pitch - plane->crtc_w * bpp, 27, 14)
-   | BIT_VAL(plane->crtc_w * bpp, 13, 0);
+   val = BIT_VAL(pitch - state->crtc.w * bpp, 27, 14)
+   | BIT_VAL(state->crtc.w * bpp, 13, 0);
else
-   val = BIT_VAL(pitch - plane->crtc_w * bpp, 29, 15)
-   | BIT_VAL(plane->crtc_w * bpp, 14, 0);
+   val = BIT_VAL(pitch - state->crtc.w * bpp, 29, 15)
+   | BIT_VAL(state->crtc.w * bpp, 14, 0);
writel(val, ctx->addr + DECON_VIDW0xADD2(win));

decon_win_set_pixfmt(ctx, win, fb);
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 1629732574e0..1c62de1a0839 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -394,9 +394,10 @@ static void decon_atomic_begin(struct exynos_drm_crtc 
*crtc,
 static void decon_update_plane(struct exynos_drm_crtc *crtc,
   struct exynos_drm_plane *plane)
 {
+   struct exynos_drm_plane_state *state =
+   to_exynos_plane_state(plane->base.state);
struct decon_context *ctx = crtc->ctx;
-   struct drm_plane_state *state = plane->base.state;
-   struct drm_framebuffer *fb = state->fb;
+   struct drm_framebuffer *fb = state->base.fb;
int padding;
unsigned long val, alpha;
unsigned int last_x;
@@ -429,22 +430,22 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
writel(fb->height, ctx->regs + VIDW_WHOLE_Y(win));

/* offset from the start of the buffer to read */
-   writel(plane->src_x, ctx->regs + VIDW_OFFSET_X(win));
-   writel(plane->src_y, ctx->regs + VIDW_OFFSET_Y(win));
+   writel(state->src.x, ctx->regs + VIDW_OFFSET_X(win));
+   writel(state->src.y, ctx->regs + VIDW_OFFSET_Y(win));

DRM_DEBUG_KMS("start addr = 0x%lx\n",
(unsigned long)val);
DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
-   plane->crtc_w, plane->crtc_h);
+   state->crtc.w, state->crtc.h);

-   val = VIDOSDxA_TOPLEFT_X(plane->crtc_x) |
-   VIDOSDxA_TOPLEFT_Y(plane->crtc_y);
+

[PATCH v2 06/22] drm/exynos: move dma_addr attribute from exynos plane to exynos fb

2015-11-30 Thread Marek Szyprowski
DMA address is a framebuffer attribute and the right place for it is
exynos_drm_framebuffer not exynos_drm_plane. This patch also introduces
helper function for getting dma address of the given framebuffer.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 13 -
 drivers/gpu/drm/exynos/exynos7_drm_decon.c| 16 +---
 drivers/gpu/drm/exynos/exynos_drm_drv.h   |  3 ---
 drivers/gpu/drm/exynos/exynos_drm_fb.c| 16 ++--
 drivers/gpu/drm/exynos/exynos_drm_fb.h|  3 +--
 drivers/gpu/drm/exynos/exynos_drm_fimd.c  | 10 ++
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 18 --
 drivers/gpu/drm/exynos/exynos_drm_vidi.c  |  5 -
 drivers/gpu/drm/exynos/exynos_mixer.c |  7 ---
 9 files changed, 38 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index edfd6e390ef7..320efc3d0659 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -21,6 +21,7 @@

 #include "exynos_drm_drv.h"
 #include "exynos_drm_crtc.h"
+#include "exynos_drm_fb.h"
 #include "exynos_drm_plane.h"
 #include "exynos_drm_iommu.h"

@@ -261,9 +262,11 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
 {
struct decon_context *ctx = crtc->ctx;
struct drm_plane_state *state = plane->base.state;
+   struct drm_framebuffer *fb = state->fb;
unsigned int win = plane->zpos;
-   unsigned int bpp = state->fb->bits_per_pixel >> 3;
-   unsigned int pitch = state->fb->pitches[0];
+   unsigned int bpp = fb->bits_per_pixel >> 3;
+   unsigned int pitch = fb->pitches[0];
+   dma_addr_t dma_addr = exynos_drm_fb_dma_addr(fb, 0);
u32 val;

if (test_bit(BIT_SUSPENDED, >flags))
@@ -284,9 +287,9 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
VIDOSD_Wx_ALPHA_B_F(0x0);
writel(val, ctx->addr + DECON_VIDOSDxD(win));

-   writel(plane->dma_addr[0], ctx->addr + DECON_VIDW0xADD0B0(win));
+   writel(dma_addr, ctx->addr + DECON_VIDW0xADD0B0(win));

-   val = plane->dma_addr[0] + pitch * plane->crtc_h;
+   val = dma_addr + pitch * plane->crtc_h;
writel(val, ctx->addr + DECON_VIDW0xADD1B0(win));

if (ctx->out_type != IFTYPE_HDMI)
@@ -297,7 +300,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
| BIT_VAL(plane->crtc_w * bpp, 14, 0);
writel(val, ctx->addr + DECON_VIDW0xADD2(win));

-   decon_win_set_pixfmt(ctx, win, state->fb);
+   decon_win_set_pixfmt(ctx, win, fb);

/* window enable */
decon_set_bits(ctx, DECON_WINCONx(win), WINCONx_ENWIN_F, ~0);
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 4db04f244c17..1629732574e0 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -30,6 +30,7 @@
 #include "exynos_drm_crtc.h"
 #include "exynos_drm_plane.h"
 #include "exynos_drm_drv.h"
+#include "exynos_drm_fb.h"
 #include "exynos_drm_fbdev.h"
 #include "exynos_drm_iommu.h"

@@ -395,13 +396,14 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
 {
struct decon_context *ctx = crtc->ctx;
struct drm_plane_state *state = plane->base.state;
+   struct drm_framebuffer *fb = state->fb;
int padding;
unsigned long val, alpha;
unsigned int last_x;
unsigned int last_y;
unsigned int win = plane->zpos;
-   unsigned int bpp = state->fb->bits_per_pixel >> 3;
-   unsigned int pitch = state->fb->pitches[0];
+   unsigned int bpp = fb->bits_per_pixel >> 3;
+   unsigned int pitch = fb->pitches[0];

if (ctx->suspended)
return;
@@ -417,14 +419,14 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
 */

/* buffer start address */
-   val = (unsigned long)plane->dma_addr[0];
+   val = (unsigned long)exynos_drm_fb_dma_addr(fb, 0);
writel(val, ctx->regs + VIDW_BUF_START(win));

-   padding = (pitch / bpp) - state->fb->width;
+   padding = (pitch / bpp) - fb->width;

/* buffer size */
-   writel(state->fb->width + padding, ctx->regs + VIDW_WHOLE_X(win));
-   writel(state->fb->height, ctx->regs + VIDW_WHOLE_Y(win));
+   writel(fb->width + padding, ctx->regs + VIDW_WHOLE_X(win));
+   writel(fb->height, ctx->regs + VIDW_WHOLE_Y(win));

/* offset from the start of the buffer to read */
writel(plane->src_x, ctx->regs + VIDW_OFFSET_X(win));
@@ -466,7 +468,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,

writel(alpha, ctx->regs + VIDOSD_D(win));

-   decon_win_set_pixfmt(ctx, win, state->fb);
+   decon_win_set_pixfmt(ctx, win, fb);

/* hardware 

[PATCH v2 05/22] drm/exynos: exynos7-decon: remove excessive check

2015-11-30 Thread Marek Szyprowski
Display area is already checked by exynos plane core, so there is no
need for such check in driver code.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos7_drm_decon.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c 
b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 38d7762ebdcb..4db04f244c17 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -394,7 +394,6 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
   struct exynos_drm_plane *plane)
 {
struct decon_context *ctx = crtc->ctx;
-   struct drm_display_mode *mode = >base.state->adjusted_mode;
struct drm_plane_state *state = plane->base.state;
int padding;
unsigned long val, alpha;
@@ -436,15 +435,6 @@ static void decon_update_plane(struct exynos_drm_crtc 
*crtc,
DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
plane->crtc_w, plane->crtc_h);

-   /*
-* OSD position.
-* In case the window layout goes of LCD layout, DECON fails.
-*/
-   if ((plane->crtc_x + plane->crtc_w) > mode->hdisplay)
-   plane->crtc_x = mode->hdisplay - plane->crtc_w;
-   if ((plane->crtc_y + plane->crtc_h) > mode->vdisplay)
-   plane->crtc_y = mode->vdisplay - plane->crtc_h;
-
val = VIDOSDxA_TOPLEFT_X(plane->crtc_x) |
VIDOSDxA_TOPLEFT_Y(plane->crtc_y);
writel(val, ctx->regs + VIDOSD_A(win));
-- 
1.9.2



[PATCH v2 04/22] drm/exynos: rotator: convert to common clock framework

2015-11-30 Thread Marek Szyprowski
This driver was not used after introduction of common clock framework.
This patch adds missing prepare/unprepare calls and allows to use it
again with current kernel code.

Signed-off-by: Marek Szyprowski 
Reviewed-by: Gustavo Padovan 
---
 drivers/gpu/drm/exynos/exynos_drm_rotator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c 
b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
index 2f5c118f4c8e..bea0f7826d30 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -790,10 +790,10 @@ static int rotator_remove(struct platform_device *pdev)
 static int rotator_clk_crtl(struct rot_context *rot, bool enable)
 {
if (enable) {
-   clk_enable(rot->clock);
+   clk_prepare_enable(rot->clock);
rot->suspended = false;
} else {
-   clk_disable(rot->clock);
+   clk_disable_unprepare(rot->clock);
rot->suspended = true;
}

-- 
1.9.2



  1   2   >