05 Mar, 2016
1 commit
-
Add missing prefixes for DVB, V4L, and ALSA interface types.
Signed-off-by: Shuah Khan
Acked-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
27 Feb, 2016
3 commits
-
Add non-locking __media_entity_pipeline_start/stop()
interfaces to be called from code paths that hold the
graph_mutex.Signed-off-by: Shuah Khan
Signed-off-by: Mauro Carvalho Chehab -
Export __media_entity_setup_link() to be used from code paths
that hold the graph_mutex.Signed-off-by: Shuah Khan
Signed-off-by: Mauro Carvalho Chehab -
Declare the interface types to be used on alsa for
the new G_TOPOLOGY ioctl.Signed-off-by: Shuah Khan
Acked-by: Takashi Iwai
Signed-off-by: Mauro Carvalho Chehab
19 Feb, 2016
1 commit
-
The allocation takes place in longs. Assign the size of the enum
accordingly.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab
01 Feb, 2016
1 commit
-
Change media_entity_pipeline_stop() to not decrement
stream_count of an inactive media pipeline. Doing so,
results in preventing starting the pipeline.Signed-off-by: Shuah Khan
Signed-off-by: Mauro Carvalho Chehab
11 Jan, 2016
34 commits
-
Sometimes, it is desired to create 1:n and n:1 or even
n:n links between different entities with the same
function.This is actually needed to support DVB devices that
have multiple frontends. While we could do a function
like that internally at the DVB core, such function is
generic enough to be at media-entity, and it could be
useful on some other places.So, add such function.
Signed-off-by: Mauro Carvalho Chehab
-
The DVB drivers may have 257 PADs. Get the next power of two
that would accomodate that amount.Signed-off-by: Mauro Carvalho Chehab
-
Instead of using one u32 counter per type for object IDs, use
just one counter. With such change, it makes sense to simplify
the debug logs too.Signed-off-by: Mauro Carvalho Chehab
-
Some exported functions were still documented at the .c file,
instead of documenting at the .h one.Move the documentation to the right place, as we only use headers
at media device-drivers.xml DocBook.Signed-off-by: Mauro Carvalho Chehab
-
This isn't really a part of any interface drivers are expected to use. In
order to keep drivers from using it, hide it in media-entity.c. This was
always an arbitrary number and should be removed in the long run.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
The bitmaps for entity enumerations used to be statically allocated. Now
that the drivers have been converted to use the new interface which
explicitly initialises the enum objects, drop the pre-allocated bitmaps.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
Initialise a given graph walk object once, and then keep using it whilst
the same pipeline is running. Once the pipeline is stopped, release the
graph walk object.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
This will also mean that the necessary graph related data structures will
be allocated dynamically, removing the need for maximum ID checks.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
The media graph walk requires initialisation and cleanup soon. Update the
users to perform the soon necessary API calls.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
Add media_entity_graph_walk_init() and media_entity_graph_walk_cleanup()
functions in order to dynamically allocate memory for the graph. This is
not done in media_entity_graph_walk_start() as there are situations where
e.g. correct error handling, that itself may not fail, requires successful
graph walk.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
The struct media_entity_graph was allocated in the stack, limiting the
number of entities that could be reasonably allocated. Instead, move the
struct to struct media_pipeline which is typically allocated using
kmalloc() instead.The intent is to keep the enumeration around for later use for the
duration of the streaming. As streaming is eventually stopped, an
unfortunate memory allocation failure would prevent stopping the
streaming. As no memory will need to be allocated, the problem is avoided
altogether.Signed-off-by: Sakari Ailus
Reviewed-by: Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab -
This is useful in e.g. knowing whether certain operations have already
been performed for an entity. The users include the framework itself (for
graph walking) and a number of drivers.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
As pointed by Dan, the commit f8fd4c61b5ae ("[media] media-entity:
protect object creation/removal using spin lock")' leads to the
following static checker warning:drivers/media/media-entity.c:781 media_remove_intf_link()
error: dereferencing freed memory 'link'drivers/media/media-entity.c
777 void media_remove_intf_link(struct media_link *link)
778 {
779 spin_lock(&link->graph_obj.mdev->lock);
780 __media_remove_intf_link(link);
781 spin_unlock(&link->graph_obj.mdev->lock);In practice, I didn't see any troubles even with KASAN enabled. I guess
gcc optimizer internally cached the mdev reference, instead of getting
it twice. Yet, it is a very bad idea to rely on such optimization. So,
let's fix the code.Reported-by: Dan Carpenter
Signed-off-by: Mauro Carvalho Chehab -
Changeset f8fd4c61b5ae ("[media] media-entity: protect object
creation/removal using spin lock") changed the object creation/removal
protection to spin lock, as this is what's used on media-device,
keeping the mutex reserved for graph traversal routines. However, it
also changed the link setup, by mistake.This could cause troubles, as the link setup can affect the graph
traversal, and this is likely the reason for a mutex there.So, revert media_entity_setup_link() to use mutex.
Signed-off-by: Mauro Carvalho Chehab
-
If a different entity->pipe in a pipeline was encountered, a warning was
issued but the execution continued as if nothing had happened. Return an
error instead right there.Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
Instead of flagging an interface link as MEDIA_LNK_FL_INTERFACE_LINK
only when returning to userspace, do it at link creation time.That would allow using such flag internally, and cleans up a
little bit the code for G_TOPOLOGY ioctl.[mchehab@osg.samsung.com: folded with a fixup from Dan Carpenter,
replacing & by &&]
Suggested-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
Commit 86ee417578a2 ("[media] media: convert links from array to list")
had many changes that were automated using coccinelle but the semantic
patch was not smart enough to rely on operators precedence and avoid
using unnecessary enclosing parenthesis.This patch removes them since are not needed.
Suggested-by: Laurent Pinchart
Signed-off-by: Javier Martinez Canillas
Signed-off-by: Mauro Carvalho Chehab -
Several additional functions are described at media-entity.c.
Moving them to the header file, to make the code cleaner and
to have all such macros at the same place.Signed-off-by: Mauro Carvalho Chehab
-
Those media_obj_* functions are actually creating/destroying
media graph objects. So, rename them to better represent
what they're actually doing.No functional changes.
This was created via this small shell script:
for i in $(git grep -l media_gobj_init); do sed s,media_gobj_init,media_gobj_create,g a && mv a $i; done
for i in $(git grep -l media_gobj_remove); do sed s,media_gobj_remove,media_gobj_destroy,g a && mv a $i; doneSuggested-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab -
> > > + if (rlink != link->reverse) {
> > > + r++;
> >
> > The variable is incremented here but otherwise never used, you can remove it.Suggested-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
Move this function to happen earlier, in order to avoid
a uneeded forward declaration.Suggested-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
No functional changes.
Suggested-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
This function was used in the past to free the links
that were allocated by the media controller core.However, this is not needed anymore. We should likely
get rid of the funcion on some function, but, for now,
let's just convert into an inlined function and let the
compiler to get rid of it.Suggested-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
With the MC next gen rework, what's left for media_entity_init()
is to just initialize the PADs. However, certain devices, like
a FLASH led/light doesn't have any input or output PAD.So, there's no reason why calling media_entity_init() would be
mandatory. Also, despite its name, what this function actually
does is to initialize the PADs data. So, rename it to
media_entity_pads_init() in order to reflect that.The media entity actual init happens during entity register,
at media_device_register_entity(). We should move init of
num_links and num_backlinks to it.Signed-off-by: Mauro Carvalho Chehab
-
If an entity is registered with a media device before is initialized
with media_device_register_entity(), the number of pads won't be set
so media_device_register_entity() won't create pad objects and add
it to the media device pads list.Do this at entity initialization time if the entity was registered
before so the graph is complete and correct regardless of the order
in which the entities are initialized and registered.Suggested-by: Mauro Carvalho Chehab
Signed-off-by: Javier Martinez Canillas
Signed-off-by: Mauro Carvalho Chehab -
We should not be creating device nodes at IRQ contexts. So,
the only flags we'll be using will be GFP_KERNEL. Let's
remove the gfp_flags, in order to make the interface simpler.If we ever need it, it would be easy to revert those changes.
While here, remove an extra blank line.
Suggested-by: Sakari Ailus
Acked-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
Due to the graph traversal algorithm currently in usage, we
need a copy of all data links. Those backlinks should not be
send to userspace, as otherwise, all links there will be
duplicated.Acked-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
The logic is testing if num_links==0 at the wrong place. Due to
that, a backlink may be kept without removal, causing KASAN
to complain about usage after free during either entity or
link removal.Signed-off-by: Mauro Carvalho Chehab
-
The media_entity_cleanup() function only cleans up the entity links list
but this operation is already made in media_device_unregister_entity().In most cases this should be harmless (besides having duplicated code)
since the links list would be empty so the iteration would not happen
but the links list is initialized in media_device_register_entity() so
if a driver fails to register an entity with a media device and clean up
the entity in the error path, a NULL deference pointer error will happen.So don't try to empty the links list in media_entity_cleanup() since
is either done already or haven't been initialized yet.Signed-off-by: Javier Martinez Canillas
-
Some parts of the media controller are using mutexes while
others are using spin locks in order to protect creation
and removal of elements in the graph. That's wrong!Also, the V4L2 core can remove graph elements on non-interactive
context:
BUG: sleeping function called from invalid context at include/linux/sched.h:2776Fix it by always using spin locks for graph element addition/removal,
just like entity creation/removal is protected at media-device.cSigned-off-by: Mauro Carvalho Chehab
-
Just like what's done with entities, when the media controller is
unregistered, release any interface and interface links that
might still be there.Signed-off-by: Mauro Carvalho Chehab
-
Add functions to explicitly unregister all entity links.
This function is called automatically when an entity
link is destroyed.Acked-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab -
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
Signed-off-by: Mauro Carvalho Chehab -
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 padsfor each entity:
for each link:
store linkfor each interface:
for each link:
store linkWith 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
Signed-off-by: Mauro Carvalho Chehab