WIP: drm/omap: use omapdss low level API (v?)

This is still work in progress, but it nicely solves the omapdss vs drm
impedence mismatches, and properly fixes unpin confusion vs GO bit status.
As an added bonus, we also no longer leave the last overlay buffer pinned.
Adding the previously missing vblank event handling for userspace should
be pretty trivial now too.

v1: initial version
v2: Reshuffle mapping of kms to dss.. now it is plane->ovl, crtc->manager.
    The encoder is still a placeholder and connector is dssdev, but
    eventually encoder should map to dss encoder (DSI/DPI/VENC/HDMI)
    and connector to panel.
v3: few cleanups, add debugfs, etc
v4: rebase and fix some irq issues
v5: rebase on "apply-test" version of omapdss
v6: add error irq handlers
v7: move the write access to dssdev (set_timings(), enable(), disable()
    to encoder, and use apply mechanism to sequence things properly
v8: rebase on apply-test-6
v9: update encoder.. call directly from apply in crtc to ensure correct
    sequencing
vA: rebase on tomi/work/apply-test-7, split dss debugfs files into
    different patch
vB: clean up crtc set_enabled() to not really need to care much about
    lcd vs tv, and clean up some spurious omapdss_compat_uninit()
    references that slipped through
WIP: drm/omap: add dss debugfs files
Revert "WIP: drm/omap: add dss debugfs files"

This reverts commit 0d82c82426dd9549974eb769b89c0e768d78d585.
HACK: drm/omap: hack to use dispc_request_irq()/dispc_free_irq()

If we associate dispc hwmod w/ omapdrm then we could avoid this..
drm: add atomic fxns

The 'atomic' mechanism allows for multiple properties to be updated,
checked, and commited atomically.  This will be the basis of atomic-
modeset and nuclear-pageflip.

The basic flow is:

   state = dev->atomic_begin();
   for (... one or more ...)
      obj->set_property(obj, state, prop, value);
   if (dev->atomic_check(state))
      dev->atomic_commit(state);
   dev->atomic_end(state);

The split of check and commit steps is to allow for ioctls with a
test-only flag (which would skip the commit step).
drm: add object property type

An object property is an id (idr) for a drm mode object.  This
will allow a property to be used set/get a framebuffer, CRTC, etc.
drm: add DRM_MODE_PROP_DYNAMIC property flag

This indicates to userspace that the property is something that can
be set dynamically without requiring a "test" step to check if the
hw is capable.  This allows a userspace compositor, such as weston,
to avoid an extra ioctl to check whether it needs to fall-back to
GPU to composite some surface prior to submission of GPU render
commands.
drm: add DRM_MODE_PROP_SIGNED property flag

Flag for range property types indicating that the value is a signed
integer rather than unsigned.  For range properties, the signed flag
will trigger use of signed integer comparisions, to handle negative
values properly.
drm: split property values out

Split property values out into a different struct, so we can later
move property values into state structs.  This will allow the
property values to stay in sync w/ the state updates which are
either discarded or atomically committed.
drm: convert plane to properties

Use atomic properties mechanism to set plane attributes.  This by
itself doesn't accomplish anything, but it avoids having multiple
code paths to do the same thing when nuclear-pageflip and atomic-
modeset are introduced.
drm: add drm_plane_state

Break the mutable state of a plane out into a separate structure.
This makes it easier to have some helpers for plane->set_property()
and for checking for invalid params.  The idea is that individual
drivers can wrap the state struct in their own struct which adds
driver specific parameters, for easy build-up of state across
multiple set_property() calls and for easy atomic commit or roll-
back.

The same should be done for CRTC, encoder, and connector, but this
patch only includes the first part (plane).
drm: convert page_flip to properties

Use atomic properties mechanism for CRTC page_flip.  This by itself
doesn't accomplish anything, but it avoids having multiple code
paths to do the same thing when nuclear-pageflip and atomic-modeset
are introduced.
drm: add drm_crtc_state

Start breaking out the mutable state of the CRTC into it's own
structure.  Plus add _check_state() and _set_property() helpers.
This only moves the state that is related to scanout fb, which
is needed for nuclear-pageflip.  The rest of the mutable state
should be moved from drm_crtc to drm_crtc_state as part of the
atomic-modeset implementation.
drm: Ignore blob propertys in drm_property_change_is_valid()

In case of a blob property drm_property_change_is_valid() can't
tell whether the change is valid or not. So just return true
for all blob properties, and leave it up to someone else to
check it.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
drm: Add restore_fbdev_mode() hook to drm_fb_helper

Add an optional driver specific restore_fbdev_mode() hook to
drm_fb_helper. If the driver doesn't provide the hook,
drm_fb_helper_restore_fbdev_mode() is called directly as before.

In this hook the driver can disable additional planes, cursors etc.
that shouldn't be visible while fbdev is in control.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
drm: Add drm_flip helper

The drm_flip mechanism can be used to implement robust page flipping
support, and also to synchronize the flips on multiple hardware
scanout engines (eg. CRTCs and overlays).

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
drm: Add mode_blob and connector_ids_blob to drm_crtc

These will be used by standard properties MODE and CONNECTOR_IDS.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
drm: Allow drm_mode_object_find() to look up an object of any type

To avoid having to pass object types from userspace for atomic mode
setting ioctl, allow drm_mode_object_find() to look up an object of any
type. This will only work as long as the all object types share the ID
space.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
drm: Refactor object property check code

Refactor the code to check whether an object has a specific property
to a new function.

v1: original
v2: rebase on atomic -- Rob Clark

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
drm: Atomic modeset ioctl

The atomic modeset ioctl cna be used to push any number of new values
for object properties. The driver can then check the full device
configuration as single unit, and try to apply the changes atomically.

The ioctl simply takes a list of object IDs and property IDs and their
values. For setting values to blob properties, the property value
indicates the length of the data, and the actual data is passed via
another blob pointer.

The caller can demand non-blocking operation from the ioctl, and if the
driver can't satisfy that requirement an error will be returned.

The caller can also request to receive asynchronous completion events
after the operation has reached the hardware. An event is sent for each
object specified by the caller, whether or not the actual state of
that object changed. Each event also carries a framebuffer ID, which
indicates to user space that the specified object is no longer
accessing that framebuffer.

TODO: detailed error reporting?

v1: original
v2: rebase on uapi changes, and drm state structs.. -- Rob Clark

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>