platform/kernel/linux-rpi.git
8 years ago[media] media: make media_link more generic to handle interace links
Mauro Carvalho Chehab [Thu, 20 Aug 2015 12:10:07 +0000 (09:10 -0300)]
[media] media: make media_link more generic to handle interace links

By adding an union at media_link, we get for free a way to
represent interface->entity links.

No need to change anything at the code, just at the internal
header file.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: make add link more generic
Mauro Carvalho Chehab [Thu, 20 Aug 2015 11:21:35 +0000 (08:21 -0300)]
[media] media: make add link more generic

The media_entity_add_link() function takes an entity
as an argument just to get the list head.

Make it more generic by changing the function argument
to list_head.

No functional changes.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: convert links from array to list
Mauro Carvalho Chehab [Fri, 7 Aug 2015 09:55:40 +0000 (06:55 -0300)]
[media] media: convert links from array to list

The entire logic that represent graph links were developed on a
time where there were no needs to dynamic remove links. So,
although links are created/removed one by one via some
functions, they're stored as an array inside the entity struct.

As the array may grow, there's a logic inside the code that
checks if the amount of space is not enough to store
the needed links. If it isn't the core uses krealloc()
to change the size of the link, with is bad, as it
leaves the memory fragmented.

So, convert links into a list.

Also, currently,  both source and sink entities need the link
at the graph traversal logic inside media_entity. So there's
a logic duplicating all links. That makes it to spend
twice the memory needed. This is not a big deal for today's
usage, where the number of links are not big.

Yet, if during the MC workshop discussions, it was said that
IIO graphs could have up to 4,000 entities. So, we may
want to remove the duplication on some future. The problem
is that it would require a separate linked list to store
the backlinks inside the entity, or to use a more complex
algorithm to do graph backlink traversal, with is something
that the current graph traversal inside the core can't cope
with. So, let's postpone a such change if/when it is actually
needed.

It should also be noticed that the media_link structure uses
44 bytes on 32-bit architectures and 84 bytes on 64-bit
architecture. It will thus be allocated out of the 64-bytes and
96-bytes pools respectively. That's a 12.5% memory waste on
64-bit architectures and 31.25% on 32-bit architecture.
A linked list is less efficient than an array in this case, but
this could later be optimized if we can get rid of the reverse
links (with would reduce memory allocation by 50%).

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: Don't accept early-created links
Mauro Carvalho Chehab [Wed, 19 Aug 2015 23:18:35 +0000 (20:18 -0300)]
[media] media: Don't accept early-created links

Links are graph objects that represent the links of two already
existing objects in the graph.

While with the current implementation, it is possible to create
the links earlier, It doesn't make any sense to allow linking
two objects when they are not both created.

So, remove the code that would be handling those early-created
links and add a BUG_ON() to ensure that.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] smiapp: create pad links after subdev registration
Javier Martinez Canillas [Thu, 3 Sep 2015 12:00:27 +0000 (09:00 -0300)]
[media] smiapp: create pad links after subdev registration

The smiapp driver creates the pads links before the media entity is
registered with the media device. This doesn't work now that object
IDs are used to create links so the media_device has to be set.

Move entity registration logic before pads links creation.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] uvcvideo: create pad links after subdev registration
Javier Martinez Canillas [Thu, 3 Sep 2015 11:46:06 +0000 (08:46 -0300)]
[media] uvcvideo: create pad links after subdev registration

The uvc driver creates the pads links before the media entity is
registered with the media device. This doesn't work now that obj
IDs are used to create links so the media_device has to be set.

Move entities registration logic before pads links creation.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] v4l: vsp1: separate links creation from entities init
Javier Martinez Canillas [Thu, 3 Sep 2015 15:19:25 +0000 (12:19 -0300)]
[media] v4l: vsp1: separate links creation from entities init

The vsp1 driver initializes the entities and creates the pads links
before the entities are registered with the media device. This doesn't
work now that object IDs are used to create links so the media_device
has to be set.

Split out the pads links creation from the entity initialization so are
made after the entities registration.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] v4l: vsp1: create pad links after subdev registration
Javier Martinez Canillas [Thu, 3 Sep 2015 14:20:34 +0000 (11:20 -0300)]
[media] v4l: vsp1: create pad links after subdev registration

The vsp1 driver creates the pads links before the media entities are
registered with the media device. This doesn't work now that object
IDs are used to create links so the media_device has to be set.

Move entities registration logic before pads links creation.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] staging: omap4iss: separate links creation from entities init
Javier Martinez Canillas [Wed, 2 Sep 2015 14:28:08 +0000 (11:28 -0300)]
[media] staging: omap4iss: separate links creation from entities init

The omap4iss driver initializes the entities and creates the pads links
before the entities are registered with the media device. This does not
work now that object IDs are used to create links so the media_device
has to be set.

Split out the pads links creation from the entity initialization so are
made after the entities registration.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] omap3isp: create links after all subdevs have been bound
Javier Martinez Canillas [Fri, 28 Aug 2015 09:28:33 +0000 (06:28 -0300)]
[media] omap3isp: create links after all subdevs have been bound

The omap3isp driver parses the graph endpoints to know how many subdevices
needs to be registered async and register notifiers callbacks for to know
when these are bound and when the async registrations are completed.

Currently the entities pad are linked with the correct ISP input interface
when the subdevs are bound but it happens before entitities are registered
with the media device so that won't work now that the entity links list is
initialized on device registration.

So instead creating the pad links when the subdevice is bound, create them
on the complete callback once all the subdevices have been bound but only
try to create for the ones that have a bus configuration set during bound.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] omap3isp: separate links creation from entities init
Javier Martinez Canillas [Wed, 26 Aug 2015 12:24:45 +0000 (09:24 -0300)]
[media] omap3isp: separate links creation from entities init

The omap3isp driver initializes the entities and creates the pads links
before the entities are registered with the media device. This does not
work now that object IDs are used to create links so the media_device
has to be set.

Split out the pads links creation from the entity initialization so the links
are created after the entities have been registered with the media device.

Suggested-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: add functions to allow creating interfaces
Mauro Carvalho Chehab [Thu, 20 Aug 2015 12:07:34 +0000 (09:07 -0300)]
[media] media: add functions to allow creating interfaces

Interfaces are different than entities: they represent a
Kernel<->userspace interaction, while entities represent a
piece of hardware/firmware/software that executes a function.

Let's distinguish them by creating a separate structure to
store the interfaces.

Later patches should change the existing drivers and logic
to split the current interface embedded inside the entity
structure (device nodes) into a separate object of the graph.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] uapi/media.h: Declare interface types for V4L2 and DVB
Mauro Carvalho Chehab [Thu, 20 Aug 2015 10:43:07 +0000 (07:43 -0300)]
[media] uapi/media.h: Declare interface types for V4L2 and DVB

Declare the interface types that will be used by the new
G_TOPOLOGY ioctl that will be defined later on.

For now, we need those types, as they'll be used on the
internal structs associated with the new media_interface
graph object defined on the next patch.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: remove media entity .parent field
Javier Martinez Canillas [Wed, 19 Aug 2015 15:35:22 +0000 (12:35 -0300)]
[media] media: remove media entity .parent field

Now that the struct media_entity .parent field is unused, it can be
safely removed. Since all the previous users were converted to use
the .mdev field from the embedded struct media_gobj instead.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: use entity.graph_obj.mdev instead of .parent
Javier Martinez Canillas [Wed, 19 Aug 2015 15:35:21 +0000 (12:35 -0300)]
[media] media: use entity.graph_obj.mdev instead of .parent

The struct media_entity has a .parent field that stores a pointer
to the parent struct media_device. But recently a media_gobj was
embedded into the entities and since struct media_gojb already has
a pointer to a struct media_device in the .mdev field, the .parent
field becomes redundant and can be removed.

This patch replaces all the usage of .parent by .graph_obj.mdev so
that field will become unused and can be removed on a later patch.

No functional changes.

The transformation was made using the following coccinelle spatch:

@@
struct media_entity *me;
@@

- me->parent
+ me->graph_obj.mdev

@@
struct media_entity *link;
@@

- link->source->entity->parent
+ link->source->entity->graph_obj.mdev

@@
struct exynos_video_entity *ve;
@@

- ve->vdev.entity.parent
+ ve->vdev.entity.graph_obj.mdev

Suggested-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: rename the function that create pad links
Mauro Carvalho Chehab [Fri, 7 Aug 2015 11:14:38 +0000 (08:14 -0300)]
[media] media: rename the function that create pad links

With the new API, a link can be either between two PADs or between an interface
and an entity. So, we need to use a better name for the function that create
links between two pads.

So, rename the such function to media_create_pad_link().

No functional changes.

This patch was created via this shell script:
for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type f) ; do sed s,media_entity_create_link,media_create_pad_link,g <$i >a && mv a $i; done

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: add a debug message to warn about gobj creation/removal
Mauro Carvalho Chehab [Thu, 13 Aug 2015 17:42:42 +0000 (14:42 -0300)]
[media] media: add a debug message to warn about gobj creation/removal

It helps to check if the media controller is doing the
right thing with the object creation and removal.

No extra code/data will be produced if DEBUG or
CONFIG_DYNAMIC_DEBUG is not enabled.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: add messages when media device gets (un)registered
Mauro Carvalho Chehab [Thu, 13 Aug 2015 18:22:24 +0000 (15:22 -0300)]
[media] media: add messages when media device gets (un)registered

We can only free the media device after being sure that no
graph object is used.

In order to help tracking it, let's add debug messages
that will print when the media controller gets registered
or unregistered.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: use media_gobj inside links
Mauro Carvalho Chehab [Fri, 14 Aug 2015 15:54:36 +0000 (12:54 -0300)]
[media] media: use media_gobj inside links

Just like entities and pads, links also need to have unique
Object IDs along a given media controller.

So, let's add a media_gobj inside it and initialize
the object then a new link is created.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: use media_gobj inside pads
Mauro Carvalho Chehab [Fri, 14 Aug 2015 15:50:08 +0000 (12:50 -0300)]
[media] media: use media_gobj inside pads

PADs also need unique object IDs that won't conflict with
the entity object IDs.

The pad objects are currently created via media_entity_init()
and, once created, never change.

While this will likely change in the future in order to
support dynamic changes, for now we'll keep PADs as arrays
and initialize the media_gobj embedded structs when
registering the entity.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: use media_gobj inside entities
Mauro Carvalho Chehab [Fri, 14 Aug 2015 15:47:48 +0000 (12:47 -0300)]
[media] media: use media_gobj inside entities

As entities are graph objects, let's embed media_gobj
on it. That ensures an unique ID for entities that can be
global along the entire media controller.

For now, we'll keep the already existing entity ID. Such
field need to be dropped at some point, but for now, let's
not do this, to avoid needing to review all drivers and
the userspace apps.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Tested-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: add a common struct to be embed on media graph objects
Mauro Carvalho Chehab [Tue, 25 Aug 2015 13:28:36 +0000 (10:28 -0300)]
[media] media: add a common struct to be embed on media graph objects

Due to the MC API proposed changes, we'll need to have an unique
object ID for all graph objects, and have some shared fields
that will be common on all media graph objects.

Right now, the only common object is the object ID, but other
fields will be added later on.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] omap3isp: get entity ID using media_entity_id()
Javier Martinez Canillas [Wed, 19 Aug 2015 15:35:20 +0000 (12:35 -0300)]
[media] omap3isp: get entity ID using media_entity_id()

Accessing media_entity ID should now use media_entity_id() macro to
obtain the entity ID, as a next patch will remove the .id field from
struct media_entity .

So, get rid of it, otherwise the omap3isp driver will fail to build.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] staging: omap4iss: get entity ID using media_entity_id()
Javier Martinez Canillas [Wed, 19 Aug 2015 15:35:19 +0000 (12:35 -0300)]
[media] staging: omap4iss: get entity ID using media_entity_id()

Accessing media_entity ID should now use media_entity_id() macro to
obtain the entity ID, as a next patch will remove the .id field from
struct media_entity .

So, get rid of it, otherwise the omap4iss driver will fail to build.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: create a macro to get entity ID
Mauro Carvalho Chehab [Fri, 14 Aug 2015 13:42:05 +0000 (10:42 -0300)]
[media] media: create a macro to get entity ID

Instead of accessing directly entity.id, let's create a macro,
as this field will be moved into a common struct later on.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] au0828: Fix the logic that enables the analog demoder link
Mauro Carvalho Chehab [Thu, 20 Aug 2015 09:53:10 +0000 (06:53 -0300)]
[media] au0828: Fix the logic that enables the analog demoder link

This logic was broken on the original patch, likely due to a
cut-and-paste mistake.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] Kconfig: Re-enable Media controller support for DVB
Mauro Carvalho Chehab [Wed, 19 Aug 2015 09:57:59 +0000 (06:57 -0300)]
[media] Kconfig: Re-enable Media controller support for DVB

This was depending on broken because we're working at the
Media Controller API, with has... issues.

As this got fixed, we can re-enable it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: get rid of unused "extra_links" param on media_entity_init()
Mauro Carvalho Chehab [Thu, 6 Aug 2015 12:25:57 +0000 (09:25 -0300)]
[media] media: get rid of unused "extra_links" param on media_entity_init()

Currently, media_entity_init() creates an array with the links,
allocated at init time. It provides a parameter (extra_links)
that would allocate more links than the current needs, but this
is not used by any driver.

As we want to be able to do dynamic link allocation/removal,
we'll need to change the implementation of the links. So,
before doing that, let's first remove that extra unused
parameter, in order to cleanup the interface first.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] au0828: Cache the decoder info at au0828 dev structure
Mauro Carvalho Chehab [Thu, 18 Jun 2015 16:06:38 +0000 (13:06 -0300)]
[media] au0828: Cache the decoder info at au0828 dev structure

Instead of seeking for the decoder every time analog stream is
started, cache it. This simplifies the code a little bit.

Requested-by: Hans Verkuil <hverkuil@xs4all.nl>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] au0828: Add support for media controller
Rafael Lourenço de Lima Chehab [Tue, 9 Jun 2015 01:20:46 +0000 (22:20 -0300)]
[media] au0828: Add support for media controller

Add support for analog and dvb tv using media controller.

Signed-off-by: Rafael Lourenço de Lima Chehab <chehabrafael@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: define Media Controller API when CONFIG_MEDIA_CONTROLLER enabled
Shuah Khan [Fri, 5 Jun 2015 20:11:54 +0000 (17:11 -0300)]
[media] media: define Media Controller API when CONFIG_MEDIA_CONTROLLER enabled

Change to define Media Controller API when CONFIG_MEDIA_CONTROLLER
is enabled. Define stubs for CONFIG_MEDIA_CONTROLLER disabled case.
This will help avoid drivers needing to enclose Media Controller
code within ifdef CONFIG_MEDIA_CONTROLLER block.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: new media controller API for device resource support
Shuah Khan [Wed, 3 Jun 2015 15:12:53 +0000 (12:12 -0300)]
[media] media: new media controller API for device resource support

Add new media controller API to allocate media device as a
device resource. When a media device is created on the main
struct device which is the parent device for the interface
device, it will be available to all drivers associated with
that interface. For example, if a usb media device driver
creates the media device on the main struct device which is
common for all the drivers that control the media device,
including the non-media ALSA driver, media controller API
can be used to share access to the resources on the media
device. This new interface provides the above described
feature. A second interface that finds and returns the media
device is added to allow drivers to find the media device
created by any of the drivers associated with the device.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] rc: sunxi-cir: Initialize the spinlock properly
Chen-Yu Tsai [Tue, 22 Dec 2015 04:27:35 +0000 (02:27 -0200)]
[media] rc: sunxi-cir: Initialize the spinlock properly

The driver allocates the spinlock but fails to initialize it correctly.
The kernel reports a BUG indicating bad spinlock magic when spinlock
debugging is enabled.

Call spin_lock_init() on it to initialize it correctly.

Fixes: b4e3e59fb59c ("[media] rc: add sunxi-ir driver")

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] rtl2832: do not filter out slave TS null packets
Antti Palosaari [Sun, 20 Dec 2015 02:57:20 +0000 (00:57 -0200)]
[media] rtl2832: do not filter out slave TS null packets

Do not remove slave TS NULL padding PID (0x1fff) by default as
there is no real need. After that whole TS is passed to kernel sw
PID filter.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] rtl2832: print reg number on error case
Antti Palosaari [Tue, 6 Oct 2015 00:16:39 +0000 (21:16 -0300)]
[media] rtl2832: print reg number on error case

It is hard to debug possible I2C failures without knowing the
possible register itself. Add register number to error printing.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] rtl28xxu: return demod reg page from driver cache
Antti Palosaari [Mon, 5 Oct 2015 23:46:37 +0000 (20:46 -0300)]
[media] rtl28xxu: return demod reg page from driver cache

Return current active rtl2830/rtl2832 register page from the driver
cache in order to reduce I2C I/O. Register page is already cached
due to I2C write needs.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] coda: enable MPEG-2 ES decoding
Philipp Zabel [Wed, 2 Dec 2015 16:58:54 +0000 (14:58 -0200)]
[media] coda: enable MPEG-2 ES decoding

Hook up the MPEG-2 ES decoder.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] coda: don't start streaming without queued buffers
Philipp Zabel [Wed, 2 Dec 2015 16:58:53 +0000 (14:58 -0200)]
[media] coda: don't start streaming without queued buffers

We could support start streaming with an empty output queue for the
BIT decoders due to the bitstream buffer which could still contain
data at this point, but there is really no reason for userspace to
expect this to work. Simplify the code by disallowing it.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] coda: hook up vidioc_prepare_buf
Philipp Zabel [Wed, 2 Dec 2015 16:58:52 +0000 (14:58 -0200)]
[media] coda: hook up vidioc_prepare_buf

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] coda: relax coda_jpeg_check_buffer for trailing bytes
Philipp Zabel [Wed, 2 Dec 2015 16:58:51 +0000 (14:58 -0200)]
[media] coda: relax coda_jpeg_check_buffer for trailing bytes

coda_jpeg_check_buffer only cares about the buffer length and contents,
so change the parameter type back from v4l2_vb2_buffer to just the
vb2_buffer.
Instead of just checking the first and last bytes for the SOI and EOI
markers, relax the EOI marker check a bit and allow up to 32 trailing
bytes after the EOI marker as hardware generated JPEGs sometimes contain
some alignment overhead.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] coda: make to_coda_video_device static
Philipp Zabel [Wed, 2 Dec 2015 16:58:50 +0000 (14:58 -0200)]
[media] coda: make to_coda_video_device static

This function is not used outside coda-common.c.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5p-mfc: remove volatile attribute from MFC register addresses
Andrzej Hajda [Wed, 2 Dec 2015 08:22:33 +0000 (06:22 -0200)]
[media] s5p-mfc: remove volatile attribute from MFC register addresses

MFC register addresses are used only by writel/readl macros which already
takes care of proper register accessing.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5p-mfc: merge together s5p_mfc_hw_call and s5p_mfc_hw_call_void
Andrzej Hajda [Wed, 2 Dec 2015 08:22:32 +0000 (06:22 -0200)]
[media] s5p-mfc: merge together s5p_mfc_hw_call and s5p_mfc_hw_call_void

Both macros can be merged into one.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5p-mfc: use spinlock to protect MFC context
Andrzej Hajda [Wed, 2 Dec 2015 08:22:31 +0000 (06:22 -0200)]
[media] s5p-mfc: use spinlock to protect MFC context

MFC driver uses dev->irqlock spinlock to protect queues only, but many context
fields require protection also - they can be accessed concurrently
from IOCTLs and IRQ handler. The patch increases protection range of irqlock
to those fields also.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5p-mfc: remove unnecessary callbacks
Andrzej Hajda [Wed, 2 Dec 2015 08:22:30 +0000 (06:22 -0200)]
[media] s5p-mfc: remove unnecessary callbacks

Many version specific functions are not called by common code, so there
is no need to use callbacks. Additionally some of them are not used at all,
so they can be safely removed.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5p-mfc: make queue cleanup code common
Andrzej Hajda [Wed, 2 Dec 2015 08:22:29 +0000 (06:22 -0200)]
[media] s5p-mfc: make queue cleanup code common

Code for queue cleanup has nothing specific to hardware version.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5p-mfc: use one implementation of s5p_mfc_get_new_ctx
Andrzej Hajda [Wed, 2 Dec 2015 08:22:28 +0000 (06:22 -0200)]
[media] s5p-mfc: use one implementation of s5p_mfc_get_new_ctx

Both version of MFC driver use functions with the same body and name.
The patch moves them to common location. It also simplifies it.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5p-mfc: constify s5p_mfc_codec_ops structures
Julia Lawall [Sun, 22 Nov 2015 07:45:34 +0000 (05:45 -0200)]
[media] s5p-mfc: constify s5p_mfc_codec_ops structures

The s5p_mfc_codec_ops structures are never modified, so declare them as
const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] au8522: Avoid memory leak for device config data
Mauro Carvalho Chehab [Mon, 21 Dec 2015 16:38:31 +0000 (14:38 -0200)]
[media] au8522: Avoid memory leak for device config data

As reported by kmemleak:

unreferenced object 0xffff880321e1da40 (size 32):
  comm "modprobe", pid 3309, jiffies 4295019569 (age 2359.636s)
  hex dump (first 32 bytes):
    47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  G...............
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff82278c8e>] kmemleak_alloc+0x4e/0xb0
    [<ffffffff8153c08c>] kmem_cache_alloc_trace+0x1ec/0x280
    [<ffffffffa13a896a>] au8522_probe+0x19a/0xa30 [au8522_decoder]
    [<ffffffff81de0032>] i2c_device_probe+0x2b2/0x490
    [<ffffffff81ca7004>] driver_probe_device+0x454/0xd90
    [<ffffffff81ca7c1b>] __device_attach_driver+0x17b/0x230
    [<ffffffff81ca15da>] bus_for_each_drv+0x11a/0x1b0
    [<ffffffff81ca6a4d>] __device_attach+0x1cd/0x2c0
    [<ffffffff81ca7d43>] device_initial_probe+0x13/0x20
    [<ffffffff81ca451f>] bus_probe_device+0x1af/0x250
    [<ffffffff81c9e0f3>] device_add+0x943/0x13b0
    [<ffffffff81c9eb7a>] device_register+0x1a/0x20
    [<ffffffff81de8626>] i2c_new_device+0x5d6/0x8f0
    [<ffffffffa0d88ea4>] v4l2_i2c_new_subdev_board+0x1e4/0x250 [v4l2_common]
    [<ffffffffa0d88fe7>] v4l2_i2c_new_subdev+0xd7/0x110 [v4l2_common]
    [<ffffffffa13b2f76>] au0828_card_analog_fe_setup+0x2e6/0x3f0 [au0828]

Checking where the error happens:
(gdb) list *au8522_probe+0x19a
0x99a is in au8522_probe (drivers/media/dvb-frontends/au8522_decoder.c:761).
756 printk(KERN_INFO "au8522_decoder attach existing instance.\n");
757 break;
758 }
759
760 demod_config = kzalloc(sizeof(struct au8522_config), GFP_KERNEL);
761 if (demod_config == NULL) {
762 if (instance == 1)
763 kfree(state);
764 return -ENOMEM;
765 }

Shows that the error path is not being handled properly.

The are actually several issues here:

1) config free should have been calling hybrid_tuner_release_state()
function, by calling au8522_release_state();

2) config is only allocated at the digital part. On the analog one,
it is received from the caller.

A complex logic could be added to address it, however, it is simpler
to just embeed config inside the state.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] ir-lirc-codec.c: don't leak lirc->drv-rbuf
Mauro Carvalho Chehab [Mon, 21 Dec 2015 15:31:23 +0000 (13:31 -0200)]
[media] ir-lirc-codec.c: don't leak lirc->drv-rbuf

As reported by kmemleak:

unreferenced object 0xffff8802adae0ba0 (size 192):
  comm "modprobe", pid 3024, jiffies 4296503588 (age 324.368s)
  hex dump (first 32 bytes):
    00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00  .....N..........
    ff ff ff ff ff ff ff ff c0 48 25 a0 ff ff ff ff  .........H%.....
  backtrace:
    [<ffffffff82278c8e>] kmemleak_alloc+0x4e/0xb0
    [<ffffffff8153c08c>] kmem_cache_alloc_trace+0x1ec/0x280
    [<ffffffffa0250f0d>] ir_lirc_register+0x8d/0x7a0 [ir_lirc_codec]
    [<ffffffffa07372b8>] ir_raw_event_register+0x318/0x4b0 [rc_core]
    [<ffffffffa07351ed>] rc_register_device+0xf2d/0x1450 [rc_core]
    [<ffffffffa13c5451>] au0828_rc_register+0x7d1/0xa10 [au0828]
    [<ffffffffa13b0dc2>] au0828_usb_probe+0x6c2/0xcf0 [au0828]
    [<ffffffff81d7619d>] usb_probe_interface+0x45d/0x940
    [<ffffffff81ca7004>] driver_probe_device+0x454/0xd90
    [<ffffffff81ca7a61>] __driver_attach+0x121/0x160
    [<ffffffff81ca141f>] bus_for_each_dev+0x11f/0x1a0
    [<ffffffff81ca5d4d>] driver_attach+0x3d/0x50
    [<ffffffff81ca5039>] bus_add_driver+0x4c9/0x770
    [<ffffffff81ca944c>] driver_register+0x18c/0x3b0
    [<ffffffff81d71e58>] usb_register_driver+0x1f8/0x440
    [<ffffffffa13680b7>] 0xffffffffa13680b7

0xf3d is in ir_lirc_register (drivers/media/rc/ir-lirc-codec.c:348).
343 drv = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL);
344 if (!drv)
345 return rc;
346
347 rbuf = kzalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
348 if (!rbuf)
349 goto rbuf_alloc_failed;
350
351 rc = lirc_buffer_init(rbuf, sizeof(int), LIRCBUF_SIZE);
352 if (rc)

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] uvcvideo: small cleanup in uvc_video_clock_update()
Dan Carpenter [Thu, 22 Oct 2015 09:09:05 +0000 (07:09 -0200)]
[media] uvcvideo: small cleanup in uvc_video_clock_update()

Smatch is not smart enough to see that "&stream->clock.lock" and
"&clock->lock" are the same thing so it complains about the locking
here.  Let's make it more consistent.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] uvcvideo: Fix reading the current exposure value of UVC
Anton V. Shokurov [Sun, 18 Oct 2015 21:01:26 +0000 (19:01 -0200)]
[media] uvcvideo: Fix reading the current exposure value of UVC

V4L2_CID_EXPOSURE_ABSOLUTE property does not return an updated value when
autoexposure (V4L2_CID_EXPOSURE_AUTO) is turned on. This patch fixes this
issue by adding the UVC_CTRL_FLAG_AUTO_UPDATE flag.

Tested on a C920 camera.

Signed-off-by: Anton V. Shokurov <shokurov.anton.v@yandex.ru>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx23885-dvb: move initialization of a8293_pdata
Mauro Carvalho Chehab [Fri, 18 Dec 2015 16:22:21 +0000 (14:22 -0200)]
[media] cx23885-dvb: move initialization of a8293_pdata

Smatch complains about where the au8293_data is placed:

drivers/media/pci/cx23885/cx23885-dvb.c:2174 dvb_register() info: 'a8293_pdata' is not actually initialized (unreached code).

It is not actually expected to have such initialization at

switch {
foo = bar;

case:
...
}

Not really sure how gcc does that, but this is something that I would
expect that different compilers would do different things.

David Howells checked with the compiler people: it's not really expected to
initialise as expected.

So, move the initialization outside the switch(), making smatch to
shut up one warning.

Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx23885-dvb: initialize a8293_pdata
Mauro Carvalho Chehab [Fri, 18 Dec 2015 16:15:56 +0000 (14:15 -0200)]
[media] cx23885-dvb: initialize a8293_pdata

As reported by smatch:
drivers/media/pci/cx23885/cx23885-dvb.c:2174 dvb_register() info: 'a8293_pdata' is not actually initialized (unreached code).

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] videobuf2: avoid memory leak on errors
Mauro Carvalho Chehab [Fri, 18 Dec 2015 16:11:31 +0000 (14:11 -0200)]
[media] videobuf2: avoid memory leak on errors

As reported by smatch:
drivers/media/v4l2-core/videobuf2-core.c:2415 __vb2_init_fileio() warn: possible memory leak of 'fileio'

While here, avoid the usage of sizeof(struct foo_struct).

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] videobuf2-core: fix plane_sizes handling in VIDIOC_CREATE_BUFS
Hans Verkuil [Fri, 20 Nov 2015 11:40:14 +0000 (09:40 -0200)]
[media] videobuf2-core: fix plane_sizes handling in VIDIOC_CREATE_BUFS

The handling of q->plane_sizes was wrong in vb2_core_create_bufs().
The q->plane_sizes array was global and it was overwritten by create_bufs.
So if reqbufs was called with e.g. size 100000 then q->plane_sizes[0] would
be set to 100000. If create_bufs was called afterwards with size 200000,
then q->plane_sizes[0] would be overwritten with the new value. Calling
create_bufs again for size 100000 would cause an error since 100000 is now
less than q->plane_sizes[0].

This patch fixes this problem by 1) removing q->plane_sizes and using the
vb->planes[].length field instead, and 2) by introducing a min_length field
in struct vb2_plane. This field is set to the plane size as returned by
the queue_setup op and is the minimum required plane size. So user pointers
or dmabufs should all be at least this size.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] videobuf2-core: call __setup_offsets before buf_init()
Hans Verkuil [Fri, 20 Nov 2015 11:36:49 +0000 (09:36 -0200)]
[media] videobuf2-core: call __setup_offsets before buf_init()

Ensure that the offsets are correct before buf_init() is called.
As a consequence the __setup_offsets() function now sets up the
offsets for the given buffer instead of for all new buffers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] videobuf2-core: fill in q->bufs[vb->index] before buf_init()
Hans Verkuil [Fri, 20 Nov 2015 11:31:11 +0000 (09:31 -0200)]
[media] videobuf2-core: fill in q->bufs[vb->index] before buf_init()

Fill in q->bufs[vb->index] before the call to buf_init: it makes
sense that this is initialized correctly.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] videobuf2-core: move __setup_lengths into __vb2_queue_alloc()
Hans Verkuil [Fri, 20 Nov 2015 11:25:52 +0000 (09:25 -0200)]
[media] videobuf2-core: move __setup_lengths into __vb2_queue_alloc()

Rather than setting up the lengths at the end, set them up when
the vb2_buffer is allocated. This also ensures that buf_init()
sees the right length values.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] videobuf2-core: fill_user_buffer and copy_timestamp should return void
Hans Verkuil [Fri, 20 Nov 2015 10:32:00 +0000 (08:32 -0200)]
[media] videobuf2-core: fill_user_buffer and copy_timestamp should return void

This ops can never fail, so make these void functions.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] videobuf2-core.c: update module description
Hans Verkuil [Fri, 20 Nov 2015 10:17:23 +0000 (08:17 -0200)]
[media] videobuf2-core.c: update module description

This module is no longer V4L2 specific, so update the module description
accordingly.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: videobuf2: Move vb2_fileio_data and vb2_thread to core part
Junghak Sung [Tue, 3 Nov 2015 10:16:42 +0000 (08:16 -0200)]
[media] media: videobuf2: Move vb2_fileio_data and vb2_thread to core part

Move things related with vb2 file I/O and vb2_thread without doing any
functional changes. After that, videobuf2-internal.h is removed because
it is not necessary any more.

Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: videobuf2: Refactor vb2_fileio_data and vb2_thread
Junghak Sung [Tue, 3 Nov 2015 10:16:41 +0000 (08:16 -0200)]
[media] media: videobuf2: Refactor vb2_fileio_data and vb2_thread

Replace v4l2-stuffs with common things in struct vb2_fileio_data and
vb2_thread().

Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: videobuf2: last_buffer_queued is set at fill_v4l2_buffer()
Junghak Sung [Tue, 3 Nov 2015 10:16:40 +0000 (08:16 -0200)]
[media] media: videobuf2: last_buffer_queued is set at fill_v4l2_buffer()

The location in which last_buffer_queued is set is moved to fill_v4l2_buffer().
So, __vb2_perform_fileio() can use vb2_core_dqbuf() instead of
vb2_internal_dqbuf().

Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: videobuf2: Separate vb2_poll()
Junghak Sung [Tue, 3 Nov 2015 10:16:39 +0000 (08:16 -0200)]
[media] media: videobuf2: Separate vb2_poll()

Separate vb2_poll() into core and v4l2 part.

Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: videobuf2: Add copy_timestamp to struct vb2_queue
Junghak Sung [Tue, 3 Nov 2015 10:16:38 +0000 (08:16 -0200)]
[media] media: videobuf2: Add copy_timestamp to struct vb2_queue

Add copy_timestamp to struct vb2_queue as a flag set if vb2-core should
copy timestamps.

Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: videobuf2: Move timestamp to vb2_buffer
Junghak Sung [Tue, 3 Nov 2015 10:16:37 +0000 (08:16 -0200)]
[media] media: videobuf2: Move timestamp to vb2_buffer

Move timestamp from struct vb2_v4l2_buffer to struct vb2_buffer
for common use, and change its type to u64 in order to handling
y2038 problem. This patch also includes all device drivers' changes related to
this restructuring.

Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] solo6x10: use v4l2_get_timestamp to fill in buffer timestamp
Hans Verkuil [Fri, 20 Nov 2015 09:16:56 +0000 (07:16 -0200)]
[media] solo6x10: use v4l2_get_timestamp to fill in buffer timestamp

The timestamp of a v4l2_buffer was advertised as being CLOCK_MONOTONIC,
but instead a timestamp from a header field was used. This is inconsistent
and not what applications expect. Use v4l2_get_timestamp to properly
set the timestamp.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] DocBook media: update VIDIOC_CREATE_BUFS documentation
Hans Verkuil [Thu, 29 Oct 2015 04:07:30 +0000 (02:07 -0200)]
[media] DocBook media: update VIDIOC_CREATE_BUFS documentation

During the Seoul media workshop we decided to relax the VIDIOC_CREATE_BUFS
specification so it would no longer require drivers to validate the format
field since almost no driver did that anyway.

Instead drivers use the buffer size(s) based on the format type and the
corresponding format fields and will ignore any other fields. If the size
cannot be used an error is returned, otherwise the size is used as-is.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] vb2: drop v4l2_format argument from queue_setup
Hans Verkuil [Wed, 28 Oct 2015 02:50:37 +0000 (00:50 -0200)]
[media] vb2: drop v4l2_format argument from queue_setup

The queue_setup callback has a void pointer that is just for V4L2
and is the pointer to the v4l2_format struct that was passed to
VIDIOC_CREATE_BUFS. The idea was that drivers would use the information
from that struct to buffers suitable for the requested format.

After the vb2 split series this pointer is now a void pointer,
which is ugly, and the reality is that all existing drivers will
effectively just look at the sizeimage field of v4l2_format.

To make this more generic the queue_setup callback is changed:
the void pointer is dropped, instead if the *num_planes argument
is 0, then use the current format size, if it is non-zero, then
it contains the number of requested planes and the sizes array
contains the requested sizes. If either is unsupported, then return
-EINVAL, otherwise use the requested size(s).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx23885: video instead of vbi register used
Hans Verkuil [Mon, 30 Nov 2015 16:47:00 +0000 (14:47 -0200)]
[media] cx23885: video instead of vbi register used

The VID_A_GPCNT register is for video, not vbi. Read from the right
register and don't write to the video register.

Based upon Devin's initial patch made for an older kernel which I
cleaned up and rebased. Thanks to Kernel Labs for that work.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx23885: add support for ViewCast 260e and 460e
Hans Verkuil [Mon, 30 Nov 2015 20:08:10 +0000 (18:08 -0200)]
[media] cx23885: add support for ViewCast 260e and 460e

Add support for these two new cards.

Based upon Devin's initial patch made for an older kernel which I
cleaned up and rebased. Thanks to Kernel Labs for that work.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cs3308: add new 8-channel volume control driver
Hans Verkuil [Mon, 30 Nov 2015 20:05:54 +0000 (18:05 -0200)]
[media] cs3308: add new 8-channel volume control driver

Add simple support for this 8 channel volume control driver.
Currently all it does is to unmute all 8 channels.

Based upon Devin's initial patch made for an older kernel which I
cleaned up and rebased. Thanks to Kernel Labs for that work.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx25840: initialize the standard to NTSC_M
Hans Verkuil [Mon, 30 Nov 2015 12:28:23 +0000 (10:28 -0200)]
[media] cx25840: initialize the standard to NTSC_M

This is necessary since the *_std_setup functions rely on a valid state->std
field.

Also fix the cx23888_std_setup() to test for 60Hz instead of NTSC, just like
cx25840_std_setup() does.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx25840: fix cx25840_s_stream for cx2388x and cx231xx
Hans Verkuil [Mon, 30 Nov 2015 12:26:35 +0000 (10:26 -0200)]
[media] cx25840: fix cx25840_s_stream for cx2388x and cx231xx

For those two devices the code wrote to addresses 0x115/6, but on
those devices those addresses have nothing to do with power controls.
So clearly this never worked. Rather than writing to bogus addresses,
just do nothing for the cx2388x and cx231xx.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx25840: relax a Vsrc check
Hans Verkuil [Mon, 30 Nov 2015 12:19:41 +0000 (10:19 -0200)]
[media] cx25840: relax a Vsrc check

The cx23888 reports a slightly different Vsrc value than the other
chip variants do. Relax the check by 1, otherwise cx25840_set_fmt()
would fail for the cx23888.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx25840: more cx23888 register address changes
Hans Verkuil [Mon, 30 Nov 2015 12:15:21 +0000 (10:15 -0200)]
[media] cx25840: more cx23888 register address changes

The cx23888 also moves the following registers around:

!cx23888 cx23888
-------- -------
0x418, 0x41c 0x434, 0x438
0x420 0x418 (expect for bit 29 which has a different meaning)
0x478 0x454

Also drop the set_input code where the scaler is changed: this does not
belong here, changing the input should not change the scaler.

And that's besides the fact that that code is plain wrong.

After this change the cx23888 behaves much better. In particular, calling
set_input no longer changes the saturation to 0, causing a grayscale
image.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx25840: fix VBI support for cx23888
Hans Verkuil [Mon, 30 Nov 2015 12:09:50 +0000 (10:09 -0200)]
[media] cx25840: fix VBI support for cx23888

The cx23888 has the VBI registers at different addresses compared to
the other variants. In most cases it is a fixed offset, but not always.

Update the code so the right registers are written for the cx23888.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] ivtv/cx18: fix inverted pixel aspect ratio
Hans Verkuil [Mon, 30 Nov 2015 12:05:53 +0000 (10:05 -0200)]
[media] ivtv/cx18: fix inverted pixel aspect ratio

These two drivers reported the pixel aspect ratio the wrong way around.
This caused qv4l2 to scale the image incorrectly.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx231xx: fix NTSC cropcap, add missing cropcap for 417
Hans Verkuil [Mon, 30 Nov 2015 12:03:30 +0000 (10:03 -0200)]
[media] cx231xx: fix NTSC cropcap, add missing cropcap for 417

The pixelaspect ratio was set incorrectly for 60Hz formats.
And since cropcap wasn't implemented at all for the -417 (compressed
video) the pixelaspect was unknown for compressed video.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] cx23885: fix format/crop handling
Hans Verkuil [Mon, 30 Nov 2015 11:59:18 +0000 (09:59 -0200)]
[media] cx23885: fix format/crop handling

While testing the cx23885 driver with various TV standards I found
a number of bugs:

1) norm_maxw() returned 768 instead of 720 for PAL formats. This should
   always be 720, so drop this inline function and just always use 720.
2) cropcap() was missing, so the pixelaspect was never known and qv4l2 would
   scale the image incorrectly. Add cropcap support.
3) cx23885_set_tvnorm() should just return 0 if the same standard was
   set again. If another standard is set, then reset the width/height and
   call set_fmt for the subdevs.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years agoRevert "[media] UVC: Add support for ds4 depth camera"
Mauro Carvalho Chehab [Sat, 12 Dec 2015 10:10:40 +0000 (08:10 -0200)]
Revert "[media] UVC: Add support for ds4 depth camera"

This reverts commit 120c41d3477a23c6941059401db63677736f1935.

The patch doesn't add the corresponding documentation bits to the
media infrastructure uAPI DocBook. Also, they're for 3D formats,
with requre further discussions.

Requested-by: Hans Verkuil <hverkuil@xs4all.nl>
Requested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
8 years ago[media] use https://linuxtv.org for LinuxTV URLs
Mauro Carvalho Chehab [Fri, 4 Dec 2015 12:38:59 +0000 (10:38 -0200)]
[media] use https://linuxtv.org for LinuxTV URLs

While https was always supported on linuxtv.org, only in
Dec 3 2015 the website is using valid certificates.

As we're planning to drop pure http support on some
future, change all references at the media subsystem
to point to the https URL instead.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years agodrm, ipu-v3: use https://linuxtv.org for LinuxTV URL
Mauro Carvalho Chehab [Fri, 4 Dec 2015 12:36:22 +0000 (10:36 -0200)]
drm, ipu-v3: use https://linuxtv.org for LinuxTV URL

While https was always supported on linuxtv.org, only in
Dec 3 2015 the website is using valid certificates.

As we're planning to drop pure http support on some
future, change the references at DRM include and at
the ipu-v3 driver to point to the https://linuxtv.org
URL instead.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years agoWHENCE: use https://linuxtv.org for LinuxTV URLs
Mauro Carvalho Chehab [Fri, 4 Dec 2015 12:34:32 +0000 (10:34 -0200)]
WHENCE: use https://linuxtv.org for LinuxTV URLs

While https was always supported on linuxtv.org, only in
Dec 3 2015 the website is using valid certificates.

As we're planning to drop pure http support on some
future, change the http://linuxtv.org references at firmware/WHENCE
file to point to https://linuxtv.org instead.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years agoMAINTAINERS: use https://linuxtv.org for LinuxTV URLs
Mauro Carvalho Chehab [Fri, 4 Dec 2015 12:31:23 +0000 (10:31 -0200)]
MAINTAINERS: use https://linuxtv.org for LinuxTV URLs

While https was always supported on linuxtv.org, only in
Dec 3 2015 the website is using valid certificates.

As we're planning to drop pure http support on some
future, change all references at MAINTAINERS file
to point to the https URL instead.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] staging: media: lirc: Replace timeval with ktime_t in lirc_parallel.c
Arnd Bergmann [Wed, 25 Nov 2015 15:13:26 +0000 (13:13 -0200)]
[media] staging: media: lirc: Replace timeval with ktime_t in lirc_parallel.c

'struct timeval tv' and 'struct timeval now' is used to calculate the
elapsed time. 'LIRC_SFH506_DELAY' is a delay t_phl in usecs.

32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the lirc_parallel.c file of  media: lirc driver
to use ktime_t.

ktime_get() is  better than using do_gettimeofday(),
because it uses the monotonic clock. ktime_sub is used
to subtract two ktime variables. ktime_to_us() is used to
convert ktime to microsecond.

New ktime_t variable timeout, is added in lirc_off(),to improve
clarity. Introduced a new ktime_t variable in lirc_lirc_irq_handler()
function, to avoid the use of signal variable for storing
seconds in the first part of this function as later it uses
a time unit that is defined by the global "timer" variable.
This makes it more clear.

ktime_set() is used to set a value in seconds to a value in
nanosecond so that ktime_compare() can be used appropriately.
ktime_compare() is used to compare two ktime values.
ktime_add_ns() is used to increment a ktime value by 1 sec.

One comment is also shifted a line up, as it was creating a 80
character warning.

Build tested it. Also tested it with sparse.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] staging: media: lirc: Replace timeval with ktime_t in lirc_sasem.c
Arnd Bergmann [Wed, 25 Nov 2015 15:12:53 +0000 (13:12 -0200)]
[media] staging: media: lirc: Replace timeval with ktime_t in lirc_sasem.c

'struct timeval presstime' and 'struct timeval tv' is used to
calculate the time since the last button press.

32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the media: lirc driver to use ktime_t.

ktime_get() is  better than using do_gettimeofday(), because it uses
the monotonic clock. ktime_sub() are used to subtract two ktime
variables. 'ms' is only used to check how much time has passed by comparing
to 250. So instead of using expensive ktime_to_ms() call, it has been
changed to hold nanoseconds by using ktime_to_ns().

Build tested it. Tested with sparse too.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] staging: media: lirc: Replace timeval with ktime_t in lirc_serial.c
Arnd Bergmann [Wed, 25 Nov 2015 15:11:55 +0000 (13:11 -0200)]
[media] staging: media: lirc: Replace timeval with ktime_t in lirc_serial.c

'struct timeval tv' is used to get current time.
'static struct timeval lasttv' is used to get last interrupt time.

32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the lirc_serial.c file of media: lirc to use
ktime_t.

ktime_get() is  better than using do_gettimeofday(),
because it uses the monotonic clock. ktime_sub is used
to subtract two ktime variables. The check to test time
going backwards is also removed. Intialization to static
variable is also removed. ktime_to_us() is used to convert
ktime_t to microsecond value. deltv is changed to delkt, a
ktime_t type varibale from long to assign the ktime_sub value
directly. ktime_compare is used to compare delkt with 15
seconds, which is changed to a nanosecond value by using
ktime_set().

Build tested it.

Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] radio-bcm2048: fix code indent
Joseph Marrero [Tue, 24 Nov 2015 21:30:18 +0000 (19:30 -0200)]
[media] radio-bcm2048: fix code indent

Fixes a warning message found by checkpatch.pl WARNING:
suspect code indent for conditional statements

Signed-off-by: Joseph Marrero <jmarrero@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] tda10071: Fix dependency to REGMAP_I2C
Matthias Schwarzott [Mon, 23 Nov 2015 19:19:04 +0000 (17:19 -0200)]
[media] tda10071: Fix dependency to REGMAP_I2C

Without I get this error for by dvb-card:
  tda10071: Unknown symbol devm_regmap_init_i2c (err 0)
  cx23885_dvb_register() dvb_register failed err = -22
  cx23885_dev_setup() Failed to register dvb adapters on VID_B

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] dm1105: Remove unnecessary synchronize_irq() before free_irq()
Lars-Peter Clausen [Sat, 21 Nov 2015 11:16:38 +0000 (09:16 -0200)]
[media] dm1105: Remove unnecessary synchronize_irq() before free_irq()

Calling synchronize_irq() right before free_irq() is quite useless. On one
hand the IRQ can easily fire again before free_irq() is entered, on the
other hand free_irq() itself calls synchronize_irq() internally (in a race
condition free way), before any state associated with the IRQ is freed.

Patch was generated using the following semantic patch:
// <smpl>
@@
expression irq;
@@
-synchronize_irq(irq);
 free_irq(irq, ...);
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: rc: remove unneeded code
Heiner Kallweit [Sat, 21 Nov 2015 14:55:03 +0000 (12:55 -0200)]
[media] media: rc: remove unneeded code

Now that that the decoder modules are loaded on-demand we can move
loading the lirc module to rc_register_device directly and remove
unneeded functions and comments.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
8 years ago[media] si2165: Add DVB-C support for HVR-4400/HVR-5500
Matthias Schwarzott [Thu, 19 Nov 2015 20:04:02 +0000 (18:04 -0200)]
[media] si2165: Add DVB-C support for HVR-4400/HVR-5500

It works only for HVR-4400/HVR-5500.
For WinTV-HVR-930C-HD it fails with bad/no reception
for unknown reasons.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] si2165: Prepare si2165_set_frontend() for future DVB-C support
Matthias Schwarzott [Thu, 19 Nov 2015 20:04:01 +0000 (18:04 -0200)]
[media] si2165: Prepare si2165_set_frontend() for future DVB-C support

The current si2165_set_frontend() function actually works only for DVB-T.
Split it into two functions, preparing the code to support DVB-C.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] si2165: set list of DVB-T registers together
Matthias Schwarzott [Thu, 19 Nov 2015 20:04:00 +0000 (18:04 -0200)]
[media] si2165: set list of DVB-T registers together

Use si2165_write_reg_list() to do the DVB-T mode initialization altogether.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] si2165: Simplify si2165_set_if_freq_shift usage
Matthias Schwarzott [Thu, 19 Nov 2015 20:03:58 +0000 (18:03 -0200)]
[media] si2165: Simplify si2165_set_if_freq_shift usage

si2165_set_if_freq_shift() needs to call get_if_frequency() in order to do
the right shift. Add such logic inside the function, simplifying the logic
for the callers.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] si2165: move setting ts config to init
Matthias Schwarzott [Thu, 19 Nov 2015 20:03:57 +0000 (18:03 -0200)]
[media] si2165: move setting ts config to init

The TS config is fixed, so no need to write it for each tune.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] si2165: only write agc registers after reset before start_syncro
Matthias Schwarzott [Thu, 19 Nov 2015 20:03:56 +0000 (18:03 -0200)]
[media] si2165: only write agc registers after reset before start_syncro

Datasheet says they must be rewritten after reset.
But it only makes sense to write them when trying to tune afterwards.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] si2165: create function si2165_write_reg_list for writing register lists
Matthias Schwarzott [Thu, 19 Nov 2015 20:03:55 +0000 (18:03 -0200)]
[media] si2165: create function si2165_write_reg_list for writing register lists

It is common the need of writing a table of values. Add a function to provide a
helper to address such case. This will allow further code cleanups.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>