gpu: ipu-v3: Add RGB666 interface pixel map

Adds RGB666 to the pre-loaded interface pixel maps.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: parallel-display: Support RGB666 pixel fmt

Add a clause to imx-pd driver to use 18-bit output if driver is told so.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>

Ported from 23bddaa0530458c4f76c881c189f266bb0f4b073.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
ARM: i.MX6: select pll3_usb_otg for ldb_di

Select pll3_usb_otg for ldb_di clock for rev 1.0 chips.

Based on 2d34ce03cbbbf15213825f51e232fd6d4dd5cee4.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: imx-ldb: Add debug to connector/encoder entry points

Add some debug macros for the important encoder and connector
callbacks.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: imx-ldb: Implement imx_ldb_encoder_dpms()

Implement imx_ldb_encoder_dpms(). Two new functions are created
to share poweroff and poweron code. imx_ldb_poweroff() is called
by encoder dpms, prepare, and disable. imx_ldb_poweron() is called
by encoder dpms and commit.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: parallel-display: Fix typo when setting mode type

Comma expression is used to set mode type
"mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,"
which is a typo, replace it with ";".

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>

Ported from 1e8af135d09cc478b83ccb6280dbc34f6d585317.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
gpu: ipu-cpmem: Pass drm fourcc to ipu_cpmem_set_yuv_*

Pass a drm pixel format fourcc to ipu_cpmem_set_yuv_interleaved(),
ipu_cpmem_set_yuv_planar_full(), and ipu_cpmem_set_yuv_planar(),
instead of a v4l2 pixel format. The remaining cpmem API that still
accepts a v4l2 format is now only ipu_cpmem_set_image(), since this
function is called by v4l2 drivers.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
gpu: ipu-v3: Add ipu_drm_fourcc_is_planar()

Adds ipu_drm_fourcc_is_planar(), which is equivalent to
ipu_pixelformat_is_planar() but accepts a drm fourcc format.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: ipuv3-plane: Fix planar formats

During a mode set the U/V plane strides and buffer offsets
for planar pixel formats were not being configured in cpmem.
Fix by calling ipu_cpmem_set_yuv_planar() for planar formats.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: ipuv3-plane: Allow YUV space for background plane

A background plane was assuming the framebuffer pixel format was
RGB by passing IPUV3_COLORSPACE_RGB to ipu_dp_setup_channel(). Fix
by passing the actual colorspace of the framebuffer's pixel format.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
gpu: ipu-cpmem: Support YVU422

Add simple hooks to support YVU422 in cpmem.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: ipuv3-plane: Add more supported pixel formats

Report more supported formats to drm core via ipu_plane_formats[].

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: ipuv3-plane: Implement global alpha and colorkey properties

Add support for setting global alpha and colorkey in foreground planes
using plane properties. Background planes can also support these
properties if the background plane is initialized as not private.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: hdmi: rework irq request/free

Rearrange how HDMI driver requests and frees irq. Currently the driver
has two problems:

1) if imx_hdmi_register() fails, irq still can trigger and cause oops
2) irq is enabled too early, before all fields are initialized, so
triggered irq can cause oops.

Fix by moving irq request and activation to very end of imx_hdmi_bind(),
especially after imx_hdmi_register(). Then there's no possible way there
could be a (spurious) interrupt after a failed imx_hdmi_register() but
before the irq is freed.

This is a combination of de3749a26d82d37dfe3c2f32ff8beeaf8d8a91f7 and
2f9c6c600146fdecab1136b3ebce51cf6a5fd22c.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>
Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: imx-ldb: Add standby pin control

Add standby pin and then control standby pin to disable/enable LCD

Signed-off-by: Fred Fan <yefeng.fan2@de.bosch.com>

This is a port of 859d413198a5e0f98bb8983b18dfc75a0d548467 and
53e99433e5450442e254f14415f66939f393e303.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: imx-ldb: Add DDC support

Add support for reading EDID over Display Data Channel. If no DDC
adapter is available, falls back to hardcoded EDID or display-timings
node as before.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: Move page flip handling to plane driver

Move page flip handling and associated vblank handling to the
plane driver. This paves the way to allow page flipping in not
just the primary plane but the overlay plane as well.

To do this the primary and overlay planes are assigned a pipe value
suitable for passing to the drm core vblank methods (drm_vblank_get,
put,handle).

We modify imx-drm core slightly to make room for primary and overlay
pipe id's when assigning the crtc pipe. So crtc 0 has a primary pipe
value of 0 and overlay pipe value 1, crtc 1 has primary pipe value 2
and overlay pipe value 3, etc. imx_drm_crtc_id() returns the primary
pipe divided by 2 as an id value to form possible crtc masks.

The drm core vblank sees these planes as additional crtcs (pipes) and
does not need significant changes.

The plane driver implements page flip using idmac double-buffering.
Without double-buffering, a page flip operation changes the idmac
channel buffer base address while the buffer is still active. This
is not recommended according to the reference manual.

With double-buffering, a page-flip can set the base of the inactive
buffer before switching to it using buffer-ready control.

Note that for the synchronous display channels, the buffer ready signal can
be driven either by the ARM core writing to the buffer ready registers,
or by the DI.

When the ARM core does not drive ping-pong buffer ready selection at
every EOF, the DI will drive buffer ready, triggered by a timer located
in the DI. The IPU's FSU unit will quickly settle on a single buffer and
then remain at that buffer, the DI driving buffer ready at that buffer.

If the ARM core (the plane driver) then selects the other (inactive)
buffer, the FSU switches to it and then remains at this buffer, the DI
again taking over buffer ready signalling at the new buffer, until the
ARM core makes the next buffer selection.

So we take advantage of this behaviour and use buffer selection to
switch to the other buffer when we want to flip to another DRM
framebuffer for page-flip.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: Reset ipu unit pointers to NULL on errors

In the crtc and plane drivers it is possible the ipu unit pointers
could be left at error pointer values. Reset them to NULL on errors
to prevent this. Also ipu_put_resources() should reset the units to
NULL after releasing them.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
drm: implement page flipping support for planes

Planes like crtcs would benefit from having page flip event support.
With planes page flip it is now possible to synchronize changing a
framebuffer used by plane with vertical sync events.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry_eremin@mentor.com>

Ported from 69d4542d0152893c50839d0a25280b42af64296e.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>
imx-drm: ipuv3-plane: Assign page_flip method to drm_plane_funcs

Assign ipu_plane_page_flip to new drm_plane_funcs->page_flip method.
This allows page flip operation in both the primary and overlay planes.

Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com>