platform/kernel/linux-3.10.git
9 years agodma-buf: use reservation objects
Maarten Lankhorst [Tue, 1 Jul 2014 10:57:26 +0000 (12:57 +0200)]
dma-buf: use reservation objects

This allows reservation objects to be used in dma-buf. it's required
for implementing polling support on the fences that belong to a dma-buf.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Mauro Carvalho Chehab <m.chehab@samsung.com> #drivers/media/v4l2-core/
Acked-by: Thomas Hellstrom <thellstrom@vmware.com> #drivers/gpu/drm/ttm
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> #drivers/gpu/drm/armada/
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Conflicts:
drivers/gpu/drm/armada/armada_gem.c
drivers/gpu/drm/drm_prime.c
drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
drivers/gpu/drm/i915/i915_gem_dmabuf.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/nouveau/nouveau_gem.h
drivers/gpu/drm/nouveau/nouveau_prime.c
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/tegra/gem.c
drivers/gpu/drm/ttm/ttm_object.c
drivers/staging/android/ion/ion.c

Change-Id: I44fbb1f41500deaf9067eb5d7e1c6ed758231d69

9 years agodrm/prime: double lock typo
Dan Carpenter [Fri, 23 Aug 2013 20:46:02 +0000 (23:46 +0300)]
drm/prime: double lock typo

There is a typo so deadlocks on error instead of unlocking.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@gmail.com>
9 years agodrm/prime: Always add exported buffers to the handle cache
Daniel Vetter [Wed, 14 Aug 2013 22:02:49 +0000 (00:02 +0200)]
drm/prime: Always add exported buffers to the handle cache

... not only when the dma-buf is freshly created. In contrived
examples someone else could have exported/imported the dma-buf already
and handed us the gem object with a flink name. If such on object gets
reexported as a dma_buf we won't have it in the handle cache already,
which breaks the guarantee that for dma-buf imports we always hand
back an existing handle if there is one.

This is exercised by igt/prime_self_import/with_one_bo_two_files

Now if we extend the locked sections just a notch more we can also
plug th racy buf/handle cache setup in handle_to_fd:

If evil userspace races a concurrent gem close against a prime export
operation we can end up tearing down the gem handle before the dma buf
handle cache is set up. When handle_to_fd gets around to adding the
handle to the cache there will be no one left to clean it up,
effectily leaking the bo (and the dma-buf, since the handle cache
holds a ref on the dma-buf):

Thread A Thread B

handle_to_fd:

lookup gem object from handle
creates new dma_buf

gem_close on the same handle
obj->dma_buf is set, but file priv buf
handle cache has no entry

obj->handle_count drops to 0

drm_prime_add_buf_handle sets up the handle cache

-> We have a dma-buf reference in the handle cache, but since the
handle_count of the gem object already dropped to 0 no on will clean
it up. When closing the drm device fd we'll hit the WARN_ON in
drm_prime_destroy_file_private.

The important change is to extend the critical section of the
filp->prime.lock to cover the gem handle lookup. This serializes with
a concurrent gem handle close.

This leak is exercised by igt/prime_self_import/export-vs-gem_close-race

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: make drm_prime_lookup_buf_handle static
Daniel Vetter [Wed, 14 Aug 2013 22:02:48 +0000 (00:02 +0200)]
drm/prime: make drm_prime_lookup_buf_handle static

... and move it to the top of the function to avoid a forward
declaration.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: proper locking+refcounting for obj->dma_buf link
Daniel Vetter [Wed, 14 Aug 2013 22:02:46 +0000 (00:02 +0200)]
drm/prime: proper locking+refcounting for obj->dma_buf link

The export dma-buf cache is semantically similar to an flink name. So
semantically it makes sense to treat it the same and remove the name
(i.e. the dma_buf pointer) and its references when the last gem handle
disappears.

Again we need to be careful, but double so: Not just could someone
race and export with a gem close ioctl (so we need to recheck
obj->handle_count again when assigning the new name), but multiple
exports can also race against each another. This is prevented by
holding the dev->object_name_lock across the entire section which
touches obj->dma_buf.

With the new scheme we also need to reinstate the obj->dma_buf link at
import time (in case the only reference userspace has held in-between
was through the dma-buf fd and not through any native gem handle). For
simplicity we don't check whether it's a native object but
unconditionally set up that link - with the new scheme of removing the
obj->dma_buf reference when the last handle disappears we can do that.

To make it clear that this is not just for exported buffers anymore
als rename it from export_dma_buf to dma_buf.

To make sure that now one can race a fd_to_handle or handle_to_fd with
gem_close we use the same tricks as in flink of extending the
dev->object_name_locking critical section. With this change we finally
have a guaranteed 1:1 relationship (at least for native objects)
between gem objects and dma-bufs, even accounting for races (which can
happen since the dma-buf itself holds a reference while in-flight).

This prevent igt/prime_self_import/export-vs-gem_close-race from
Oopsing the kernel. There is still a leak though since the per-file
priv dma-buf/handle cache handling is racy. That will be fixed in a
later patch.

v2: Remove the bogus dma_buf_put from the export_and_register_object
failure path if we've raced with the handle count dropping to 0.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Conflicts:
drivers/gpu/drm/drm_gem.c

Change-Id: I915b0e73cedffa0ba358cf00510e19dccfcb4703

9 years agodrm/prime: clarify logic a bit in drm_gem_prime_fd_to_handle
Daniel Vetter [Wed, 14 Aug 2013 22:02:43 +0000 (00:02 +0200)]
drm/prime: clarify logic a bit in drm_gem_prime_fd_to_handle

if (!ret) implies that ret == 0, so no need to clear it again. And
explicitly check for ret == 0 to indicate that we're checking an errno
integer.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: shrink critical section protected by prime lock
Daniel Vetter [Wed, 14 Aug 2013 22:02:42 +0000 (00:02 +0200)]
drm/prime: shrink critical section protected by prime lock

When exporting a gem object as a dma-buf the critical section for the
per-fd prime lock is just the adding (and in case of errors, removing)
of the handle to the per-fd lookup cache.

So restrict the critical section to just that part of the function.

This simplifies later reordering.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: use proper pointer in drm_gem_prime_handle_to_fd
Daniel Vetter [Wed, 14 Aug 2013 22:02:41 +0000 (00:02 +0200)]
drm/prime: use proper pointer in drm_gem_prime_handle_to_fd

Part of the function uses the properly-typed dmabuf variable, the
other an untyped void *buf. Kill the later.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: fix error path in drm_gem_prime_fd_to_handle
Daniel Vetter [Wed, 14 Aug 2013 22:02:38 +0000 (00:02 +0200)]
drm/prime: fix error path in drm_gem_prime_fd_to_handle

handle_unreference only clears up the obj->name and the reference,
but would leave a dangling handle in the idr. The right thing
to do is to call handle_delete.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: remove cargo-cult locking from map_sg helper
Daniel Vetter [Wed, 14 Aug 2013 22:02:32 +0000 (00:02 +0200)]
drm/prime: remove cargo-cult locking from map_sg helper

I've checked both implementations (radeon/nouveau) and they both grab
the page array from ttm simply by dereferencing it and then wrapping
it up with drm_prime_pages_to_sg in the callback and map it with
dma_map_sg (in the helper).

Only the grabbing of the underlying page array is anything we need to
be concerned about, and either those pages are pinned independently,
or we're screwed no matter what.

And indeed, nouveau/radeon pin the backing storage in their
attach/detach functions.

Since I've created this patch cma prime support for dma_buf was added.
drm_gem_cma_prime_get_sg_table only calls kzalloc and the creates&maps
the sg table with dma_get_sgtable. It doesn't touch any gem object
state otherwise. So the cma helpers also look safe.

The only thing we might claim it does is prevent concurrent mapping of
dma_buf attachments. But a) that's not allowed and b) the current code
is racy already since it checks whether the sg mapping exists _before_
grabbing the lock.

So the dev->struct_mutex locking here does absolutely nothing useful,
but only distracts. Remove it.

This should also help Maarten's work to eventually pin the backing
storage more dynamically by preventing locking inversions around
dev->struct_mutex.

v2: Add analysis for recently added cma helper prime code.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm: add mmap function to prime helpers
Joonyoung Shim [Fri, 28 Jun 2013 05:24:53 +0000 (14:24 +0900)]
drm: add mmap function to prime helpers

This adds to call low-level mmap() from prime helpers.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: fix sgt NULL checking
Joonyoung Shim [Thu, 4 Jul 2013 07:19:12 +0000 (16:19 +0900)]
drm/prime: fix sgt NULL checking

The drm_gem_map_detach() can be called with sgt is NULL.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: fix up handle_to_fd ioctl return value
Daniel Vetter [Tue, 2 Jul 2013 07:18:39 +0000 (09:18 +0200)]
drm/prime: fix up handle_to_fd ioctl return value

In

commit da34242e5e0638312130f5bd5d2d277afbc6f806
Author: YoungJun Cho <yj44.cho@samsung.com>
Date:   Wed Jun 26 10:21:42 2013 +0900

    drm/prime: add return check for dma_buf_fd

the failure case handling was fixed up. But in the case when we
already had the buffer exported it changed the return value:
Previously we've return 0 on success, now we return the fd.

This ABI change has been caught by i-g-t/prime_self_import/with_one_bo.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66436
Cc: YoungJun Cho <yj44.cho@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Tested-by: lu hua <huax.lu@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: add return check for dma_buf_fd
YoungJun Cho [Wed, 26 Jun 2013 01:21:42 +0000 (10:21 +0900)]
drm/prime: add return check for dma_buf_fd

The dma_buf_fd() can return error when it fails to prepare fd,
so the dma_buf needs to be put.

Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: reorder drm_prime_add_buf_handle and remove prototype
Seung-Woo Kim [Wed, 26 Jun 2013 01:21:41 +0000 (10:21 +0900)]
drm/prime: reorder drm_prime_add_buf_handle and remove prototype

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: fix to put an exported dma_buf for adding handle failure
YoungJun Cho [Wed, 26 Jun 2013 01:21:40 +0000 (10:21 +0900)]
drm/prime: fix to put an exported dma_buf for adding handle failure

When drm_prime_add_buf_handle() returns failure for an exported
dma_buf, the dma_buf was already allocated and its refcount was
increased, so it needs to be put.

Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: support to cache mapping
Joonyoung Shim [Wed, 19 Jun 2013 06:03:05 +0000 (15:03 +0900)]
drm/prime: support to cache mapping

The drm prime also can support it like GEM CMA supports to cache
mapping. It doesn't allow multiple mappings for one attachment.

[airlied: rebased on top of other prime changes]
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: replace NULL with error value in drm_prime_pages_to_sg
YoungJun Cho [Mon, 24 Jun 2013 07:40:53 +0000 (16:40 +0900)]
drm/prime: replace NULL with error value in drm_prime_pages_to_sg

Instead of NULL, error value is casted with ERR_PTR() for
drm_prime_pages_to_sg() and IS_ERR_OR_NULL() macro is replaced
with IS_ERR() macro for drm_gem_map_dma_buf().

Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm/prime: fix to check return of dma_map_sg in prime helper
YoungJun Cho [Mon, 24 Jun 2013 06:34:21 +0000 (15:34 +0900)]
drm/prime: fix to check return of dma_map_sg in prime helper

The dma_map_sg(), in map_dma_buf callback operation of prime helper,
can return 0 when it fails to map, so it needs to release related
resources.

Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agodrm: move pinning/unpinning to buffer attach
Maarten Lankhorst [Tue, 9 Apr 2013 07:52:54 +0000 (09:52 +0200)]
drm: move pinning/unpinning to buffer attach

This allows importing bo's to own device to work without requiring that the buffer is pinned in GART.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Conflicts:
drivers/gpu/drm/drm_prime.c

Change-Id: I17dbe44549acdf570e155d11370752b0b4ab7919

9 years agodrm: add unpin function to prime helpers
Maarten Lankhorst [Tue, 9 Apr 2013 07:18:44 +0000 (09:18 +0200)]
drm: add unpin function to prime helpers

Prevents buffers from being pinned forever.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Conflicts:
drivers/gpu/drm/drm_prime.c

Change-Id: I220c7924a9b08a13646fcc43c80cd9c031dd2d79

9 years agoseqno-fence: Hardware dma-buf implementation of fencing (v6)
Maarten Lankhorst [Tue, 1 Jul 2014 10:57:20 +0000 (12:57 +0200)]
seqno-fence: Hardware dma-buf implementation of fencing (v6)

This type of fence can be used with hardware synchronization for simple
hardware that can block execution until the condition
(dma_buf[offset] - value) >= 0 has been met when WAIT_GEQUAL is used,
or (dma_buf[offset] != 0) has been met when WAIT_NONZERO is set.

A software fallback still has to be provided in case the fence is used
with a device that doesn't support this mechanism. It is useful to expose
this for graphics cards that have an op to support this.

Some cards like i915 can export those, but don't have an option to wait,
so they need the software fallback.

I extended the original patch by Rob Clark.

v1: Original
v2: Renamed from bikeshed to seqno, moved into dma-fence.c since
    not much was left of the file. Lots of documentation added.
v3: Use fence_ops instead of custom callbacks. Moved to own file
    to avoid circular dependency between dma-buf.h and fence.h
v4: Add spinlock pointer to seqno_fence_init
v5: Add condition member to allow wait for != 0.
    Fix small style errors pointed out by checkpatch.
v6: Move to a separate file. Fix up api changes in fences.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Reviewed-by: Rob Clark <robdclark@gmail.com> #v4
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agofence: dma-buf cross-device synchronization (v18)
Maarten Lankhorst [Tue, 1 Jul 2014 10:57:14 +0000 (12:57 +0200)]
fence: dma-buf cross-device synchronization (v18)

A fence can be attached to a buffer which is being filled or consumed
by hw, to allow userspace to pass the buffer without waiting to another
device.  For example, userspace can call page_flip ioctl to display the
next frame of graphics after kicking the GPU but while the GPU is still
rendering.  The display device sharing the buffer with the GPU would
attach a callback to get notified when the GPU's rendering-complete IRQ
fires, to update the scan-out address of the display, without having to
wake up userspace.

A driver must allocate a fence context for each execution ring that can
run in parallel. The function for this takes an argument with how many
contexts to allocate:
  + fence_context_alloc()

A fence is transient, one-shot deal.  It is allocated and attached
to one or more dma-buf's.  When the one that attached it is done, with
the pending operation, it can signal the fence:
  + fence_signal()

To have a rough approximation whether a fence is fired, call:
  + fence_is_signaled()

The dma-buf-mgr handles tracking, and waiting on, the fences associated
with a dma-buf.

The one pending on the fence can add an async callback:
  + fence_add_callback()

The callback can optionally be cancelled with:
  + fence_remove_callback()

To wait synchronously, optionally with a timeout:
  + fence_wait()
  + fence_wait_timeout()

When emitting a fence, call:
  + trace_fence_emit()

To annotate that a fence is blocking on another fence, call:
  + trace_fence_annotate_wait_on(fence, on_fence)

A default software-only implementation is provided, which can be used
by drivers attaching a fence to a buffer when they have no other means
for hw sync.  But a memory backed fence is also envisioned, because it
is common that GPU's can write to, or poll on some memory location for
synchronization.  For example:

  fence = custom_get_fence(...);
  if ((seqno_fence = to_seqno_fence(fence)) != NULL) {
    dma_buf *fence_buf = seqno_fence->sync_buf;
    get_dma_buf(fence_buf);

    ... tell the hw the memory location to wait ...
    custom_wait_on(fence_buf, seqno_fence->seqno_ofs, fence->seqno);
  } else {
    /* fall-back to sw sync * /
    fence_add_callback(fence, my_cb);
  }

On SoC platforms, if some other hw mechanism is provided for synchronizing
between IP blocks, it could be supported as an alternate implementation
with it's own fence ops in a similar way.

enable_signaling callback is used to provide sw signaling in case a cpu
waiter is requested or no compatible hardware signaling could be used.

The intention is to provide a userspace interface (presumably via eventfd)
later, to be used in conjunction with dma-buf's mmap support for sw access
to buffers (or for userspace apps that would prefer to do their own
synchronization).

v1: Original
v2: After discussion w/ danvet and mlankhorst on #dri-devel, we decided
    that dma-fence didn't need to care about the sw->hw signaling path
    (it can be handled same as sw->sw case), and therefore the fence->ops
    can be simplified and more handled in the core.  So remove the signal,
    add_callback, cancel_callback, and wait ops, and replace with a simple
    enable_signaling() op which can be used to inform a fence supporting
    hw->hw signaling that one or more devices which do not support hw
    signaling are waiting (and therefore it should enable an irq or do
    whatever is necessary in order that the CPU is notified when the
    fence is passed).
v3: Fix locking fail in attach_fence() and get_fence()
v4: Remove tie-in w/ dma-buf..  after discussion w/ danvet and mlankorst
    we decided that we need to be able to attach one fence to N dma-buf's,
    so using the list_head in dma-fence struct would be problematic.
v5: [ Maarten Lankhorst ] Updated for dma-bikeshed-fence and dma-buf-manager.
v6: [ Maarten Lankhorst ] I removed dma_fence_cancel_callback and some comments
    about checking if fence fired or not. This is broken by design.
    waitqueue_active during destruction is now fatal, since the signaller
    should be holding a reference in enable_signalling until it signalled
    the fence. Pass the original dma_fence_cb along, and call __remove_wait
    in the dma_fence_callback handler, so that no cleanup needs to be
    performed.
v7: [ Maarten Lankhorst ] Set cb->func and only enable sw signaling if
    fence wasn't signaled yet, for example for hardware fences that may
    choose to signal blindly.
v8: [ Maarten Lankhorst ] Tons of tiny fixes, moved __dma_fence_init to
    header and fixed include mess. dma-fence.h now includes dma-buf.h
    All members are now initialized, so kmalloc can be used for
    allocating a dma-fence. More documentation added.
v9: Change compiler bitfields to flags, change return type of
    enable_signaling to bool. Rework dma_fence_wait. Added
    dma_fence_is_signaled and dma_fence_wait_timeout.
    s/dma// and change exports to non GPL. Added fence_is_signaled and
    fence_enable_sw_signaling calls, add ability to override default
    wait operation.
v10: remove event_queue, use a custom list, export try_to_wake_up from
    scheduler. Remove fence lock and use a global spinlock instead,
    this should hopefully remove all the locking headaches I was having
    on trying to implement this. enable_signaling is called with this
    lock held.
v11:
    Use atomic ops for flags, lifting the need for some spin_lock_irqsaves.
    However I kept the guarantee that after fence_signal returns, it is
    guaranteed that enable_signaling has either been called to completion,
    or will not be called any more.

    Add contexts and seqno to base fence implementation. This allows you
    to wait for less fences, by testing for seqno + signaled, and then only
    wait on the later fence.

    Add FENCE_TRACE, FENCE_WARN, and FENCE_ERR. This makes debugging easier.
    An CONFIG_DEBUG_FENCE will be added to turn off the FENCE_TRACE
    spam, and another runtime option can turn it off at runtime.
v12:
    Add CONFIG_FENCE_TRACE. Add missing documentation for the fence->context
    and fence->seqno members.
v13:
    Fixup CONFIG_FENCE_TRACE kconfig description.
    Move fence_context_alloc to fence.
    Simplify fence_later.
    Kill priv member to fence_cb.
v14:
    Remove priv argument from fence_add_callback, oops!
v15:
    Remove priv from documentation.
    Explicitly include linux/atomic.h.
v16:
    Add trace events.
    Import changes required by android syncpoints.
v17:
    Use wake_up_state instead of try_to_wake_up. (Colin Cross)
    Fix up commit description for seqno_fence. (Rob Clark)
v18:
    Rename release_fence to fence_release.
    Move to drivers/dma-buf/.
    Rename __fence_is_signaled and __fence_signal to *_locked.
    Rename __fence_init to fence_init.
    Make fence_default_wait return a signed long, and fix wait ops too.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com> #use smp_mb__before_atomic()
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Conflicts:
drivers/base/Kconfig

Change-Id: Ie62c8c33a0cb7ca3df596f47ef328c33c4468139

9 years agodma-buf: move to drivers/dma-buf
Maarten Lankhorst [Tue, 1 Jul 2014 10:57:08 +0000 (12:57 +0200)]
dma-buf: move to drivers/dma-buf

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agodma-buf: update debugfs output
Sumit Semwal [Mon, 3 Feb 2014 09:39:12 +0000 (15:09 +0530)]
dma-buf: update debugfs output

Russell King observed 'wierd' looking output from debugfs, and also suggested
better ways of getting device names (use KBUILD_MODNAME, dev_name())

This patch addresses these issues to make the debugfs output correct and better
looking.

While at it, replace seq_printf with seq_puts to remove the checkpatch.pl
warnings.

Reported-by: Russell King - ARM Linux <linux@arm.linux.org.uk>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
9 years agoreservation: cross-device reservation support, v4
Maarten Lankhorst [Thu, 27 Jun 2013 11:48:16 +0000 (13:48 +0200)]
reservation: cross-device reservation support, v4

This adds support for a generic reservations framework that can be
hooked up to ttm and dma-buf and allows easy sharing of reservations
across devices.

The idea is that a dma-buf and ttm object both will get a pointer
to a struct reservation_object, which has to be reserved before
anything is done with the contents of the dma-buf.

Changes since v1:
 - Fix locking issue in ticket_reserve, which could cause mutex_unlock
   to be called too many times.
Changes since v2:
 - All fence related calls and members have been taken out for now,
   what's left is the bare minimum to be useful for ttm locking conversion.
Changes since v3:
 - Removed helper functions too. The documentation has an example
   implementation for locking. With the move to ww_mutex there is no
   need to have much logic any more.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agoRevert "dmabuf-sync: add buffer synchronization framework"
Chanho Park [Tue, 19 Aug 2014 12:40:44 +0000 (21:40 +0900)]
Revert "dmabuf-sync: add buffer synchronization framework"

This reverts commit 7a9958fedb90ef4000b6461d77a5c6dfd795c1c1.

9 years agoRevert "dmabuf-sync: add cache operation feature"
Chanho Park [Tue, 19 Aug 2014 12:40:35 +0000 (21:40 +0900)]
Revert "dmabuf-sync: add cache operation feature"

This reverts commit 22a2b813ad54d967edf9d8117662fea25093f7d0.

9 years agoRevert "dma-buf: add lock callback for fcntl system call."
Chanho Park [Tue, 19 Aug 2014 12:40:27 +0000 (21:40 +0900)]
Revert "dma-buf: add lock callback for fcntl system call."

This reverts commit 30d585606b85e454113b79478b6b6bb1991dd210.

9 years agoRevert "dmabuf-sync: fix sync lock to multiple read"
Chanho Park [Tue, 19 Aug 2014 12:40:19 +0000 (21:40 +0900)]
Revert "dmabuf-sync: fix sync lock to multiple read"

This reverts commit 5c6a3a47e9a5b4286e4219bd70e9917b8ffee414.

9 years agoRevert "dmabuf-sync: remove unnecessary the use of mutex lock."
Chanho Park [Tue, 19 Aug 2014 12:40:12 +0000 (21:40 +0900)]
Revert "dmabuf-sync: remove unnecessary the use of mutex lock."

This reverts commit c75e1e7a03b157842638e55b27f28c41a9a3dc2b.

9 years agoRevert "dmabuf-sync: add private backend callbacks"
Chanho Park [Tue, 19 Aug 2014 12:40:02 +0000 (21:40 +0900)]
Revert "dmabuf-sync: add private backend callbacks"

This reverts commit 5d2749a0ac3be2a3ed43a24a88d821e26097bf1e.

9 years agoRevert "dmabuf-sync: add select system call support."
Chanho Park [Tue, 19 Aug 2014 12:39:54 +0000 (21:39 +0900)]
Revert "dmabuf-sync: add select system call support."

This reverts commit 4439a419906d4fe3d7e5093292bd2f4f4fbfc8c2.

9 years agoRevert "dma-buf: return POLLIN | POLLOUT instead of POLLERR"
Chanho Park [Tue, 19 Aug 2014 12:39:46 +0000 (21:39 +0900)]
Revert "dma-buf: return POLLIN | POLLOUT instead of POLLERR"

This reverts commit 494805a828f760a3b36629875cc123cc1e396aa8.

9 years agoRevert "dmabuf-sync: update it to patch v8"
Chanho Park [Tue, 19 Aug 2014 12:39:36 +0000 (21:39 +0900)]
Revert "dmabuf-sync: update it to patch v8"

This reverts commit cf7e07ce2d9843105d2ed8f9d30ee66c06d83bb0.

9 years agosensorhub: add sentinel into array to fix out-of-bound memory access 67/30567/2
Seung-Woo Kim [Thu, 20 Nov 2014 08:25:03 +0000 (17:25 +0900)]
sensorhub: add sentinel into array to fix out-of-bound memory access

Without sentinel, of_match_node() to array causes out-of-bound
memory access. So this patch adds sentinel into ssp_of_match.

Change-Id: I66d69b10f6e96ceb0a874554249317416c58471d
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
9 years agortc: s5m: Add sentinel into array to fix out-of-bound memory access 66/30566/2
Seung-Woo Kim [Thu, 20 Nov 2014 08:24:19 +0000 (17:24 +0900)]
rtc: s5m: Add sentinel into array to fix out-of-bound memory access

Without sentinel in array of platform_device_id, platform_match()
causes out-of-bound memory access. So this patch adds sentinel into
s5m_rtc_id.

Change-Id: I65af741dd117d017ccf03bd8ad833fa4b165ab9b
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
9 years agoiio: st_gyro: Add sentinel into array to fix out-of-bound memory access 65/30565/2
Seung-Woo Kim [Thu, 20 Nov 2014 07:45:47 +0000 (16:45 +0900)]
iio: st_gyro: Add sentinel into array to fix out-of-bound memory access

Without sentinel, of_match_node() to array causes out-of-bound
memory access. So this patch adds sentinel.

Change-Id: I22a4c117f68bba05acc27e7b4c6ad86471e6cf6d
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
9 years agoARM: EXYNOS: Add sentinel into array to fix out-of-bound memory access 64/30564/2
Seung-Woo Kim [Wed, 19 Nov 2014 04:08:33 +0000 (13:08 +0900)]
ARM: EXYNOS: Add sentinel into array to fix out-of-bound memory access

An array exynos_pinctrl_ids does not have sentinel, but it is used
by of_match_node(). This cause out-of-bound memory access, so this
patch adds sentinel into exynos_pinctrl_ids.

Change-Id: Ic3f5cb4bcc41baa27d92ec7e9386adc4a80b813a
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
9 years agopackaging: update to 3.10.60 v3.10.60-rebase
Chanho Park [Tue, 18 Nov 2014 03:03:39 +0000 (12:03 +0900)]
packaging: update to 3.10.60

Change-Id: Icf9f18a293de098cc93b863a49591660807b51bc
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agodrm/exynos: use irq_flags instead of triggering
Joonyoung Shim [Thu, 30 Oct 2014 04:36:26 +0000 (13:36 +0900)]
drm/exynos: use irq_flags instead of triggering

The drm_handle_vblank should be called whenever be vsync, te interrupt
means vsync on i80 interface.

Change-Id: I620346fc78e02589b398a0aaee74a2eb60579720
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agopackaging: separate modules.img
Chanho Park [Thu, 6 Nov 2014 10:12:52 +0000 (19:12 +0900)]
packaging: separate modules.img

This patch separates modules.img from /boot. We'll add a new partition
for modules.

Change-Id: I50ef63dfebacd389c96d7e012970f1a1e9796125
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agogpu: arm: mali400: fix buile warning
Joonyoung Shim [Thu, 6 Nov 2014 04:45:29 +0000 (13:45 +0900)]
gpu: arm: mali400: fix buile warning

drivers/gpu/arm/mali400/mali/platform/exynos4/exynos4.c: In function ‘mali_platform_init’:
drivers/gpu/arm/mali400/mali/platform/exynos4/exynos4.c:346:2: warning: ignoring return value of ‘regulator_enable’, declared with attribute warn_unused_result [-Wunused-result]
  regulator_enable(mali->vdd_g3d);
  ^

Change-Id: I72d60e94e2f7380fcc7a457cf487368037d30b7a
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agogpu: arm: mali400: add exynos3250 support for R4P0_REL0
Joonyoung Shim [Thu, 6 Nov 2014 04:55:17 +0000 (13:55 +0900)]
gpu: arm: mali400: add exynos3250 support for R4P0_REL0

This is based on drivers/gpu/arm/mali400/mali/platform/exynos4/exynos4.c

Change-Id: Ib030f2463648983f3855d827d022c15ad3a76ab9
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agogpu: arm: mali400: fix warning on booting
Joonyoung Shim [Fri, 1 Aug 2014 09:38:41 +0000 (18:38 +0900)]
gpu: arm: mali400: fix warning on booting

This fixes below warnings.

[    1.461424] ------------[ cut here ]------------
[    1.464524] WARNING: at fs/proc/generic.c:101 __xlate_proc_name+0xa8/0xbc()
[    1.471444] name '/gpu@13000000'
[    1.474651] Modules linked in:
[    1.477678] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.10.39-01649-g6491ddb-dirty #15
[    1.485623] [<c0014224>] (unwind_backtrace+0x0/0xf4) from [<c0011520>] (show_stack+0x10/0x14)
[    1.494120] [<c0011520>] (show_stack+0x10/0x14) from [<c001ff7c>] (warn_slowpath_common+0x54/0x6c)
[    1.503050] [<c001ff7c>] (warn_slowpath_common+0x54/0x6c) from [<c001ffc4>] (warn_slowpath_fmt+0x30/0x40)
[    1.512598] [<c001ffc4>] (warn_slowpath_fmt+0x30/0x40) from [<c010774c>] (__xlate_proc_name+0xa8/0xbc)
[    1.521886] [<c010774c>] (__xlate_proc_name+0xa8/0xbc) from [<c01077ac>] (__proc_create+0x4c/0x100)
[    1.530910] [<c01077ac>] (__proc_create+0x4c/0x100) from [<c0107b18>] (proc_mkdir_data+0x2c/0x68)
[    1.539766] [<c0107b18>] (proc_mkdir_data+0x2c/0x68) from [<c007b72c>] (register_handler_proc+0xd8/0xf0)
[    1.549233] [<c007b72c>] (register_handler_proc+0xd8/0xf0) from [<c0077b38>] (__setup_irq+0x1e4/0x440)
[    1.558525] [<c0077b38>] (__setup_irq+0x1e4/0x440) from [<c0077ec4>] (request_threaded_irq+0xa8/0x128)
[    1.567817] [<c0077ec4>] (request_threaded_irq+0xa8/0x128) from [<c02a6f34>] (_mali_osk_irq_init+0x64/0x124)
[    1.577628] [<c02a6f34>] (_mali_osk_irq_init+0x64/0x124) from [<c02afa58>] (mali_pp_create+0xac/0x23c)
[    1.586899] [<c02afa58>] (mali_pp_create+0xac/0x23c) from [<c02aa94c>] (mali_initialize_subsystems+0x21c/0x7d8)
[    1.596966] [<c02aa94c>] (mali_initialize_subsystems+0x21c/0x7d8) from [<c02ab854>] (mali_probe+0x3c/0x254)
[    1.606697] [<c02ab854>] (mali_probe+0x3c/0x254) from [<c02bd314>] (driver_probe_device+0x88/0x244)
[    1.615715] [<c02bd314>] (driver_probe_device+0x88/0x244) from [<c02bd5a0>] (__driver_attach+0x8c/0x90)
[    1.625089] [<c02bd5a0>] (__driver_attach+0x8c/0x90) from [<c02bb8f0>] (bus_for_each_dev+0x60/0x94)
[    1.634121] [<c02bb8f0>] (bus_for_each_dev+0x60/0x94) from [<c02bcb68>] (bus_add_driver+0x1c0/0x24c)
[    1.643232] [<c02bcb68>] (bus_add_driver+0x1c0/0x24c) from [<c02bdb78>] (driver_register+0x78/0x140)
[    1.652345] [<c02bdb78>] (driver_register+0x78/0x140) from [<c02abaa4>] (mali_module_init+0xc/0x50)
[    1.661370] [<c02abaa4>] (mali_module_init+0xc/0x50) from [<c000870c>] (do_one_initcall+0x108/0x158)
[    1.670505] [<c000870c>] (do_one_initcall+0x108/0x158) from [<c07bec54>] (kernel_init_freeable+0x13c/0x1dc)
[    1.680214] [<c07bec54>] (kernel_init_freeable+0x13c/0x1dc) from [<c05a05bc>] (kernel_init+0xc/0x160)
[    1.689411] [<c05a05bc>] (kernel_init+0xc/0x160) from [<c000df58>] (ret_from_fork+0x14/0x3c)
[    1.697837] ---[ end trace e694d4bb842a349f ]---

Change-Id: Ic2b9ef0388f929e5d028ccd3b10882aecc9c815e
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agogpu: arm: mali400: modify DVFS tables and setting
Joonyoung Shim [Thu, 6 Nov 2014 04:29:27 +0000 (13:29 +0900)]
gpu: arm: mali400: modify DVFS tables and setting

This comes from commit ("local/ARM/MALI400: R4P0_REL0: Clean up codes")
of in-house kernel.

Change-Id: Id835808d157438527d32b3f3cf46108ab8d45fb6
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agogpu: arm: mali400: fix clocks for R4P0_REL0
Joonyoung Shim [Tue, 4 Nov 2014 05:30:54 +0000 (14:30 +0900)]
gpu: arm: mali400: fix clocks for R4P0_REL0

It needs clock setting change by the commit 0a88cf3 ("ARM: dts:
exynos4x12: clean up clock property for gpu node").

Change-Id: I18d40e382c152a1a7c9dcd3077cbc2a83b265485
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agogpu: arm: mali400: use exynos platform of R3P2_REL0 for R4P0_REL0
Joonyoung Shim [Fri, 1 Aug 2014 09:34:10 +0000 (18:34 +0900)]
gpu: arm: mali400: use exynos platform of R3P2_REL0 for R4P0_REL0

It's better R3P2_REL0 exynos platform codes than R4P0_REL0.

Change-Id: Ia97c1b800a209a98a860f533e5617efebcf3e600
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agogpu: arm: mali400: remove unnecessary #if 0 for R4P0_REL0
Joonyoung Shim [Thu, 6 Nov 2014 02:00:02 +0000 (11:00 +0900)]
gpu: arm: mali400: remove unnecessary #if 0 for R4P0_REL0

I don't know why added it.

Change-Id: I60ecbc113d4a9fb1e32971bd249f1fe167b0c2d9
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years agoARM/MALI400: R4P0_REL0: port with exynos common platform
YoungJun Cho [Wed, 11 Jun 2014 01:08:09 +0000 (10:08 +0900)]
ARM/MALI400: R4P0_REL0: port with exynos common platform

This patch ports mali400 r4p0 rel0 with exynos common platform.

Change-Id: I741c2fbd76cbb7177472ea61b40d7fab22a7c081
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
9 years agogpu: arm: Add mali400 r4p0_rel0 version
Joonyoung Shim [Fri, 1 Aug 2014 07:35:19 +0000 (16:35 +0900)]
gpu: arm: Add mali400 r4p0_rel0 version

This comes from in-house kernel.

Change-Id: Ic3f3516e44e71ea9ca2e0b5caa6a9e836ffa599c
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
9 years ago[media] s5p-mfc: Adjust memports handling to MFC v7 needs.
Jacek Anaszewski [Thu, 23 Oct 2014 12:49:42 +0000 (14:49 +0200)]
[media] s5p-mfc: Adjust memports handling to MFC v7 needs.

MFC v7 supports only one memory interface. Adjust memory ports
initialization accordingly.

Change-Id: I56e2c582c41f9ad948dc612b3060688619195b1c
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
9 years ago[media] s5p-mfc: Update driver for v7 firmware
Arun Kumar K [Tue, 9 Jul 2013 04:24:39 +0000 (01:24 -0300)]
[media] s5p-mfc: Update driver for v7 firmware

Firmware version v7 is mostly similar to v6 in terms
of hardware specific controls and commands. So the hardware
specific opr_v6 and cmd_v6 are re-used for v7 also. This patch
updates the v6 files to handle v7 version also.

Change-Id: I137075c6802cfef3aa40cb45413837f18fa969eb
Signed-off-by: Arun Kumar K <arun.kk@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-mfc: Core support for MFC v7
Arun Kumar K [Tue, 9 Jul 2013 04:24:38 +0000 (01:24 -0300)]
[media] s5p-mfc: Core support for MFC v7

Adds variant data and core support for the MFC v7 firmware

Change-Id: I5dc12438d3bfdf6d254f4ced3089e1881d524e0b
Signed-off-by: Arun Kumar K <arun.kk@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-mfc: Add register definition file for MFC v7
Arun Kumar K [Tue, 9 Jul 2013 04:24:37 +0000 (01:24 -0300)]
[media] s5p-mfc: Add register definition file for MFC v7

The patch adds the register definition file for new firmware
version v7 for MFC. New firmware supports VP8 encoding along with
many other features.

Change-Id: I3abf2768fe2a59ec45f6f4a2660c3ccf23f7ca88
Signed-off-by: Arun Kumar K <arun.kk@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-mfc: Rename IS_MFCV6 macro
Arun Kumar K [Tue, 9 Jul 2013 04:24:36 +0000 (01:24 -0300)]
[media] s5p-mfc: Rename IS_MFCV6 macro

The MFC v6 specific code holds good for MFC v7 also as
the v7 version is a superset of v6 and the HW interface
remains more or less similar. This patch renames the macro
IS_MFCV6() to IS_MFCV6_PLUS() so that it can be used
for v7 also.

Change-Id: Ia27f4ed36cc46568bbe9152f13332436f04e106a
Signed-off-by: Arun Kumar K <arun.kk@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoARM: dts: exynos3250-rinato: add MFC codec device node
Jacek Anaszewski [Wed, 22 Oct 2014 08:59:10 +0000 (10:59 +0200)]
ARM: dts: exynos3250-rinato: add MFC codec device node

This patch adds mfc codec device tree node.

Change-Id: I6d4ef65b1c518ddcace691c23aded8e0797193e4
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
9 years agoARM: dts: exynos3250: add MFC codec device node
Jacek Anaszewski [Wed, 22 Oct 2014 08:56:45 +0000 (10:56 +0200)]
ARM: dts: exynos3250: add MFC codec device node

This patch adds mfc codec device tree node and the corresponding IOMMU
device node.

Change-Id: I8ea6b68b92fe035ec947cc5319b0cd1d070764d0
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
9 years ago[media] media: s5p-mfc: rename special clock to sclk_mfc
Marek Szyprowski [Wed, 27 Aug 2014 12:36:28 +0000 (09:36 -0300)]
[media] media: s5p-mfc: rename special clock to sclk_mfc

Commit d19f405a5a8d2ed942b40f8cf7929a5a50d0cc59 ("[media] s5p-mfc: Fix
selective sclk_mfc init") added support for special clock handling
(named "sclk-mfc"). However this clock is not defined yet on any
platform, so before adding it to all Exynos platform, better rename it
to "sclk_mfc" to match the scheme used for all other special clocks on
Exynos platform.

Change-Id: I41f646096e8a82c3cca032e1cc7a70f6d2960059
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-mfc: Fix selective sclk_mfc init
Jacek Anaszewski [Thu, 10 Jul 2014 09:00:39 +0000 (06:00 -0300)]
[media] s5p-mfc: Fix selective sclk_mfc init

fc906b6d "Remove special clock usage in driver" removed
initialization of MFC special clock, arguing that there's
no need to do it explicitly, since it's one of MFC gate clock's
dependencies and gets enabled along with it. However, there's
no promise of keeping this hierarchy across Exynos SoC
releases, therefore this approach fails to provide a stable,
portable solution.

Out of all MFC versions, only v6 doesn't use special clock at all.
For other versions log a message only in case clk_get fails,
as not all the devices with the same MFC version require
initializing the clock explicitly.

Change-Id: Id5ee2696c7b880f45f9744b6bac603dcee9e3dcb
Signed-off-by: Mateusz Zalega <m.zalega@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoRevert "media: s5p-mfc: add to set clock rate"
Jacek Anaszewski [Wed, 5 Nov 2014 15:03:30 +0000 (16:03 +0100)]
Revert "media: s5p-mfc: add to set clock rate"

This reverts commit 2cbd58556a83b417750483de842e1e918de273a3.

Mainline commit d19f405a "Fix selective sclk_mfc init"
solves the issue in a wider scope.

Change-Id: Ib163697c3ae65e30b6e13f6f7170d791d853a6f0
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
9 years ago[media] s5p-jpeg: fix HUF_TBL_EN bit clearing path
Jacek Anaszewski [Mon, 1 Sep 2014 13:05:52 +0000 (10:05 -0300)]
[media] s5p-jpeg: fix HUF_TBL_EN bit clearing path

Use proper bitwise operator while clearing HUF_TBL_EN bit.

Change-Id: Ic78dd26168ffa6124d61f8cb9549339f05cff0d9
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: avoid overwriting JPEG_CNTL register settings
Jacek Anaszewski [Mon, 1 Sep 2014 13:05:51 +0000 (10:05 -0300)]
[media] s5p-jpeg: avoid overwriting JPEG_CNTL register settings

Take into account the JPEG_CNTL register value read before
setting SYS_INT_EN bit field.

Change-Id: I76b622f01be6747ea2ad95e63fb305377b0f540b
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: remove stray call to readl
Jacek Anaszewski [Mon, 1 Sep 2014 13:05:50 +0000 (10:05 -0300)]
[media] s5p-jpeg: remove stray call to readl

There is no need to read INT_EN_REG before enabling interrupts.

Change-Id: Idebb919754df34fb2bfa53982a4ea0a7be3f1fe7
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Avoid assigning readl result
Jacek Anaszewski [Mon, 1 Sep 2014 13:05:49 +0000 (10:05 -0300)]
[media] s5p-jpeg: Avoid assigning readl result

Avoid gcc warning when -Wunused-but-set-variable is enabled.
The readl return value need not to be assigned to any variable
as the reading itself is just a part of a sequence required
for clearing the interrupt flag.

Change-Id: I09b9ec4a724ae46eca0491d81003cd0c0f714ad2
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Get rid of a warning
Mauro Carvalho Chehab [Tue, 26 Aug 2014 14:23:58 +0000 (11:23 -0300)]
[media] s5p-jpeg: Get rid of a warning

drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c: In function 's5p_jpeg_clear_int':
drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c:327:16: warning: variable 'reg' set but not used [-Wunused-but-set-variable]
  unsigned long reg;
                ^

Change-Id: I51401e5bc719fd8788933acf2181daa5b82bed38
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoARM: dts: exynos3250: add JPEG codec device node
Jacek Anaszewski [Tue, 21 Oct 2014 12:57:59 +0000 (14:57 +0200)]
ARM: dts: exynos3250: add JPEG codec device node

Change-Id: I1c4d9de9c3c476356d71d3c219d7313c9492fddc
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
9 years agos5p-jpeg: Avoid -Wuninitialized warning in s5p_jpeg_parse_hdr
Jacek Anaszewski [Fri, 10 Oct 2014 08:43:14 +0000 (10:43 +0200)]
s5p-jpeg: Avoid -Wuninitialized warning in s5p_jpeg_parse_hdr

Initialize components variable in order to avoid
the possibility of using it uninitialized.

Change-Id: Ib1c9c11d1fc94aa5aa4e28f24819b32d6dd1ee5c
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
9 years ago[media] s5p-jpeg: add chroma subsampling adjustment for Exynos3250
Jacek Anaszewski [Fri, 11 Jul 2014 15:19:48 +0000 (12:19 -0300)]
[media] s5p-jpeg: add chroma subsampling adjustment for Exynos3250

Take into account limitations specific to the Exynos3250 SoC,
regarding setting the chroma subsampling control's value.

Change-Id: I5f106163efb3961b4684c111cee7527bfe5454f6
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Prevent erroneous downscaling for Exynos3250 SoC
Jacek Anaszewski [Fri, 11 Jul 2014 15:19:47 +0000 (12:19 -0300)]
[media] s5p-jpeg: Prevent erroneous downscaling for Exynos3250 SoC

JPEG codec on Exynos3250 SoC produces broken raw image if a JPEG
image is decoded to YUV420 format and downscaled by a factor
greater than 2. Prevent this by asserting downscale ratio to 2.

Change-Id: Ib415579d25a4b076a1879b3108c3a08b3dcd4ab8
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Assure proper crop rectangle initialization
Jacek Anaszewski [Fri, 11 Jul 2014 15:19:46 +0000 (12:19 -0300)]
[media] s5p-jpeg: Assure proper crop rectangle initialization

Assure proper crop_rect initialization in case the user space
doesn't call S_SELECTION ioctl.

Change-Id: I0ad267a1f3480efa83e78e714fb4ba94e08494be
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: fix g_selection op
Jacek Anaszewski [Fri, 11 Jul 2014 15:19:45 +0000 (12:19 -0300)]
[media] s5p-jpeg: fix g_selection op

V4L2_SEL_TGT_COMPOSE_DEFAULT switch case should select whole
available area of the image and V4L2_SEL_TGT_COMPOSE
should apply user settings.

Change-Id: I32ea7a72f86a52b001a251782f821d0772f42e54
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Adjust jpeg_bound_align_image to Exynos3250 needs
Jacek Anaszewski [Fri, 11 Jul 2014 15:19:44 +0000 (12:19 -0300)]
[media] s5p-jpeg: Adjust jpeg_bound_align_image to Exynos3250 needs

The jpeg_bound_align_image function needs to know the context
in which it is called, as it needs to align image dimensions in
a slight different manner for Exynos3250, which crops pixels for
specific values in case the format is RGB.

Change-Id: I697ec8aa1bf602695618d3bc373031aa8e06d59a
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: return error immediately after get_byte fails
Jacek Anaszewski [Fri, 11 Jul 2014 15:19:43 +0000 (12:19 -0300)]
[media] s5p-jpeg: return error immediately after get_byte fails

When parsing JPEG header s5p_jpeg_parse_hdr function
should return immediately in case there was an error
while reading a byte.

Change-Id: I82429c1e2878f27276594da1069b30c40b83aadb
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Add support for Exynos3250 SoC
Jacek Anaszewski [Fri, 11 Jul 2014 15:19:42 +0000 (12:19 -0300)]
[media] s5p-jpeg: Add support for Exynos3250 SoC

This patch adds support for jpeg codec on Exynos3250 SoC to
the s5p-jpeg driver. Supported raw formats are: YUYV, YVYU, UYVY,
VYUY, RGB565, RGB565X, RGB32, NV12, NV21. The support includes
also scaling and cropping features.

Change-Id: I16bc7135f97ef7cf029dff7e8f7c59cf0fea8daf
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Document sclk-jpeg clock for Exynos3250 SoC
Jacek Anaszewski [Fri, 11 Jul 2014 15:19:49 +0000 (12:19 -0300)]
[media] s5p-jpeg: Document sclk-jpeg clock for Exynos3250 SoC

JPEG IP on Exynos3250 SoC requires enabling two clock gates
for its operation. This patch documents this requirement.

Change-Id: If6670c5b841d5a4fc7a9e47db5a234fa60e1b92e
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Fix NV12 format entry related to S5C2120 SoC
Jacek Anaszewski [Thu, 10 Apr 2014 07:32:18 +0000 (04:32 -0300)]
[media] s5p-jpeg: Fix NV12 format entry related to S5C2120 SoC

S5PC210 SoC doesn't support encoding NV12 raw images. Remove
relavant flag from the respective entry in the sjpeg_formats
array.

Change-Id: Ibe70ae070afab4dcf380c41dc36a2a276b8f78f3
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Fix build break when CONFIG_OF is undefined
Jacek Anaszewski [Thu, 10 Apr 2014 07:32:14 +0000 (04:32 -0300)]
[media] s5p-jpeg: Fix build break when CONFIG_OF is undefined

This patch fixes build break occurring when there is no support
for Device Tree turned on in the kernel configuration. In such
case only the driver variant for S5PC210 SoC will be available.

Change-Id: Ic747bc56bbc5c624e9c21c9e68b62be806a18f60
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Prevent JPEG 4:2:0 > YUV 4:2:0 decompression
Jacek Anaszewski [Thu, 10 Apr 2014 07:32:17 +0000 (04:32 -0300)]
[media] s5p-jpeg: Prevent JPEG 4:2:0 > YUV 4:2:0 decompression

Prevent decompression of a JPEG 4:2:0 with odd width to
the YUV 4:2:0 compliant formats for Exynos4x12 SoCs and
adjust capture format to RGB565 in such a case. This is
required because the configuration would produce a raw
image with broken luma component.

Change-Id: Id4bf3ddca3fed89ee1a2db56c342661717e3db2e
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Fix sysmmu page fault
Jacek Anaszewski [Thu, 10 Apr 2014 07:32:16 +0000 (04:32 -0300)]
[media] s5p-jpeg: Fix sysmmu page fault

This patch fixes jpeg sysmmu page fault on Exynos4x12 SoCs.
During encoding Exynos4x12 SoCs access wider memory area
than it results from Image_x and Image_y values written to
the JPEG_IMAGE_SIZE register. In order to avoid sysmmu page
fault apply proper output buffer size alignment.

Change-Id: I39f40d68b10c29d0085cbd0ef986b9f311fd7ba8
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: g_selection callback should always succeed
Jacek Anaszewski [Thu, 10 Apr 2014 07:32:15 +0000 (04:32 -0300)]
[media] s5p-jpeg: g_selection callback should always succeed

Remove erroneous guard preventing successful execution of
g_selection callback in case the driver variant is different
from SJPEG_S5P.

Change-Id: I4db87c0abfc0fd15ec8ae137192e522136ecec1b
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Add m2m_ops field to the s5p_jpeg_variant structure
Jacek Anaszewski [Thu, 10 Apr 2014 07:32:13 +0000 (04:32 -0300)]
[media] s5p-jpeg: Add m2m_ops field to the s5p_jpeg_variant structure

Simplify the code by adding m2m_ops field to the
s5p_jpeg_variant structure which allows to avoid
"if" statement in the s5p_jpeg_probe function.

Change-Id: I3ae0bc8e5af4ee26aa13f136255342eb3c50e89e
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Perform fourcc downgrade only for Exynos4x12 SoCs
Jacek Anaszewski [Thu, 10 Apr 2014 07:32:12 +0000 (04:32 -0300)]
[media] s5p-jpeg: Perform fourcc downgrade only for Exynos4x12 SoCs

Change the driver variant check from "is not S5PC210"
to "is Exynos4" while checking whether YUV format needs
to be downgraded in order to prevent upsampling which
is not supported by Exynos4 SoCs family.

Change-Id: Iedda710f6e6ea62555e2bde9481f7e789eb36fb9
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Add fmt_ver_flag field to the s5p_jpeg_variant structure
Jacek Anaszewski [Thu, 10 Apr 2014 07:32:11 +0000 (04:32 -0300)]
[media] s5p-jpeg: Add fmt_ver_flag field to the s5p_jpeg_variant structure

Simplify the code by adding fmt_ver_flag field
to the s5p_jpeg_variant structure which allows
to avoid "if" statement in the s5p_jpeg_find_format
function.

Change-Id: I0f5610b5450a9d29ec1fc09f2837f712b76ac909
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Fix broken indentation in jpeg-regs.h
Jacek Anaszewski [Thu, 16 Jan 2014 11:26:32 +0000 (08:26 -0300)]
[media] s5p-jpeg: Fix broken indentation in jpeg-regs.h

Change-Id: I5a0ac834689e86400078421f033b5b1d07eb3e05
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Fix wrong NV12 format parameters
Jacek Anaszewski [Thu, 16 Jan 2014 11:26:33 +0000 (08:26 -0300)]
[media] s5p-jpeg: Fix wrong NV12 format parameters

NV12 format entries in the sjpeg_formats array had wrong
colplanes, depth and v_align values.

Change-Id: I1c5813862046fa9b1bf0a327721a05e630b39e1c
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs
Jacek Anaszewski [Wed, 18 Dec 2013 14:14:00 +0000 (11:14 -0300)]
[media] s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs

Whereas S5PC210 device produces decoded JPEG subsampling values that
map on V4L2_JPEG_CHROMA_SUBSAMPLNG values, the Exynos4x12 device
doesn't. This patch adds helper function s5p_jpeg_to_user_subsampling,
which performs suitable translation.

Change-Id: Ide93376b0fd413cb769a562ebe727ee706391dff
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Ensure setting correct value of the chroma subsampling control
Jacek Anaszewski [Thu, 21 Nov 2013 16:34:01 +0000 (13:34 -0300)]
[media] s5p-jpeg: Ensure setting correct value of the chroma subsampling control

Exynos4x12 has limitations regarding setting chroma subsampling
of an output JPEG image. It cannot be lower than the subsampling
of the raw source image. Also in case of V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY
option the source image fourcc has to be V4L2_PIX_FMT_GREY.
This patch implements try_ctrl callback containing mechanism that
prevents setting invalid value of the V4L2_CID_JPEG_CHROMA_SUBSAMPLING
control.

Change-Id: Ic0f08644f21fb167e049ac60a7d49b14d5e0f058
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value
Jacek Anaszewski [Thu, 21 Nov 2013 16:33:52 +0000 (13:33 -0300)]
[media] s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value

When output queue fourcc is set to any flavour of YUV,
the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value as
well as its in-driver cached counterpart have to be
updated with the subsampling property of the format
so as to be able to provide correct information to the
user space and preclude setting an illegal subsampling
mode for Exynos4x12 encoder.

Change-Id: I342638537b57940d411513a5465bf8449a1d1091
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder
Jacek Anaszewski [Thu, 21 Nov 2013 16:33:41 +0000 (13:33 -0300)]
[media] s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder

Exynos4x12 supports wider scope of subsampling modes than
S5PC210. Adjust corresponding mask accordingly.

Change-Id: Ie734ac8a4e4442e91ff5453fbe4be007607513a5
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Ensure correct capture format for Exynos4x12
Jacek Anaszewski [Fri, 22 Nov 2013 09:13:34 +0000 (06:13 -0300)]
[media] s5p-jpeg: Ensure correct capture format for Exynos4x12

Adjust capture format to the Exynos4x12 device limitations,
according to the subsampling value parsed from the source
JPEG image header. If the capture format was set to YUV with
subsampling lower than the one of the source JPEG image
the decoding process would not succeed.

Change-Id: I12420509e1c9ab887dcf3ab78099917d2bae5ae4
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
Jacek Anaszewski [Thu, 21 Nov 2013 16:33:09 +0000 (13:33 -0300)]
[media] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header

Make s5p_jpeg_parse_hdr function capable of parsing
"YCbCr subsampling" field of a jpeg file header. Store the
parsed value in the context.

The information about source JPEG subsampling is required to
make validation of destination format possible, which must be
conducted for exynos4x12 device as the decoding process will
not succeed if the destination format is set to YUV with
subsampling lower than the one of the source JPEG image.

With this knowledge the driver can adjust the destination format
appropriately.

Change-Id: I6327a5037cf06eb05f10caba6a86f4d00e5c029b
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: JPEG codec
Jacek Anaszewski [Wed, 18 Dec 2013 14:04:44 +0000 (11:04 -0300)]
[media] s5p-jpeg:  JPEG codec

Add hardware API for the exynos4x12 on s5p-jpeg.

Change-Id: I1b027a76ec22e3291c599e7d6d5317dcba8b617f
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
Jacek Anaszewski [Wed, 18 Dec 2013 12:32:50 +0000 (09:32 -0300)]
[media] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c

Move function definitions from jpeg-hw.h to jpeg-hw-s5p.c,
add "s5p" prefix and put function declarations in the jpeg-hw-s5p.h.

Change-Id: I7ef4814c8b00afa77de819f6cb248d93c3f7ce1d
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Synchronize cached controls with V4L2 core
Jacek Anaszewski [Mon, 25 Nov 2013 09:58:15 +0000 (06:58 -0300)]
[media] s5p-jpeg: Synchronize cached controls with V4L2 core

This patch adds proper initialization of the in-driver
cached state of JPEG controls with V4L2 core.

Change-Id: I29d5fccab898d820aa22194e4f71d28be1240f26
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Fix lack of spin_lock protection
Jacek Anaszewski [Mon, 25 Nov 2013 09:58:14 +0000 (06:58 -0300)]
[media] s5p-jpeg: Fix lack of spin_lock protection

s5p_jpeg_device_run and s5p_jpeg_runtime_resume callbacks should
have spin_lock protection as they alter device registers.

Change-Id: I56f19f6314c58e21284562e3e92c08409664aee4
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Fix clock resource management
Jacek Anaszewski [Mon, 25 Nov 2013 09:58:13 +0000 (06:58 -0300)]
[media] s5p-jpeg: Fix clock resource management

Standard suspend/resume path is called after runtime resume
of the given device, so suspend/resume callbacks must do all
clock management done also by runtime pm to allow for proper
power domain shutdown. Moreover, JPEG clock is enabled from
probe function but is is not necessary. This patch also moves
control of jpeg clock to runtime_pm callbacks.

Change-Id: I1292e2514baf3ca1f9af9a8edd3ddcb60f8c5901
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly
Jacek Anaszewski [Mon, 25 Nov 2013 09:58:12 +0000 (06:58 -0300)]
[media] s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly

Change-Id: Iafabd18c9728a83b6876ebec59fab1911f8f3266
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function
Jacek Anaszewski [Mon, 25 Nov 2013 09:58:11 +0000 (06:58 -0300)]
[media] s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function

Aligning capture queue image dimensions while enqueuing output
queue doesn't make a sense as the S_FMT ioctl might have not
been called for the capture queue until that moment, whereas
it is required to know capture format as the type of alignment
heavily depends on it.

Change-Id: I58dd67c5ce088e0ed889515dd53d6f39abc8b80e
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years ago[media] s5p-jpeg: Fix erroneous condition while validating bytesperline value
Jacek Anaszewski [Mon, 25 Nov 2013 09:58:10 +0000 (06:58 -0300)]
[media] s5p-jpeg: Fix erroneous condition while validating bytesperline value

The aim of the condition is ensuring that the bytesperline
value set by the user space application is proper for the
given format and adjusting it if isn't. As the depth value
of the format description entry is expressed in bits then
the bytesperline value needs to be divided, not multiplied,
by that value to get the number of bytes required to store
single line of image samples.

Change-Id: Ied5ab2df3b4ab89d44178481a9b15c51e4d02085
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>