Commit graph

172 commits

Author SHA1 Message Date
Jyri Sarha cba8844a68 drm/tilcdc: Enable sync lost error and recovery handling for rev 1 LCDC
Revision 1 LCDC support also sync lost errors and can benefit from
sync lost recovery routine.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2016-11-30 14:18:26 +02:00
Jyri Sarha ec9eab097a drm/tilcdc: Add drm bridge support for attaching drm bridge drivers
Adds drm bride support for attaching drm bridge drivers to tilcdc. The
decision whether a video port leads to an external encoder or bridge
is made simply based on remote device's compatible string. The code
has been tested with BeagleBone-Black with and without BeagleBone
DVI-D Cape Rev A3 using ti-tfp410 driver.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2016-11-30 14:17:52 +02:00
Jyri Sarha 13b3d72705 drm/tilcdc: Recover from sync lost error flood by resetting the LCDC
Recover from sync lost error flood by resetting the LCDC instead of
turning off the SYNC_LOST error IRQ. When LCDC starves on limited
memory bandwidth it may sometimes result an error situation when the
picture may have shifted couple of pixels to right and SYNC_LOST
interrupt is generated on every frame. LCDC main reset recovers from
this situation and causes a brief blanking on the screen.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Tested-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2016-11-30 14:14:40 +02:00
Jyri Sarha 2d53a18098 drm/tilcdc: Fix race from forced shutdown of crtc in unload
Fix race from forced shutdown of crtc in unload by adding internal
locking and a boolean telling if device is going to be shutdown.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-11-29 21:03:20 +02:00
Jyri Sarha 9e79e062dc drm/tilcdc: Use unload to handle initialization failures
Use unload to handle initialization failures instead of complex goto
label mess. To do this the initialization sequence needed slight
reordering and some unload functions needed to become conditional.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-11-29 21:03:19 +02:00
Jyri Sarha 923310ba73 drm/tilcdc: Stop using struct drm_driver load() callback
Stop using struct drm_driver load() and unload() callbacks. The
callbacks should not be used anymore. Instead of using load the
drm_device is allocated with drm_dev_alloc() and registered with
drm_dev_register() only after the driver is completely initialized.
The deinitialization is done directly either in component unbind
callback or in platform driver demove callback.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2016-11-29 21:03:19 +02:00
Jyri Sarha 15d704e53c drm/tilcdc: Remove obsolete drm_connector_register() calls
Remove obsolete drm_connector_register() calls from tilcdc_panel.c and
tilcdc_tfp410.c. All connectors are registered when drm_dev_register()
is called.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2016-11-29 21:03:18 +02:00
Daniel Schultz d701453bd5 drm/tilcdc: Correct misspelling in error message
This error message will be printed when a FIFO underflow irq has
triggered. Since this happens sometimes and the error message will be
displayed on the console, it should have a correct spelling.

Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-11-29 21:03:17 +02:00
Daniel Schultz 4c268d635f drm/tilcdc: Add revision handling for FB_CEILING
The commit d8ff0c63fbcb ("drm/tilcdc: Adjust the FB_CEILING address")
added an adjustment of the FB_CEILING address. This is done by decrementing
the address by one.

On the AM335x (rev 0x4F201000) the framebuffer is rotated left over the
display border, because the ceiling address is 8f276fff instead of
8f277000. Since this adjustment isn't necessary for the LCDC v2, the
origin ceiling address should be used.

Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-11-29 21:03:17 +02:00
Bartosz Golaszewski 507b72b24c drm/tilcdc: add a da850-specific compatible string
Due to some potential tweaks for the da850 LCDC (for example: the
required memory bandwith settings) we need a separate compatible
for the IP present on the da850 boards.

Suggested-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-11-29 21:03:16 +02:00
Bartosz Golaszewski cb42e20ea0 drm/tilcdc: add a workaround for failed clk_set_rate()
Some architectures don't use the common clock framework and don't
implement all the clk interfaces for every clock. This is the case
for da850-lcdk where clk_set_rate() only works for PLL0 and PLL1.

Trying to set the clock rate for the LCDC clock results in -EINVAL
being returned.

As a workaround for that: if the call to clk_set_rate() fails, fall
back to adjusting the clock divider instead. Proper divider value is
calculated by dividing the current clock rate by the required pixel
clock rate in HZ.

This code is based on a hack initially developed internally for
baylibre by Karl Beldan <kbeldan@baylibre.com>.

Tested with a da850-lcdk with an LCD display connected over VGA.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-11-29 21:03:15 +02:00
Jani Nikula 55edf41b69 drm: define drm_compat_ioctl NULL on CONFIG_COMPAT=n and reduce #ifdefs
If we define drm_compat_ioctl NULL on CONFIG_COMPAT=n, we don't have to
check for the config everywhere.

Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1478014844-27454-1-git-send-email-jani.nikula@intel.com
2016-11-02 11:33:47 -04:00
Russell King 97ac0e47ae drm: convert DT component matching to component_match_add_release()
Convert DT component matching to use component_match_add_release().

Acked-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/E1bwo6l-0005Io-Q1@rmk-PC.armlinux.org.uk
2016-10-25 11:52:38 -04:00
Laurent Pinchart 59f11a4323 drm: tilcdc: Replace drm_fb_get_bpp_depth() with drm_format_plane_cpp()
The driver needs the number of bytes per pixel, not the bpp and depth
info meant for fbdev compatibility. Use the right API.

In the tilcdc_crtc_mode_set() function compute the hardware register
value directly from the pixel format instead of computing the number of
bits per pixels first.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1476744081-24485-7-git-send-email-laurent.pinchart@ideasonboard.com
2016-10-18 15:21:57 +05:30
Chris Wilson 0853695c3b drm: Add reference counting to drm_atomic_state
drm_atomic_state has a complicated single owner model that tracks the
single reference from allocation through to destruction on another
thread - or perhaps on a local error path. We can simplify this tracking
by using reference counting (at a cost of a few more atomics). This is
even more beneficial when the lifetime of the state becomes more
convoluted than being passed to a single worker thread for the commit.

v2: Double check !intel atomic_commit functions for missing gets
v3: Update kerneldocs

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161014121833.439-27-chris@chris-wilson.co.uk
2016-10-17 08:19:57 +02:00
Dave Airlie 662d5c9571 Second attempt for 3rd drm/tilcdc pull request for v4.9.
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJX5R79AAoJEJA2s1DX1hlBKHYP/2dfTMY3OGJtLaXUTFR0v5/v
 NPYneoAlSbwI8//hyuXXwgubiHGc0sTiQtmiVpdjXl2TgUrQpgTO98xGV+tMEeME
 4vydlR/dZV7TTdsKhWAWkx3BauSR5Qqfz5jy4oiRjxtCCBKyyAQxvuSC6opHnpCu
 dDlIy9PLEMV8PcIh3iTEqRDkJ1xy0dcZ/E+j66EeLACByduObVjaxRnNumu/1kzh
 wskBaVPR4547Qx4OM/LDOLrh97D2lIhMMBoDlrQZNx6sCcXFXPgLG+CWZv7b8/TQ
 A8PT4cQuUHg5Bs2w/8VWuXja0sWpwptp6zU7b6W6H0omYK9+lZLppRMWiP549s5R
 BirrChI4jGq7iTSfp7WUJI/dopSkSxGeX96w2pQfhbf6Ip6TbN0/ohMpOVQXh8Pn
 96prS67/gHXJ4u3pxU1/Yce6L9NkXiTHFiyiL8EGsUHSki0ccFiiPrSq6Yrteea+
 oDgRGHB3tcEA0Uk08pSHjy2Ts73CxDs27iA1N/Q2k60bR37WaKU5MKlxnTrntPfZ
 6kdoyPyQI9BUZDzlpmXrH2zLPTXMlFgAnbo8AevF1u4c95fJlDdlYyWZunQ/DOlB
 CNDSGZIU1kG99LH8sNr4+4TxjeFavBYAl09fPL6kFS8hyNhorvdZye8x+lmQvIkQ
 NsmWkVzHCoosINIJmuCl
 =Iyf9
 -----END PGP SIGNATURE-----

Merge tag 'tilcdc-4.9-3.1' of https://github.com/jsarha/linux into drm-next

Second attempt for 3rd drm/tilcdc pull request for v4.9.

* tag 'tilcdc-4.9-3.1' of https://github.com/jsarha/linux:
  drm/tilcdc: fix wrong error handling
  drm/tilcdc: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node()
  drm/tilcdc: Remove "default" from blue-and-red-wiring property binding
  drm/tilcdc: Fix non static symbol warning
  drm/tilcdc: mark symbols static where possible
  drm/tilcdc: add missing header dependencies
  drm/tilcdc: WARN if CRTC is touched without CRTC lock
  drm/tilcdc: Take CRTC lock when calling tilcdc_crtc_disable()
  drm/tilcdc: Remove unnecessary tilcdc_crtc_disable() from tilcdc_unload()
  drm/tilcdc: Flush flip-work workqueue before drm_flip_work_cleanup()
  drm/tilcdc: Clean up LCDC functional clock rate setting code
  drm/tilcdc: Take crtc modeset lock while updating the crtc clock rate
2016-09-28 11:17:26 +10:00
Daniel Schultz 7b993855df drm/tilcdc: fix wrong error handling
When 'component_bind_all' fails it should not try to unbind components
in the error handling. This will produce a null pointer kernel panic when
no component exist.

This patch changes the order of the error handling. Now, it will only
unbind components if the are bound. Otherwise, the module will jump to
an error label below.

Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-09-23 15:12:57 +03:00
Markus Elfring cf97ee1962 drm/tilcdc: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node()
Return directly after a memory allocation failed in this function
at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-09-23 13:49:52 +03:00
Wei Yongjun 30457676e2 drm/tilcdc: Fix non static symbol warning
Fixes the following sparse warning:

drivers/gpu/drm/tilcdc/tilcdc_drv.c:64:5: warning:
 symbol 'tilcdc_atomic_check' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-09-22 23:50:09 +03:00
Baoyou Xie 952e8faec5 drm/tilcdc: mark symbols static where possible
We get 3 warnings when building kernel with W=1:
drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c:142:29: warning: no previous prototype for 'tilcdc_get_overlay' [-Wmissing-prototypes]
drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c:198:13: warning: no previous prototype for 'tilcdc_convert_slave_node' [-Wmissing-prototypes]
drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c:264:12: warning: no previous prototype for 'tilcdc_slave_compat_init' [-Wmissing-prototypes]

In fact, these functions are only used in the file in which they are
declared and don't need a declaration, but can be made static.
So this patch marks these functions with 'static'.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-09-22 23:50:09 +03:00
Baoyou Xie 0fd86779f0 drm/tilcdc: add missing header dependencies
We get 4 warnings when building kernel with W=1:
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c:393:12: warning: no previous prototype for 'tilcdc_tfp410_init' [-Wmissing-prototypes]
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c:398:13: warning: no previous prototype for 'tilcdc_tfp410_fini' [-Wmissing-prototypes]
drivers/gpu/drm/tilcdc/tilcdc_panel.c:443:12: warning: no previous prototype for 'tilcdc_panel_init' [-Wmissing-prototypes]
drivers/gpu/drm/tilcdc/tilcdc_panel.c:448:13: warning: no previous prototype for 'tilcdc_panel_fini' [-Wmissing-prototypes]

In fact, these functions are declared in
drivers/gpu/drm/tilcdc/tilcdc_tfp410.h,
drivers/gpu/drm/tilcdc/tilcdc_panel.h,
so this patch adds missing header dependencies.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-09-22 23:50:08 +03:00
Sean Paul ce2f2c3f82 drm/tilcdc: Add atomic and crtc headers to crtc.c
Also reorder alphabetically and fix up drm_flip_work header.

Reviewed-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
2016-09-21 23:36:53 -07:00
Jyri Sarha 2e0965b06d drm/tilcdc: WARN if CRTC is touched without CRTC lock
WARN if CRTC is touched without CRTC lock. The crtc functions should
not be called simultaneously from multiple threads. Having the DRM
CRTC lock should take care of that.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-07 15:54:43 +03:00
Jyri Sarha 6c94c71400 drm/tilcdc: Take CRTC lock when calling tilcdc_crtc_disable()
Take CRTC lock when calling tilcdc_crtc_disable() in
tilcdc_crtc_destroy().

In theory there could still be some operation ongoing, which should
finish before destroying the CRTC. However, the main reason for
adding this is to be able to add WARNing in tilcdc_crtc_disable() if
CRTC is not locked.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-07 15:54:42 +03:00
Jyri Sarha 7eff041027 drm/tilcdc: Remove unnecessary tilcdc_crtc_disable() from tilcdc_unload()
Remove unnecessary tilcdc_crtc_disable() from tilcdc_unload(). The
tilcdc_crtc_disable() called via tilcdc_crtc_destroy() by
drm_mode_config_cleanup() couple of lines later.

The early call to tilcdc_crtc_disable() was a wrong fix (that worked)
for calling drm_flip_work_cleanup() before flushing the flip-work
queue.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-07 15:54:42 +03:00
Jyri Sarha 4e910c7a18 drm/tilcdc: Flush flip-work workqueue before drm_flip_work_cleanup()
Flush flip-work workqueue before drm_flip_work_cleanup(). It causes a
nasty warning if there is unfinished flip-work in the queue when
drm_flip_work_cleanup() is called. The flush_workqueue() has to be
called before drm_crtc_cleanup() for unref_worker() to be able to do
its job.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-07 15:54:41 +03:00
Jyri Sarha 642e51677d drm/tilcdc: Clean up LCDC functional clock rate setting code
Clean up LCDC functional clock rate setting code.

The LCDC functional clock is set by two functions: mode_set_nofb() and
cpufreq_transition().

When tilcdc_crtc_mode_set_nofb() is called in atomic commit phase the
drm atomic helpers have taken all the necessary drm locks and turned
off the crtc, while tilcdc_commit() is keeping LCDC powered on. For
mode_set_nofb() just a simple clock setting function without any
locking or power management code is enough. The new tilcdc_crtc_set_clk()
is implemented for that purpose.

cpufreq_transition() on the other hand is called from outside DRM and
it needs to take the necessary locks and turn off the CRTC while
keeping the LCDC powered. The reimplemented tilcdc_crtc_update_clk()
is for that purpose and it uses the new tilcdc_crtc_set_clk() to
actually set the clock.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-07 15:54:40 +03:00
Jyri Sarha a6b7ebaadb drm/tilcdc: Take crtc modeset lock while updating the crtc clock rate
Take crtc modeset lock while updating the crtc clock rate. To avoid a
race in tilcdc_crtc_update_clk(), we do not want crtc mode to change
while we update crtc clock.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-07 15:54:40 +03:00
Jyri Sarha c566538552 drm/tilcdc: Choose console BPP that supports RGB
Choose console BPP that supports RGB and remove the old fbdev bpp
selection code. LCDC on AM335x has red and blue wires switched between
24 bit and 16 bit colors. If 24 format is wired for RGB colors, the 16
bit format is wired for BGR. drm_fbdev_cma_init() does not currently
like anything else but RGB formats, so we must choose such bytes per
pixel value that supports RGB.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-01 22:32:23 +03:00
Jyri Sarha bcc5a6f5fc drm/tilcdc: Add blue-and-red-crossed devicetree property
Add "blue-and-red-wiring"-device tree property and update devicetree
binding document.

The red and blue components are reversed between 24 and 16 bit modes
on am335x LCDC output pins. To get 24 RGB format the red and blue
wires has to be crossed and this in turn causes 16 colors output to be
in BGR format. With straight wiring the 16 color is RGB and 24 bit is
BGR.

The new property describes whether the red and blue wires are crossed
or not. If the property is not present or its value is not recognized
the legacy mode is assumed. The legacy configuration supports RGB565,
RGB888 and XRGB8888 formats. However, depending on wiring, the red and
blue colors are swapped in either 16 or 24-bit color modes.

For more details see section 3.1.1 in AM335x Silicon Errata:
http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sprz360

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-01 22:32:11 +03:00
Jyri Sarha 7eb9f069ff drm/tilcdc: Write DMA base and ceiling address with single instruction
Write DMA base and ceiling address with a single instruction, if
available. This should make it more unlikely that LCDC would fetch the
DMA addresses in the middle of an update. Having bad combination of
addresses in dma base and ceiling (e.g base > ceiling) can cause
unpredictaple behavior in LCDC.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-01 22:31:59 +03:00
Jyri Sarha 63b07a8d81 drm/tilcdc: Remove drm_helper_disable_unused_functions() call
drm_helper_disable_unused_functions() should not be called by atomic
drivers.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
2016-09-01 22:31:41 +03:00
Karl Beldan 8d6c3f7d8f drm/tilcdc: Enable EOF interrupts for v1 LCDC
This got accidentally dropped in the fixed commit and is required for
the driver to properly work on the rev1 IP, such as found on the LCDK.

Fixes: 2b2080d7e9 ("drm/tilcdc: Get rid of complex ping-pong mechanism")
Signed-off-by: Karl Beldan <kbeldan@baylibre.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-09-01 22:30:12 +03:00
Karl Beldan ee8c42baeb drm/tilcdc: Adjust the FB_CEILING address
The LCDC seems to expect its framebuffer ceiling address pointer to be
an inclusive bound.  The IP rev2 seems to cope with that but rev1 (as
found on the LCDK) don't.
Also note that this is what the framebuffer code does in da8xx-fb.c.

Since, as the TRM puts it, "The 2 LSBs are hardwired to 00b", the
dma_addr_t can be decremented without cast.
I tested it with a v2 (AM335x, rev  0x4F201000) and an LCDK (v1).

Signed-off-by: Karl Beldan <kbeldan@baylibre.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-09-01 22:29:12 +03:00
Teresa Remmet a3479c4fa0 drm/tilcdc: Fix check for remote port parent
In function tilcdc_get_external_components the check for
the remote port parent is not correct. We need a '||' instead of
an '&&'.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-09-01 22:28:57 +03:00
Liu Ying 2b58e98d42 drm/atomic-helper: Add NO_DISABLE_AFTER_MODESET flag support for plane commit
Drivers may set the NO_DISABLE_AFTER_MODESET flag in the 'flags' parameter
of the helper drm_atomic_helper_commit_planes() if the relevant display
controllers(e.g., IPUv3 for imx-drm) require to disable a CRTC's planes
when the CRTC is disabled. The helper would skip the ->atomic_disable
call for a plane if the CRTC of the old plane state needs a modesetting
operation. Of course, the drivers need to disable the planes in their CRTC
disable callbacks since no one else would do that.

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Liu Ying <gnuiyl@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1472461923-14364-1-git-send-email-gnuiyl@gmail.com
2016-08-29 11:29:37 +02:00
Jyri Sarha e0e344e620 drm/tilcdc: Change tilcdc_crtc_page_flip() to tilcdc_crtc_update_fb()
Change tilcdc_crtc_page_flip() to tilcdc_crtc_update_fb(). The
function is not used as a page_flip() callback anymore so it is only
confusing to call it that. The function should only be used by dummy
primary plane commit() callback.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:19 +03:00
Jyri Sarha d81b7f3403 drm/tilcdc: Remove unnecessary pm_runtime_get() and *_put() calls
Remove unnecessary pm_runtime_get() and *_put() calls from commit
phase callbacks. Those calls are not needed since we have the whole
commit phase between pm_runtime_get_sync() and pm_runtime_put_sync().

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:18 +03:00
Jyri Sarha 47bfd6c01e drm/tilcdc: Get rid of legacy dpms mechanism
Get rid of legacy dpms mechanism. This simplifies the code quite a
bit. The old start() and stop() functions become tilcdc_crtc_enable()
and *_disable(). The functions are added with all the necessary
mechanisms from the old dpms function and they are used directly as
the crtc helper enable() and disable() callbacks.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:17 +03:00
Jyri Sarha 514d1a1f47 drm/tilcdc: Use drm_atomic_helper_resume/suspend()
Use drm_atomic_helper_resume/suspend() and get rid off all the obsolete
register level context restoring code.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:16 +03:00
Jyri Sarha afaf833dd5 drm/tilcdc: Enable and disable interrupts in crtc start() and stop()
Enable and disable interrupts in crtc start() and stop(). None of the
interrupts can fire if CRTC is disabled, so it is cleaner - when
considering suspend/resume code etc. - to enable the interrupts when
CRTC is turned on and to disable them when CRTC is turned off.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:15 +03:00
Jyri Sarha 018cfbde63 drm/tilcdc: tfp410: Add atomic modeset helpers to connector funcs
Add atomic modeset helpers to tfp410 connector funcs. Property handling
related helpers, atomic reset helper, and new dpms helper is needed in
connector for atomic modeseting to work. The default helper functions
are enough.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:13 +03:00
Jyri Sarha 7c979b5518 drm/tilcdc: tfp410: Set crtc panel info at init phase
Set crtc panel info at init phase. Setting it at prepare callback does
it multiple times for no good reason and it is also too late when atomic
modeset is used.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:12 +03:00
Jyri Sarha 0f65d89b9a drm/tilcdc: panel: Add atomic modeset helpers to connector funcs
Add atomic modeset helpers to panel connector funcs. Property handling
related helpers, atomic reset helper, and new dpms helper is needed in
connector for atomic modeseting to work. The default helper functions
are enough.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:11 +03:00
Jyri Sarha ee6de21b69 drm/tilcdc: panel: Set crtc panel info at init phase
Set crtc panel info at init phase. Setting it at prepare callback does
it multiple times for no good reason and it is also too late when atomic
modeset is used.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:10 +03:00
Jyri Sarha c72cc66364 drm/tilcdc: Remove tilcdc_verify_fb()
Remove tilcdc_verify_fb(). The tilcdc_verify_fb() function is not
needed because the same checks are implemented in
tilcdc_plane_atomic_check().

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:09 +03:00
Jyri Sarha 6b4736db9c drm/tilcdc: Remove obsolete crtc helper functions
Remove obsolete crtc helper functions. These are not needed when
atomic modeset is used.

Note that the drm_crtc_helper_funcs mode_fixup() is still needed. The
crtc's check() callback can not do its job here.

The plane's check() callback needs to set drm_crtc_state's
->mode_changed to true if the pixel format for the framebuffer
changes. Because of this drm_mode_config_funcs atomic_check() callback
needs to call drm_atomic_helper_check_modeset() once more after it has
called drm_atomic_helper_check_planes(). If the fixing of the
adjusted_mode would be done in drm_crtc_helper_funcs atomic_check()
callback, it would get over written by the extra
drm_atomic_helper_check_modeset() call.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:08 +03:00
Jyri Sarha 305198de89 drm/tilcdc: Set DRIVER_ATOMIC and use atomic crtc helpers
Set DRIVER_ATOMIC and use atomic helpers and rename commit and prepare
crtc helpers to enable and disable. This makes the final jump to mode
setting, but there is lot of obsolete code to clean up.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:07 +03:00
Jyri Sarha 522a76f895 drm/tilcdc: Add drm_mode_config_reset() call to tilcdc_load()
Add drm_mode_config_reset() call to tilcdc_load(). This is need to
initialize atomic state variables at load time.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:06 +03:00
Jyri Sarha edc4330388 drm/tilcdc: Add atomic mode config funcs
Add atomic mode config funcs. The atomic_commit implementation is a
copy-paste from drm_atomic_helper_commit(), leaving out the async
test. The similar copy-paste implementation appears to be used in many
other drivers too. The standard drm_atomic_helper_check() is used for
checking.

The drm_atomic_helper_check() can not be used in drm_mode_config_funcs
atomic_check() callback because the plane's check implementation may
update crtc state's ->mode_changed flag. Because of this the
drm_atomic_helper_check_modeset() has to be called once more after
drm_atomic_helper_check_planes() (see drm_atomic_helper_check_modeset()
documentation).

Signed-off-by: Jyri Sarha <jsarha@ti.com>
2016-08-08 23:05:05 +03:00