26 Feb, 2018
1 commit
-
The media.h public header is very messy. It mixes legacy and 'new' defines
and it is not easy to figure out what should and what shouldn't be used. It
also contains confusing comment that are either out of date or completely
uninteresting for anyone that needs to use this header.The patch groups all entity functions together, including the 'old' defines
based on the old range base. The reader just wants to know about the available
functions and doesn't care about what range is used.All legacy defines are moved to the end of the header, so it is easier to
locate them and just ignore them.The legacy structs in the struct media_entity_desc are put under
also a much more effective signal to the reader that they shouldn't be used
compared to the old method of relying on '#if 1' followed by a comment.The unused MEDIA_INTF_T_ALSA_* defines are also moved to the end of the header
in the legacy area. They are also dropped from intf_type() in media-entity.c.All defines are also aligned at the same tab making the header easier to read.
Signed-off-by: Hans Verkuil
[mchehab@s-opensource.com: removed lots of spaces before tabs; typo changes ->change ]
Signed-off-by: Mauro Carvalho Chehab
05 Oct, 2017
1 commit
-
The active and has_no_links arrays will overrun in
media_entity_pipeline_start() if there's an entity which has more than
MEDIA_ENTITY_MAX_PAD pads. Ensure in media_entity_init() that there are
fewer pads than that.Signed-off-by: Sakari Ailus
Acked-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
21 Jul, 2017
1 commit
-
The local pad parameter in media_entity_remote_pad() is not modified.
Make that explicit by adding a const modifier.Signed-off-by: Todor Tomov
Acked-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab
23 Jun, 2017
1 commit
-
Drivers must not perform unbalanced calls to stop the entity pipeline,
however if they do they will fault in the core media code, as the
entity->pipe will be set as NULL. We handle this gracefully in the core
with a WARN for the developer.Replace the erroneous check on zero streaming counts, with a check on
NULL pipe elements instead, as this is the symptom of unbalanced
media_pipeline_stop calls.Signed-off-by: Kieran Bingham
Signed-off-by: Laurent Pinchart
Signed-off-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab
20 Jun, 2017
1 commit
-
This is a wrapper around the media entity get_fwnode_pad operation.
Signed-off-by: Niklas Söderlund
Acked-by: Sakari Ailus
Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
19 Apr, 2017
1 commit
-
Fix kernel Oops NULL pointer deference
Call dev_dbg_obj only after checking if gobj->mdev is not NULLSigned-off-by: Helen Koike
Signed-off-by: Mauro Carvalho Chehab
30 Jan, 2017
2 commits
-
Use dev_dbg() to tell about the progress of the graph traversal algorithm.
This is intended to make debugging of the algorithm easier.Signed-off-by: Sakari Ailus
Reviewed-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
Instead of double quotes, use single quotes to quote entity names. Using
single quotes is consistent with the English language and is also in line
with the practices across the kernel.Signed-off-by: Sakari Ailus
Reviewed-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab
28 Jan, 2017
2 commits
-
With media_entity_graph_walk_next() getting more and more complicated (and
especially so with has_routing() support added), split the function into
two.Signed-off-by: Sakari Ailus
Reviewed-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
The media_entity_pipeline_start() and media_entity_pipeline_stop()
functions are renamed as media_pipeline_start() and media_pipeline_stop(),
respectively. The reason is two-fold: the pipeline struct is, rightly,
already called media_pipeline (rather than media_entity_pipeline) and what
this really is about is a pipeline. A pipeline consists of entities ---
and, well, other objects embedded in these entities.As the pipeline object will be in the future moved from entities to pads
in order to support multiple pipelines through a single entity, do the
renaming now.Similarly, functions operating on struct media_entity_graph as well as the
struct itself are renamed by dropping the "entity_" part from the prefix
of the function family and the data structure. The graph traversal which
is what the functions are about is not specifically about entities only
and will operate on pads for the same reason as the media pipeline.The patch has been generated using the following command:
git grep -l media_entity |xargs perl -i -pe '
s/media_entity_pipeline/media_pipeline/g;
s/media_entity_graph/media_graph/g'And a few manual edits related to line start alignment and line wrapping.
Signed-off-by: Sakari Ailus
Acked-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab
27 Jan, 2017
3 commits
-
Commit 3801bc7d1b8d ("[media] media: Media Controller fix to not let
stream_count go negative") added a sanity check for negative stream_count,
but a failure of the check remained silent. Make sure the failure is
noticed.Signed-off-by: Sakari Ailus
Reviewed-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
There's a sanity check for the stream count remaining positive or zero on
error path, but instead of performing the check on the traversed entity it
is performed on the entity where traversal ends. Fix this.Fixes: commit 3801bc7d1b8d ("[media] media: Media Controller fix to not let stream_count go negative")
Signed-off-by: Sakari Ailus
Reviewed-by: Laurent Pinchart
Signed-off-by: Mauro Carvalho Chehab -
Drop the FSF's postal address from the source code files that typically
contain mostly the license text. Of the 628 removed instances, 578 are
outdated.The patch has been created with the following command without manual edits:
git grep -l "675 Mass Ave\|59 Temple Place\|51 Franklin St" -- \
drivers/media/ include/media|while read i; do i=$i perl -e '
open(F,"< $ENV{i}");
$a=join("", );
$a =~ s/[ \t]*\*\n.*You should.*\n.*along with.*\n.*(\n.*USA.*$)?\n//m
&& $a =~ s/(^.*)Or, (point your browser to) /$1To obtain the license, $2\n$1/m;
close(F);
open(F, "> $ENV{i}");
print F $a;
close(F);'; doneSigned-off-by: Sakari Ailus
19 Nov, 2016
1 commit
-
media_gobj_destroy() may be called twice on one instance - once by
media_device_unregister() and again by dvb_media_device_free(). The
function media_remove_intf_links() establishes and documents the
convention that mdev==NULL means that the object is not registered,
but nobody ever NULLs this variable. So this patch really implements
this behavior, and adds another mdev==NULL check to
media_gobj_destroy() to protect against double removal.Signed-off-by: Max Kellermann
Signed-off-by: Mauro Carvalho Chehab
09 Sep, 2016
1 commit
-
This will allow adding new operations without increasing the
media_device structure size for drivers that don't implement any media
device operation.Signed-off-by: Laurent Pinchart
Signed-off-by: Sakari Ailus
Acked-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
24 Aug, 2016
1 commit
-
Some touch controllers send out touch data in a similar way to a
greyscale frame grabber.Add new device type VFL_TYPE_TOUCH:
- This uses a new device prefix v4l-touch for these devices, to stop
generic capture software from treating them as webcams. Otherwise,
touch is treated similarly to video capture.
- Add V4L2_INPUT_TYPE_TOUCH
- Add MEDIA_INTF_T_V4L_TOUCH
- Add V4L2_CAP_TOUCH to indicate device is a touch deviceAdd formats:
- V4L2_TCH_FMT_DELTA_TD16 for signed 16-bit touch deltas
- V4L2_TCH_FMT_DELTA_TD08 for signed 16-bit touch deltas
- V4L2_TCH_FMT_TU16 for unsigned 16-bit touch data
- V4L2_TCH_FMT_TU08 for unsigned 8-bit touch dataThis support will be used by:
- Atmel maXTouch (atmel_mxt_ts)
- Synaptics RMI4.
- sur40Signed-off-by: Nick Dyer
Tested-by: Chris Healy
Signed-off-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
Acked-by: Dmitry Torokhov
29 Apr, 2016
1 commit
-
According to the V4L2 API, the VIDIOC_STREAMON ioctl should return EPIPE
if there is a format mismatch in the pipeline configuration.As the .vidioc_streamon in the v4l2_ioctl_ops usually forwards the error
caused by the v4l2_subdev_link_validate_default (if it is in use), it
should return -EPIPE when it detect the mismatch.When an entity is connected to a non enabled link,
media_entity_pipeline_start should return -ENOLINK, as the link does not
exist.Signed-off-by: Helen Mae Koike Fornazier
Acked-by: Sakari Ailus
Signed-off-by: Mauro Carvalho Chehab
21 Apr, 2016
1 commit
-
Right now, the lock schema for media_device struct is messy,
since sometimes, it is protected via a spin lock, while, for
media graph traversal, it is protected by a mutex.Solve this conflict by always using a mutex.
As a side effect, this prevents a bug when the media notifiers
is called at atomic context, while running the notifier callback:BUG: sleeping function called from invalid context at mm/slub.c:1289
in_atomic(): 1, irqs_disabled(): 0, pid: 3479, name: modprobe
4 locks held by modprobe/3479:
#0: (&dev->mutex){......}, at: [] __driver_attach+0xa3/0x160
#1: (&dev->mutex){......}, at: [] __driver_attach+0xb1/0x160
#2: (register_mutex#5){+.+.+.}, at: [] usb_audio_probe+0x257/0x1c90 [snd_usb_audio]
#3: (&(&mdev->lock)->rlock){+.+.+.}, at: [] media_device_register_entity+0x1cb/0x700 [media]
CPU: 2 PID: 3479 Comm: modprobe Not tainted 4.5.0-rc3+ #49
Hardware name: /NUC5i7RYB, BIOS RYBDWi35.86A.0350.2015.0812.1722 08/12/2015
0000000000000000 ffff8803b3f6f288 ffffffff81933901 ffff8803c4bae000
ffff8803c4bae5c8 ffff8803b3f6f2b0 ffffffff811c6af5 ffff8803c4bae000
ffffffff8285d7f6 0000000000000509 ffff8803b3f6f2f0 ffffffff811c6ce5
Call Trace:
[] dump_stack+0x85/0xc4
[] ___might_sleep+0x245/0x3a0
[] __might_sleep+0x95/0x1a0
[] kmem_cache_alloc_trace+0x20e/0x300
[] ? media_add_link+0x4d/0x140 [media]
[] media_add_link+0x4d/0x140 [media]
[] media_create_pad_link+0xa1/0x600 [media]
[] au0828_media_graph_notify+0x173/0x360 [au0828]
[] ? media_gobj_create+0x1ba/0x480 [media]
[] media_device_register_entity+0x3ab/0x700 [media]Reviewed-by: Javier Martinez Canillas
Acked-by: Sakari Ailus
Acked-by: Hans Verkuil
Signed-off-by: Mauro Carvalho Chehab
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
16 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