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>
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%).
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>
[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.
[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>
[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.
[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.
[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.
[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>
[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.
[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>
[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>
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>
[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:
[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>
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>
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>
[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>
[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>
[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>
[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.
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.
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.
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.
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>
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.
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.
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.
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.
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.
[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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Hans Verkuil [Mon, 30 Nov 2015 12:26:35 +0000 (10:26 -0200)]
[media] cx25840: fix cx25840_s_stream for cx2388x and cx231xx
For those two devices the code wrote to addresses 0x115/6, but on
those devices those addresses have nothing to do with power controls.
So clearly this never worked. Rather than writing to bogus addresses,
just do nothing for the cx2388x and cx231xx.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Mon, 30 Nov 2015 12:19:41 +0000 (10:19 -0200)]
[media] cx25840: relax a Vsrc check
The cx23888 reports a slightly different Vsrc value than the other
chip variants do. Relax the check by 1, otherwise cx25840_set_fmt()
would fail for the cx23888.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Mon, 30 Nov 2015 12:03:30 +0000 (10:03 -0200)]
[media] cx231xx: fix NTSC cropcap, add missing cropcap for 417
The pixelaspect ratio was set incorrectly for 60Hz formats.
And since cropcap wasn't implemented at all for the -417 (compressed
video) the pixelaspect was unknown for compressed video.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Mon, 30 Nov 2015 11:59:18 +0000 (09:59 -0200)]
[media] cx23885: fix format/crop handling
While testing the cx23885 driver with various TV standards I found
a number of bugs:
1) norm_maxw() returned 768 instead of 720 for PAL formats. This should
always be 720, so drop this inline function and just always use 720.
2) cropcap() was missing, so the pixelaspect was never known and qv4l2 would
scale the image incorrectly. Add cropcap support.
3) cx23885_set_tvnorm() should just return 0 if the same standard was
set again. If another standard is set, then reset the width/height and
call set_fmt for the subdevs.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
The patch doesn't add the corresponding documentation bits to the
media infrastructure uAPI DocBook. Also, they're for 3D formats,
with requre further discussions.
Requested-by: Hans Verkuil <hverkuil@xs4all.nl> Requested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drm, ipu-v3: use https://linuxtv.org for LinuxTV URL
While https was always supported on linuxtv.org, only in
Dec 3 2015 the website is using valid certificates.
As we're planning to drop pure http support on some
future, change the references at DRM include and at
the ipu-v3 driver to point to the https://linuxtv.org
URL instead.
While https was always supported on linuxtv.org, only in
Dec 3 2015 the website is using valid certificates.
As we're planning to drop pure http support on some
future, change the http://linuxtv.org references at firmware/WHENCE
file to point to https://linuxtv.org instead.
Arnd Bergmann [Wed, 25 Nov 2015 15:13:26 +0000 (13:13 -0200)]
[media] staging: media: lirc: Replace timeval with ktime_t in lirc_parallel.c
'struct timeval tv' and 'struct timeval now' is used to calculate the
elapsed time. 'LIRC_SFH506_DELAY' is a delay t_phl in usecs.
32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the lirc_parallel.c file of media: lirc driver
to use ktime_t.
ktime_get() is better than using do_gettimeofday(),
because it uses the monotonic clock. ktime_sub is used
to subtract two ktime variables. ktime_to_us() is used to
convert ktime to microsecond.
New ktime_t variable timeout, is added in lirc_off(),to improve
clarity. Introduced a new ktime_t variable in lirc_lirc_irq_handler()
function, to avoid the use of signal variable for storing
seconds in the first part of this function as later it uses
a time unit that is defined by the global "timer" variable.
This makes it more clear.
ktime_set() is used to set a value in seconds to a value in
nanosecond so that ktime_compare() can be used appropriately.
ktime_compare() is used to compare two ktime values.
ktime_add_ns() is used to increment a ktime value by 1 sec.
One comment is also shifted a line up, as it was creating a 80
character warning.
Arnd Bergmann [Wed, 25 Nov 2015 15:12:53 +0000 (13:12 -0200)]
[media] staging: media: lirc: Replace timeval with ktime_t in lirc_sasem.c
'struct timeval presstime' and 'struct timeval tv' is used to
calculate the time since the last button press.
32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the media: lirc driver to use ktime_t.
ktime_get() is better than using do_gettimeofday(), because it uses
the monotonic clock. ktime_sub() are used to subtract two ktime
variables. 'ms' is only used to check how much time has passed by comparing
to 250. So instead of using expensive ktime_to_ms() call, it has been
changed to hold nanoseconds by using ktime_to_ns().
Arnd Bergmann [Wed, 25 Nov 2015 15:11:55 +0000 (13:11 -0200)]
[media] staging: media: lirc: Replace timeval with ktime_t in lirc_serial.c
'struct timeval tv' is used to get current time.
'static struct timeval lasttv' is used to get last interrupt time.
32-bit systems using 'struct timeval' will break in the year 2038,
so we have to replace that code with more appropriate types.
This patch changes the lirc_serial.c file of media: lirc to use
ktime_t.
ktime_get() is better than using do_gettimeofday(),
because it uses the monotonic clock. ktime_sub is used
to subtract two ktime variables. The check to test time
going backwards is also removed. Intialization to static
variable is also removed. ktime_to_us() is used to convert
ktime_t to microsecond value. deltv is changed to delkt, a
ktime_t type varibale from long to assign the ktime_sub value
directly. ktime_compare is used to compare delkt with 15
seconds, which is changed to a nanosecond value by using
ktime_set().
Without I get this error for by dvb-card:
tda10071: Unknown symbol devm_regmap_init_i2c (err 0)
cx23885_dvb_register() dvb_register failed err = -22
cx23885_dev_setup() Failed to register dvb adapters on VID_B
[media] dm1105: Remove unnecessary synchronize_irq() before free_irq()
Calling synchronize_irq() right before free_irq() is quite useless. On one
hand the IRQ can easily fire again before free_irq() is entered, on the
other hand free_irq() itself calls synchronize_irq() internally (in a race
condition free way), before any state associated with the IRQ is freed.
Patch was generated using the following semantic patch:
// <smpl>
@@
expression irq;
@@
-synchronize_irq(irq);
free_irq(irq, ...);
// </smpl>
Heiner Kallweit [Sat, 21 Nov 2015 14:55:03 +0000 (12:55 -0200)]
[media] media: rc: remove unneeded code
Now that that the decoder modules are loaded on-demand we can move
loading the lirc module to rc_register_device directly and remove
unneeded functions and comments.