drm format working
UPSTREAM: drm: add extended property types

If we continue to use bitmask for type, we will quickly run out of room
to add new types.  Split this up so existing part of bitmask range
continues to function as before, but reserve a chunk of the remaining
space for an integer type-id.  Wrap this all up in some type-check
helpers to keep the backwards-compat uglyness contained.

Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit 5ea22f24d77b511d68c4ecaf4e6fd5d6ab462b8f)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: I5dbff8cfc64fe7226ffabc43bb1dd074e411762b
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210714
Reviewed-by: Dominik Behr <dbehr@chromium.org>
UPSTREAM: drm: expose subpixel order name routine v3

Just like we have for connector type etc.

v2: drop static array (Chris)
v3: add kdoc (Daniel)

Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Acked-by: Dave Airlie <airlied@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit ac1bb36c4e28b53b3494bc8afbe6ffa0588bfe4a)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: I2551944b7e579b9161c8fbae2e1bebf019afd40c
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210715
Reviewed-by: Dominik Behr <dbehr@chromium.org>
UPSTREAM: drm/kms: rip out drm_mode_connector_detach_encoder

It's only used by imx, and that one gets it wrong - there's no need
to deteach the encoder before removing it.

And really, neither current drm modesetting code nor all the userspace
we have can handle dynamic changes in the set of possible encoders for
a given connector. So let's just remove this before someone starts
doing something really nasty with it.

As a plus, one less kerneldoc comment to write.

Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit 69fa5293bf8d0ade3fd726848c7af925227e9180)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: I0a481a600ca42e79a091e1768cffa2cc3a649fc6
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210716
Reviewed-by: Dominik Behr <dbehr@chromium.org>
UPSTREAM: drm: Have the crtc code only reference master from legacy nodes v2

control- and render nodes are intended to be master-less.

v2: Replace tests for !legacy with tests for !mode_group for readability.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
(cherry picked from commit 09f308f7b675b692d1c0a451ff02f0fff7846c96)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: If1017ffe46e61490137a473b6c49d95387e5ada8
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210717
Reviewed-by: Dominik Behr <dbehr@chromium.org>
UPSTREAM: drm: Add support for multiple plane types (v2)

The DRM core currently only tracks "overlay"-style planes.  Start
refactoring the plane handling to allow other plane types (primary and
cursor) to also be placed on the DRM plane list.

v2: Add drm_for_each_legacy_plane() iterator to smooth transition
    of drivers with plane loops.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit e27dde3e1c5117149c50b89d688528e279756113)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: I4466d3a0568e9e803740447ffc17c5ff97497102
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210718
Reviewed-by: Dominik Behr <dbehr@chromium.org>
UPSTREAM: drm: Make drm_crtc_check_viewport non-static

This function will be used by the universal plane helpers and may also
be useful for individual drivers.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit af93629d1524dfff7df215b7de692f4de5ee855f)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: I4aa17666550f12be2b169b67c7faa915c83725c8
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210719
Reviewed-by: Dominik Behr <dbehr@chromium.org>
UPSTREAM: drm: kerneldoc polish for drm_crtc.c

- Standardized on "Returns:" Block.
- Sprinkle missing kerneldoc over all exported functions and all
  ioctls.
- Add a stern warning that driver's really shouldn't use
  drm_mode_group_init_legacy_group.
- Usual attempt at more consistency.
- Add warnings that drm_mode_object_get/put don't do refcounting,
  despite what the names might lead to believe.
- Try to clarify the framebuffer setup/cleanup functions wrt driver
  private framebuffers - I've fallen recently over this when reviewing
  i915 fbdev patches.
- Align function parameters where the kerneldoc has been updated.
- Most of the drm_get_*_name functions aren't thread safe. Add stern
  warnings where this is the case.

Since a lot of the functions in drm_crtc.c are boilerplate to handle
properties and create default sets of them it might be useful to
extract all that code into a new file drm_property.c. Especially since
properties will be used a lot more in the future.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit c8e32cc1219fc15135b696b726421571f68bd97e)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: Ic7c169bcc58b76a5a14395e75766a019723fd3d7
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210720
Reviewed-by: Dominik Behr <dbehr@chromium.org>
UPSTREAM: drm: Add drm_universal_plane_init()

Add a new plane initialization interface for universal plane support
that allows a specific plane type (primary, cursor, or overlay) to
be specified.

drm_plane_init() remains as a compatibility API to reduce churn in
existing drivers.  The 'bool priv' parameter has been changed to
'bool is_primary' under the assumption that all existing uses of
private planes were representing primary planes.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit dc415ff97d6b8f21cc6d264962f3a857a8d44650)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: Id0882ccfadfa9c7c4c9dbbec6354263f106a4267
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210722
Reviewed-by: Dominik Behr <dbehr@chromium.org>
UPSTREAM: drm: Add plane type property (v2)

Add a plane type property to allow userspace to distinguish plane types.

v2: Driver-specific churn eliminated now that drm_plane_init() and
    drm_universal_plane_init() were separated out in a previous patch.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit 9922ab5a7e4a4e089b2abfb1425590b97a7a90a3)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: Ia05e53b60c6ee6f875587ed2989815ae99663025
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210723
Reviewed-by: Dominik Behr <dbehr@chromium.org>
drm: Add primary plane helpers (v3)

When we expose non-overlay planes to userspace, they will become
accessible via standard userspace plane API's.  We should be able to
handle the standard plane operations against primary planes in a generic
way via the modeset handler.

Drivers that can program primary planes more efficiently, that want to
use their own primary plane structure to track additional information,
or that don't have the limitations assumed by the helpers are free to
provide their own implementation of some or all of these handlers.

v3: Tweak kerneldoc formatting slightly to avoid ugliness
v2:
 - Move plane helpers to a new file (drm_plane_helper.c)
 - Tighten checks on update handler (check for scaling, CRTC coverage,
   subpixel positioning)
 - Pass proper panning parameters to modeset interface
 - Disallow disabling primary plane (and thus CRTC) if other planes are
   still active on the CRTC.
 - Use a minimal format list that should work on all hardware/drivers.
   Drivers may call this function with a more accurate plane list to
   enable additional formats they can support.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
UPSTREAM: drm: Add drm_crtc_init_with_planes() (v2)

Add a new drm_crtc_init_with_planes() to allow drivers to provide
specific primary and cursor planes at CRTC initialization.  The existing
drm_crtc_init() interface remains to avoid driver churn in existing
drivers; it will initialize the CRTC with a plane helper-created primary
plane and no cursor plane.

v2:
  - Move drm_crtc_init() to plane helper file so that nothing in the DRM
    core depends on helpers.  [suggested by Daniel Vetter]
  - Keep cursor parameter to drm_crtc_init_with_planes() a void* until
    we actually add cursor support.  [suggested by Daniel Vetter]

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
(cherry picked from commit e13161af80c185ecd8dc4641d0f5df58f9e3e0af)

BUG=chromium:385270
TEST=compiles on rush

Change-Id: I92f114b6215c16ac88de97cd845bdd1e26e6d094
Signed-off-by: Rhyland Klein <rklein@nvidia.com>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210724
Reviewed-by: Dominik Behr <dbehr@chromium.org>
drm: reference gem obj when swap into vop and unrefernce when swap out

if gem obj swap into vop, and then we release the gem obj, iommu will
use a unmap buffer, and get oops. we should protect the buffer when we
use it.