platform/kernel/linux-rpi.git
8 years ago[media] media-entity: unregister entity links
Mauro Carvalho Chehab [Mon, 24 Aug 2015 11:46:46 +0000 (08:46 -0300)]
[media] media-entity: unregister entity links

Add functions to explicitly unregister all entity links.
This function is called automatically when an entity
link is destroyed.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl
Mauro Carvalho Chehab [Sun, 23 Aug 2015 13:36:41 +0000 (10:36 -0300)]
[media] media-device: add support for MEDIA_IOC_G_TOPOLOGY ioctl

Add support for the new MEDIA_IOC_G_TOPOLOGY ioctl, according
with the RFC for the MC next generation.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media_device: add a topology version field
Mauro Carvalho Chehab [Sun, 23 Aug 2015 12:40:26 +0000 (09:40 -0300)]
[media] media_device: add a topology version field

Every time a graph object is added or removed, the version
of the topology changes. That's a requirement for the new
MEDIA_IOC_G_TOPOLOGY, in order to allow userspace to know
that the topology has changed after a previous call to it.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media-device: add pads and links to media_device
Mauro Carvalho Chehab [Sun, 23 Aug 2015 11:00:33 +0000 (08:00 -0300)]
[media] media-device: add pads and links to media_device

The MC next gen API sends objects to userspace grouped by
their types.

In the case of pads and links, in order to improve performance
and have a simpler code, the best is to store them also on
separate linked lists at MC.

If we don't do that, we would need this kind of interaction
to send data to userspace (code is in structured english):

for each entity:
for each pad:
store pads

for each entity:
for each link:
store link

for each interface:
for each link:
store link

With would require one nested loop for pads and two nested
loops for links. By using  separate linked lists for them,
just one loop would be enough.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: move mdev list init to gobj
Mauro Carvalho Chehab [Sun, 23 Aug 2015 10:51:33 +0000 (07:51 -0300)]
[media] media: move mdev list init to gobj

Let's control the topology changes inside the graph_object. So, move the
addition and removal of interfaces/entities from the mdev lists to
media_gobj_init() and media_gobj_remove().

The main reason is that mdev should have lists for all object types, as
the new MC api will require to store objects in separate places.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: Use a macro to interate between all interfaces
Mauro Carvalho Chehab [Sun, 23 Aug 2015 10:51:22 +0000 (07:51 -0300)]
[media] media: Use a macro to interate between all interfaces

Just like we do with entities, use a similar macro for the
interfaces loop.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] uapi/media.h: Add MEDIA_IOC_G_TOPOLOGY ioctl
Mauro Carvalho Chehab [Sun, 23 Aug 2015 11:28:21 +0000 (08:28 -0300)]
[media] uapi/media.h: Add MEDIA_IOC_G_TOPOLOGY ioctl

Add a new ioctl that will report the entire topology on
one go.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: report if a pad is sink or source at debug msg
Mauro Carvalho Chehab [Fri, 21 Aug 2015 21:26:42 +0000 (18:26 -0300)]
[media] media: report if a pad is sink or source at debug msg

Sometimes, it is important to see if the created pad is
sink or source. Add info to track that.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] dvb: modify core to implement interfaces/entities at MC new gen
Mauro Carvalho Chehab [Fri, 21 Aug 2015 19:18:18 +0000 (16:18 -0300)]
[media] dvb: modify core to implement interfaces/entities at MC new gen

The Media Controller New Generation redefines the types for both
interfaces and entities to be used on DVB. Make the needed
changes at the DVB core for all interfaces, entities and
data and interface links to appear in the graph.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] DocBook: update descriptions for the media controller entities
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:40 +0000 (22:12 -0300)]
[media] DocBook: update descriptions for the media controller entities

Cleanup the media controller entities description:
- remove MEDIA_ENT_T_DEVNODE and MEDIA_ENT_T_V4L2_SUBDEV entity
  types, as they don't mean anything;
- add MEDIA_ENT_T_UNKNOWN with a proper description;
- remove ALSA and FB entity types. Those should not be used, as
  the types are deprecated. We'll soon be adidng ALSA, but with
  a different entity namespace;
- improve the description of some entities.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media.h: don't use legacy entity macros at Kernel
Mauro Carvalho Chehab [Sat, 29 Aug 2015 17:50:46 +0000 (14:50 -0300)]
[media] media.h: don't use legacy entity macros at Kernel

Put the legacy MEDIA_ENT_* macros under a #ifndef __KERNEL__,
in order to be sure that none of those old symbols are used
inside the Kernel.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media controller: get rid of entity subtype on Kernel
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:39 +0000 (22:12 -0300)]
[media] media controller: get rid of entity subtype on Kernel

Don't use anymore the type/subtype entity data/macros
inside the Kernel.

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] v4l2-subdev: use MEDIA_ENT_T_UNKNOWN for new subdevs
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:38 +0000 (22:12 -0300)]
[media] v4l2-subdev: use MEDIA_ENT_T_UNKNOWN for new subdevs

Instead of abusing MEDIA_ENT_T_V4L2_SUBDEV, initialize
new subdev entities as MEDIA_ENT_T_UNKNOWN.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] omap4iss: change the logic that checks if an entity is a subdev
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:37 +0000 (22:12 -0300)]
[media] omap4iss: change the logic that checks if an entity is a subdev

As we're getting rid of an specific number range for the V4L2 subdev,
we need to replace the check for MEDIA_ENT_T_V4L2_SUBDEV by a macro.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] davinci_vbpe: stop MEDIA_ENT_T_V4L2_SUBDEV abuse
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:36 +0000 (22:12 -0300)]
[media] davinci_vbpe: stop MEDIA_ENT_T_V4L2_SUBDEV abuse

This driver is abusing MEDIA_ENT_T_V4L2_SUBDEV:

- it uses a hack to check if the remote entity is a subdev;
- it still uses the legacy entity subtype check macro, that
  will be removed soon.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5k5baf: fix subdev type
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:35 +0000 (22:12 -0300)]
[media] s5k5baf: fix subdev type

The driver creates two subdevs, one for the image sensor pixel array
(and the related readout logic) and one for an ISP.

The first subdev already uses the MEDIA_ENT_T_V4L2_SUBDEV_SENSOR type,
but the second subdev isn't a sensor pixel array.

So, rename the second subdev as MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] s5c73m3: fix subdev type
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:34 +0000 (22:12 -0300)]
[media] s5c73m3: fix subdev type

This sensor driver is abusing MEDIA_ENT_T_V4L2_SUBDEV, creating
some subdevs with a non-existing type.

As this is a sensor driver, one of the entries is
MEDIA_ENT_T_CAM_SENSOR. The other one will be using
MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN, because the subdev is not
any of the already existing types.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] omap3/omap4/davinci: get rid of MEDIA_ENT_T_V4L2_SUBDEV abuse
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:33 +0000 (22:12 -0300)]
[media] omap3/omap4/davinci: get rid of MEDIA_ENT_T_V4L2_SUBDEV abuse

On omap3/omap4/davinci drivers, MEDIA_ENT_T_V4L2_SUBDEV macro is
abused in order to "simplify" the pad checks.

Basically, it does a logical or of this macro, in order to check
for a local index and if the entity is either a subdev or not.

As we'll get rid of MEDIA_ENT_T_V4L2_SUBDEV macro, replace it by
2 << 16 where it occurs, and add a note saying that the code
there is actually a hack.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: use macros to check for V4L2 subdev entities
Mauro Carvalho Chehab [Fri, 8 May 2015 01:12:32 +0000 (22:12 -0300)]
[media] media: use macros to check for V4L2 subdev entities

Instead of relying on media subtype, use the new macros to detect
if an entity is a subdev or an A/V DMA entity.

Please note that most drivers assume that there's just AV_DMA or
V4L2 subdevs. This is not true anymore, as we've added MC support
for DVB, and there are plans to add support for ALSA and FB/DRM
too.

Ok, on the current pipelines supported by those drivers, just V4L
stuff are there, but, assuming that some day a pipeline that also
works with other subsystems will ever added, it is better to add
explicit checks for the AV_DMA stuff.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: add macros to check if subdev or V4L2 DMA
Mauro Carvalho Chehab [Fri, 21 Aug 2015 15:17:40 +0000 (12:17 -0300)]
[media] media: add macros to check if subdev or V4L2 DMA

As we'll be removing entity subtypes from the Kernel, we need
to provide a way for drivers and core to check if a given
entity is represented by a V4L2 subdev or if it is an V4L2
I/O entity (typically with DMA).

Drivers that create entities that don't belong to any defined subdev
category should use MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] replace all occurrences of MEDIA_ENT_T_DEVNODE_DVB
Mauro Carvalho Chehab [Fri, 21 Aug 2015 14:54:40 +0000 (11:54 -0300)]
[media] replace all occurrences of MEDIA_ENT_T_DEVNODE_DVB

Now that interfaces and entities are distinct, it makes no sense
of keeping something named as MEDIA_ENT_T_DEVNODE_DVB_foo.

Made via this script:
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_DVB_,MEDIA_ENT_T_DVB_, <$i >a && mv a $i; done
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DVB_DVR,MEDIA_ENT_T_DVB_TSOUT, <$i >a && mv a $i; done
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DVB_FE,MEDIA_ENT_T_DVB_DEMOD, <$i >a && mv a $i; done
for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DVB_NET,MEDIA_ENT_T_DVB_DEMOD_NET_DECAP, <$i >a && mv a $i; done

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L
Mauro Carvalho Chehab [Fri, 21 Aug 2015 14:50:17 +0000 (11:50 -0300)]
[media] replace all occurrences of MEDIA_ENT_T_DEVNODE_V4L

Now that interfaces and entities are distinct, it makes no sense
of keeping something named as MEDIA_ENT_T_DEVNODE.

This change was done with this script:

for i in $(git grep -l MEDIA_ENT_T|grep -v uapi/linux/media.h); do sed s,MEDIA_ENT_T_DEVNODE_V4L,MEDIA_ENT_T_V4L2_VIDEO, <$i >a && mv a $i; done

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] uapi/media.h: Fix entity namespace
Mauro Carvalho Chehab [Fri, 21 Aug 2015 14:40:34 +0000 (11:40 -0300)]
[media] uapi/media.h: Fix entity namespace

Now that interfaces got created, we need to fix the entity
namespace.

So, let's create a consistent new namespace and add backward
compatibility macros to keep the old namespace preserved.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] dvbdev: add support for indirect interface links
Mauro Carvalho Chehab [Fri, 21 Aug 2015 12:32:38 +0000 (09:32 -0300)]
[media] dvbdev: add support for indirect interface links

Some interfaces indirectly control multiple entities.
Add support for those.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: add a linked list to track interfaces by mdev
Mauro Carvalho Chehab [Fri, 21 Aug 2015 12:23:22 +0000 (09:23 -0300)]
[media] media: add a linked list to track interfaces by mdev

The media device should list the interface objects, so add a linked list
for those interfaces in struct media_device.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] dvbdev: add support for interfaces
Mauro Carvalho Chehab [Fri, 21 Aug 2015 11:20:22 +0000 (08:20 -0300)]
[media] dvbdev: add support for interfaces

Now that the infrastruct for that is set, add support for
interfaces.

Please notice that we're missing two links:
DVB FE intf    -> tuner
DVB demux intf -> dvr

Those should be added latter, after having the entire graph
set. With the current infrastructure, those should be added
at dvb_create_media_graph(), but it would also require some
extra core changes, to allow the function to enumerate the
interfaces.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media-entity: add a helper function to create interface
Mauro Carvalho Chehab [Fri, 28 Aug 2015 18:43:36 +0000 (15:43 -0300)]
[media] media-entity: add a helper function to create interface

As we'll be adding other interface types in the future, put the
common interface create code on a separate function.

Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
8 years ago[media] media: add support to link interfaces and entities
Mauro Carvalho Chehab [Fri, 7 Aug 2015 13:36:25 +0000 (10:36 -0300)]
[media] media: add support to link interfaces and entities

Now that we have a new graph object called "interfaces", we
need to be able to link them to the entities.

Add a linked list to the interfaces to allow them to be
linked to the entities.

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

Remove entity name from the link as this exists only if the object
type is PAD on both link ends.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
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>