Commit Graph

67 Commits

Author SHA1 Message Date
1fad0c7ba4 MLK-19468: drm: imx: dcss: fix blkctl setting for B1 silicon
B1 silicon has a new ID and we need to handle it properly.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:33:47 +08:00
d64ff2b2f6 MLK-19274: drm: imx: dcss: add rotation functionality
This patch will allow userspace to rotate planes by setting the
'rotation' property. Generally, 0 and 180 rotations are allowed for
pretty much all 8-bit xRGB and 2-plane YUV420 formats. 90/270 rotations
can be performed only for non-compressed tiled GPU xRGB formats. Tiled
YUV420 formats do not allow rotations at all because these formats need
DTRC for de-tiling and DTRC has no rotation support.

For more info, consult the DPR Features chapter in the reference manual.

Test example:

modetest -M imx-drm -w 27:rotation:4 -w 32:rotation:33 -w 27:alpha:30 -s
42@31:3840x2160-60@XR24 -P 32@31:3840x2160@NV21

The above will perform:
 * 180 degree rotation of primary plane (XR24);
 * vertical flip of first overlay plane (rotate-0 | reflect-y);
 * set primary plane alpha to 30;

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:33:29 +08:00
855dea4f35 MLK-18809: drm: imx: dcss: revert the max upscale ratio to 1:8
The DCSS RM states that the maximum upscale ratio is 1:8. However, DCSS
HW team suggested some time back that upscale ratios of 1:16 could be
achieved with DCSS scaler, though these ratios were not validated.

Unfortunately there are corner cases, when the upscale ratio nears
1:16, that fail. At the recommendation of DCSS designers, we revert the
maximum ratio to 1:8 until further notice.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
(cherry picked from commit bafb5a9481c289951872923d4bbbbcf24a8910b5)
2019-02-12 10:32:57 +08:00
133855b90b MLK-18826: drm: imx: dcss: fix hang when dumping registers
If DCSS is suspended, the clocks are disabled. Dumping the registers,
with the following command:

cat /sys/kernel/debug/imx-dcss/dump_registers

will hang the system, because of DTG.

This patch makes sure clocks are enabled before dumping the registers
and will immediately release them afterwards.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:32:44 +08:00
18d6c486e4 MLK-18873: drm: imx: dcss: request PM QoS only when VBLANK is on
DCSS needs PM QoS in order to keep interrupt latency low. Otherwise,
page flipping will not work smooth enough because CTXLD will not be
triggered in time.

Currently, PM QoS is requested all the time but that does not allow the
CPUs to go idle. Hence, this leads to increased power consumption.

This patch will change how PM QoS is requested by doing it only when
VBLANK is enabled/disabled. The VBLANK interrupt is enabled just before
a commit takes place and disabled after one second after last commit.
This will allow DCSS to function properly and, also, allow CPUs to go
idle whenever there's no buffer submitted.

Exception to this is when DTRC is used (when DCSS is passed tiled
buffers). In this case, PM QoS will always be active, even if no buffer
is submitted, because DTRC banks need to be switched in CTXLD ISR, so
that DCSS does not underrun. DTRC does not have the REPEAT feature, as
the rest of DCSS does.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:32:39 +08:00
7f8239c878 MLK-18844: drm: imx: dcss: lower mode change time
Currently, there's a hardcoded wait time (500ms) after enabling DTG
clocks. This is supposed to avoid VBLANK timeout warning messages.
However, this time is quite big. This patch changes this by lowering this
time as much as possible, with the use of completion events. After
enabling CRTC we just block until the first VBLANK interrupt comes. This
way, we know for sure that we'll never get a VBLANK timeout.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:32:29 +08:00
3f77069897 MLK-18680-4: drm: imx: dcss: activate DPR completion interrupts
This patch activates DPR completion interrupts, just for tracing and
detecting green screen issues.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:32:28 +08:00
fd26cac133 MLK-18680-3: drm: imx: dcss: activate DTRC interrupts for debugging
DTRC interrupts will not be used for switching the banks, as the CTXLD
will be used for that, however these are useful for tracing and
debugging green screen issues when DTRC is used.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:32:28 +08:00
4f7b9db981 MLK-18680-2: drm: imx: dcss: add some traces
This patch will add traces for the following events:
 * CTXLD arm, completion and kick;
 * VBLANKs;
 * atomic flushes;
 * plane updates (printing the DPR buffer base address);

These will allow us to measure and analyze where bottlenecks are:
application or driver.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:32:28 +08:00
cbf778aa33 MLK-18680-1: drm: imx: dcss: low latency tracing mechanism
This patch adds a DCSS tracing mechanism that introduces as low latency
as possible, so that it does not affect timings. Instead of text, 64 bit
tags will be logged, together with the system time in nanoseconds. Based
on these, post-processing can be done on any PC to compute deltas,
delays, missed buffers, etc.

Example usage:

echo 1 > /sys/module/imx_dcss_core/parameters/tracing
gplay-1.0 movie.mpg
echo 0 > /sys/module/imx_dcss_core/parameters/tracing

To dump the trace:
cat /sys/kernel/debug/imx-dcss/dump_trace_log > trace.txt

With the help of a scripting language (awk), the trace can then be
post-processed and analyzed on the PC.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:32:28 +08:00
00d05efa64 MGS-3560 [#imx-913] Enable DRM compression for mscale board
Refine the code for compressed format support.

Date: June 29, 2018
Signed-off-by: Yong Gan <yong.gan@nxp.com>
2019-02-12 10:32:27 +08:00
7ad6072a37 MLK-17925: drm: imx: dcss: fix tearing
The video tearing appeared only when the application used 2 buffers.
That's because, sometimes, the context loader could be armed after the
DB event came in the frame trace. That made a buffer submitted in frame
N end up on screen in frame N+2 because the context loader waits for the
next DB event. Since vblank events are sent at the end of the frame, by
the time the buffer lands on screen, the application will reuse it while
it's being displayed, hence the tearing effect.

This patch moves the CTXLD trigger moment all the way to the end of the
frame trace, just before DB event arrives. This will leave the
application plenty of time to submit new buffers.

In the event that the trigger moment is missed (application submits a
buffer right at the end of a frame trace), then we're not signalling the
next VBLANK event to application. This way, application will know that
the buffer is still needed and will not submit a new one.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:32:15 +08:00
7c76871dbb MLK-18164: drm: imx: dcss: fix max upscale ratio
Currently, the maximum upscale ratio is 1:7. However, DCSS can support
upscale ratios up to 1:16, even though the RM states the maximum upscale
ratio is 1:8.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
(cherry picked from commit 361a057cee)
2019-02-12 10:31:22 +08:00
92100dc00e MLK-18115: drm: imx: dcss: fix usage of uninitialized variable
In certain conditions, i.e. YUV mode, pixel_depth variable will be used
uninitialized. This can lead to unpredictable behavior.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:31:18 +08:00
7f3ca9cbc2 MLK-18000: drm: imx: dcss: compute filter coeff based on scaling ratios
Currently, scaler filter coefficients are hardcoded. However, they need
to be re-computed, based on input/output resolution as well.

Also, in order to use the scaler 7-tap filter, DPR RTRAM rows need to be
changed accordingly.

Signed-off-by: Dzung Hoang <dzung.hoang@nxp.com>
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:31:15 +08:00
d835d638aa MLK-17703-5: drm: imx: dcss: ignore the 8 bit for input pipe
Since the input of HDR10 is always 10-bit, ignore 8-bit flags when
setting up the output pipe.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:31:06 +08:00
bc5cfdfaca MLK-17703-4: drm: imx: dcss: return the hdr10 table at once
Don't go through the rest of the list if we found our table. Just return it
immediately.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:31:06 +08:00
8665b1134f MLK-17703-1: drm: imx: dcss: update HDR10 tables
The old tables had incorrect CSCBs when YUV formats were being used. That's
because the application used to generate the tables always assumed channel 0 is
graphics even if it was configured as YUV.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:31:05 +08:00
c289d73356 MLK-17648-2: drm: imx: dcss: Load the HDR10 from header file
This commit allows one to select if a firmware file is used, for loading
the HDR10 tables, or a header. By default, this will be header file.
This is until a proper way of passing the file from bootloader is found.

Also, fix a minor bug which made parsing the tables over the actual data
limit.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:56 +08:00
caa821505c MLK-17648-1: drm: imx: dcss: add HDR10 module tables
This commit adds HDR10 tables as a header. Using a FW file is
problematic since the tables need to be available immediately after
boot. After the rootfs is mounted, as is the case for loading a FW file,
it's already too late if some conversion tables are needed.

This usually happens if the output pipe is configured as YUV420.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:56 +08:00
fd9a3c47df MLK-17645: drm: imx: dcss: fix DTRC start issue
The following commit:

af01350 - MLK-17634-18: drm: imx: dcss: optimize context loading and DDR
bus load

introduced a regression. During my attempts to fix various green screen
issues, I modified the DTRC start routine by enabling the other register
bank, not the current one.

Unfortunately, this was committed by mistake...

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:49 +08:00
4b874212e6 MLK-17671-1: drm: imx: dcss: add a delay after changing the pixel clock
DCSS needs some time to stabilize after switching to a new pixel clock.
All interrupts will delayed till the clock stabilizes and we'll end up
getting warnings about VBLANK interrupt taking more than 50ms to arrive.

This patch adds a 500ms delay after switching to a new clock. This will
allow DCSS to stabilize before enabling CRTC and DTG channels.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:48 +08:00
f4e80340e7 MLK-17689-1: drm:imx: dcss: Fix DCSS clock selection for MIPI
Fix the clock source selection for MIPI use-case.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
2019-02-12 10:30:48 +08:00
1258b41d40 MLK-17626: drm: imx: dcss: fix "ctxld error" messages
The problem arised because of a combination of 2 commits:

Commit 1:

"2a70f32 - MLK-17232-2: drm: imx: dcss: ignore SB_PEND_DISP_ACTIVE
interrupt"

disabled the SB_PEND_DISP_ACTIVE interrupt because of a problem in SOC.
However, it did not remove the flag from CTXLD_IRQ_ERROR macro.

Commit 2:

"f0e3911 - MLK-17459-1: drm: imx: dcss: change ctxld irq handling"

moved the bottom half interrupt handling to top half. By doing that, the
top half did not exit immediately if IRQ_COMPLETION condition was met
and continued evaluating if any interrupts in CTXLD_IRQ_ERROR flags
were triggered.

This patch removes SB_PEND_DISP_ACTIVE interrupt flag from
CTXLD_IRQ_ERROR macro.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:46 +08:00
a2a1c46fe0 MLK-17634-18: drm: imx: dcss: optimize context loading and DDR bus load
This will lower the amount of ctxld entries sent, if configuration has
not changed much. Also, disable channel 0 if alpha is 0 and global alpha
is used. This will lower the DDR load, depending on graphics channel
resolution.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:46 +08:00
09aaa36642 MLK-17634-17: drm: imx: dcss: make P010 tiled formats work
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:46 +08:00
164e1b778a MLK-17634-16: drm: imx: dcss: make 10-bit formats work with HDR
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:45 +08:00
5847d6c96d MLK-17634-15: drm: imx: dcss: handle P010 format
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:45 +08:00
7264088803 MLK-17634-14: drm: imx: dcss: Add basic HDR10 support
This patch adds basic HDR10 support. However, full support depends on
subsequent patches.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:45 +08:00
f1709bf8e0 MLK-17634-13: drm: imx: dcss: remove the dcss-tables header
The tables header is no longer necessary as dcss.fw file will be used
from now on to store LUT and CSC tables.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:45 +08:00
2216742190 MLK-17634-11: drm: imx: dcss: make DCSS use VIDEO2_PLL2 clock
This clock is needed by HDR10 so this patch makes DCSS use VIDEO2_PLL2
for the rest of the resolutions as well.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:45 +08:00
08a6a1d133 MLK-17634-8: drm: imx: dcss: read HDR10 LUTs/CSCs from FW file
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:44 +08:00
3589399cd3 MLK-17634-7: drm: imx: dcss: remove unused dcss_hdr10_priv structure member
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:44 +08:00
789efd5ea9 MLK-17459-4: drm: imx: dcss: fix weston
This patch fixes an issue introduced by the cropping patches which made
weston look bad. That's because use_dtrc flag was enabled if modifiers
were present. However, graphics plane can have modifiers too. This patch
adds an extra check.

Also, remove an unnecessary debug message.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:41 +08:00
4767484840 MLK-17459-3: drm: imx: dcss: fixes for compressed format cropping
Cropping of compressed formats seems problematic and we cannot up-align
in this case. For compressed formats we need to down-align both the
width and height.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:40 +08:00
1233607a95 MLK-17459-2: drm: imx: dcss: add cropping functionality and fix odd resolutions
This patch fixes playback for movies with unaligned widths/heights and
adds cropping functionality for tiled formats. Untiled formats will not
have this feature as cropping is a DTRC function.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:40 +08:00
59ca8534c4 MLK-17459-1: drm: imx: dcss: change ctxld irq handling
To remove any possible latencies introduced by scheduling the bottom
half interrupt handler, do everything in the top half handler and get
rid of the IRQ worker thread handler. Also, that needs all mutexes
changed to spinlocks since mutexes can sleep.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:40 +08:00
86fe65ddb7 MLK-17492 drm/imx: dec400d: set read config to '0x0' when bypass dec400d
When the DEC400D is set to bypass mode from decompressed mode,
the read config should be set to disable compression along with
the control register. Otherwise, the DEC400D cannot really leave
the decompressed mode. And the value '0x0' is suitable to be set
to read config register in this case.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2019-02-12 10:30:36 +08:00
5e7ce6e5d3 MLK-17490-2 drm/imx: dec400d: fix wrong path to define 'dcss_dec400d_write()'
The macro 'USE_CTXLD' usage in function 'dcss_dec400d_write()'
is opposite to the real defintion path.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2019-02-12 10:30:29 +08:00
ab33d30b20 MLK-17490-1 drm/imx: dec400d: fix incorrect register base passed to context loader
The register base of DEC400D which is passed to context loader
should be the physical address but not the ioremaped virtual
address.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2019-02-12 10:30:29 +08:00
883c745b2c MLK-17473-7 drm/imx: dec400d: avoid shadow trigger when bypass dec400d
Do not really do shadow regiters trigger in'dcss_dec400d_shadow_trig()'
when dec400d is bypassed, since in 'dcss_dec400d_bypass()', the shadow
registers have already been triggerd.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2019-02-12 10:30:29 +08:00
89110a82a8 MGS-3632-2: drm: imx: dcss: adjust DPR MAX_BYTES_PREQ depending on resolution
Current setting uses a 256 bytes/request for anything less than 1080p.
This works when DTRC is not involved. However, with DTRC, the
MAX_BYTES_PREQ needs to be fine tuned a little.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:29 +08:00
7162ea8890 MGS-3632-1: drm: imx: dcss: adjust ratio when WR_SCL kicks in
Using WRSCL for downscaling ratios between 3 and 5 can lead to more
DDR bandwidth beeing used (~400MB/s).

Hence, use WR_SCL only for downscaling ratios from 5 to 7.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:29 +08:00
ebe6aba18b MLK-17473-4 drm/imx: dcss: handle tiled and compressed layout for primary plane
Add handling code to support tiled and compressed pixel source
layout. The tiled only layout will bypass DEC400D and be resolved
by DPR, since DEC400D is only responsible for decompression.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
2019-02-12 10:30:29 +08:00
5690f1cb70 MLK-17401: drm: imx: dcss: fix scaling issue
Under certain circumstances (corner cases) the scaling fractions were
not set properly. This patch fixes this.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:17 +08:00
e6105ee90a MLK-17368-3: drm: imx: dcss: Add support for tiled formats
This patch effectively enables DTRC module in DCSS to decode tiled
formats from VPU:
 * uncompressed G1;
 * uncompressed G2;
 * compressed G2;

Compressed G2 formats need to pass on the decompression table offsets,
by using the 'dtrc_dec_ofs' property. This is a 64 bit value like below:

64--------48----------32---------16---------0
|<- chroma table ofs ->|<- luma table ofs ->|

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:12 +08:00
cdd6c9a50d MLK-17368-2: drm: imx: dcss: split dcss_ctxld_write
In order for DTRC to work properly, we need to be able to write the DCTL
registers (to switch banks), just before activating CTXLD. However,
__dcss_ctxld_enable() function is usually called from irq context, or
whn the mutex is taken. Hence, create a function the can be called from
irq context.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:12 +08:00
220a46f0f0 MLK-17257-2: drm: imx: dcss: use the WRSCL/RDSRC modules
This patch makes the necessary changes so that, for downscaling ratios
more than 3:1 and up to 7:1 (for video) and 5:1 (for graphics), the
WRSCL/RDSRC path will be used. This way the DRAM bandwidth will be lower
and spread evenly across the frame time.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:02 +08:00
7f8fb37423 MLK-17257-1: drm: imx: dcss: Add WRSCL/RDSRC modules
WRSCL and RDSRC modules will be needed when downscaling ratios starting
from 3:1 up to 7:1 are needed. Otherwise, if the usual scaling path is
used, the DRAM bandwidth needed will be too much and performance will be
affected.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:02 +08:00
ba0c3666c7 MLK-17274: drm: imx: dcss: use_global_alpha not working if channel
already enabled

If the channel is already enabled, or it doesn't need a mode set, then
the dcss_dtg_global_alpha_changed() will always return false for formats
with per-pixel alpha. Hence, the plane will not be updated. This patch
removes the check for image format and the check will be done for all
image formats.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
2019-02-12 10:30:01 +08:00