Let's add media controller support for this driver and register it
for both V4L and DVB.
The media controller on this driver is not mandatory, as it can fully
work without it. So, if the media controller register fails, just print
an error message, but proceed with device registering.
[media] media: Fix DVB devnode representation at media controller
The previous provision for DVB media controller support were to
define an ID (likely meaning the adapter number) for the DVB
devnodes.
This is just plain wrong. Just like V4L, DVB devices (and any other
device node)) are uniquely identified via a (major, minor) tuple.
This is enough to uniquely identify a devnode, no matter what
API it implements.
So, before we go too far, let's mark the old v4l, fb, dvb and alsa
"devnode" info as deprecated, and just call it as "dev".
We can latter add fields specific to each API if needed.
As we don't want to break compilation on already existing apps,
let's just keep the old definitions as-is, adding a note that
those are deprecated at media-entity.h.
[media] gpsca: remove the risk of a division by zero
As reported by Peter Kovar, there's a potential risk of a division by
zero on calls to jpeg_set_qual() when quality is zero.
As quality can't be 0 or lower than that, add an extra clause to cover
this special case.
Signed-off-by: Luis de Bethencourt <luis.bg@samsung.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Olli Salonen [Fri, 16 Jan 2015 12:35:19 +0000 (09:35 -0300)]
[media] si2168: return error if set_frontend is called with invalid parameters
This patch should is based on Antti's silabs branch.
According to dvb-frontend.h set_frontend may be called with bandwidth_hz set to 0 if automatic bandwidth is required. Si2168 does not support automatic bandwidth and does not declare FE_CAN_BANDWIDTH_AUTO in caps.
This patch will change the behaviour in a way that EINVAL is returned if bandwidth_hz is 0.
Signed-off-by: Olli Salonen <olli.salonen@iki.fi> Reviewed-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] lmedm04: Create frontend call back for read status
Create dm04_read_status to check lock through either interrupt values
or directly by the call back.
When the device is not streaming the frontends original call back is
used. When streaming has started it turns off I2C messaging by
setting st->i2c_talk_onoff to zero. I2C can only be turn on again
by one of the other allowed frontend calls.
All old code is removed from lme2510_msg and this function only needs
to set st->i2c_talk_onoff to 1.
The lock status is saved and when the frondend is locked is maintained
by lme2510_int_response who will now just kill the lock.
The call back for rs2000 tuner is nologer required.
X-Patchwork-Delegate: m.chehab@samsung.com
Fix the following smatch warning:
drivers/media/pci/cx88//cx88-dvb.c:1508 dvb_register() warn: if statement not indented
As complained by smatch:
drivers/media/usb/dvb-usb-v2/rtl28xxu.c:1159 rtl2832u_tuner_attach() info: 'pdata' is not actually initialized (unreached code).
Cc: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/dvb-frontends/rtl2832.c:157:5: warning: no previous prototype for ‘rtl2832_bulk_write’ [-Wmissing-prototypes]
int rtl2832_bulk_write(struct i2c_client *client, unsigned int reg,
^
drivers/media/dvb-frontends/rtl2832.c:169:5: warning: no previous prototype for ‘rtl2832_update_bits’ [-Wmissing-prototypes]
int rtl2832_update_bits(struct i2c_client *client, unsigned int reg,
^
drivers/media/dvb-frontends/rtl2832.c:181:5: warning: no previous prototype for ‘rtl2832_bulk_read’ [-Wmissing-prototypes]
int rtl2832_bulk_read(struct i2c_client *client, unsigned int reg, void *val,
Cc: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/dvb-frontends/rtl2830.c:21:5: warning: no previous prototype for ‘rtl2830_bulk_write’ [-Wmissing-prototypes]
int rtl2830_bulk_write(struct i2c_client *client, unsigned int reg,
^
drivers/media/dvb-frontends/rtl2830.c:33:5: warning: no previous prototype for ‘rtl2830_update_bits’ [-Wmissing-prototypes]
int rtl2830_update_bits(struct i2c_client *client, unsigned int reg,
^
drivers/media/dvb-frontends/rtl2830.c:45:5: warning: no previous prototype for ‘rtl2830_bulk_read’ [-Wmissing-prototypes]
int rtl2830_bulk_read(struct i2c_client *client, unsigned int reg, void *val,
^
Cc: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Thu, 18 Dec 2014 10:22:46 +0000 (07:22 -0300)]
[media] rtl2832: implement own lock for regmap
Introduce own lock to silence lockdep warning. lockdep validator
makes wrong decision when two similar (&map->mutex) locks were taken
recursively, even those are different mutexes in a two different
drivers. After that patch, functionality remains same, but mutex names
are different. That is a temporary hack, proper solution is make
regmap aware of locked nested locking rules.
=============================================
[ INFO: possible recursive locking detected ]
3.18.0-rc4+ #4 Tainted: G O
---------------------------------------------
kdvb-ad-0-fe-0/2814 is trying to acquire lock:
(&map->mutex){+.+.+.}, at: [<ffffffff814ec90f>] regmap_lock_mutex+0x2f/0x40
but task is already holding lock:
(&map->mutex){+.+.+.}, at: [<ffffffff814ec90f>] regmap_lock_mutex+0x2f/0x40
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&map->mutex);
lock(&map->mutex);
*** DEADLOCK ***
May be due to missing lock nesting notation
1 lock held by kdvb-ad-0-fe-0/2814:
#0: (&map->mutex){+.+.+.}, at: [<ffffffff814ec90f>] regmap_lock_mutex+0x2f/0x40
Antti Palosaari [Tue, 23 Dec 2014 16:14:36 +0000 (13:14 -0300)]
[media] rtl28xxu: add heuristic to detect chip type
Detect automatically whether chip is old RTL2831U or newer
RTL2832U/RTL2832P. Detection is based I2C command that is found only
from newer RTL2832U models.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Thu, 18 Dec 2014 09:30:32 +0000 (06:30 -0300)]
[media] rtl2832: remove internal mux I2C adapter
There was 2 muxed I2C adapters, one for demod tuner bus and one for
internal use. Idea of internal I2C adapter was to force I2C repeater
close when demod access its registers. Driver has also delayed work
queue based method to close I2C repeater.
After regmap conversion internal I2C adapter based repeater close
left unused - only work queue method was in use. We could not use
internal mux adapter method with regmap as it makes recursive regmap
call, which causes deadlock as regmap has own locking. Due to that
remove whole method totally.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Wed, 17 Dec 2014 11:25:03 +0000 (08:25 -0300)]
[media] rtl2832_sdr: refcount to rtl28xxu
We are consumer of DVB frontend provided by rtl28xxu module. Due to
that we must use refcount to ensure none could remove rtl28xxu when
we are alive (or when we are streaming, if more fine-grained
refcounting is wanted).
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Wed, 17 Dec 2014 11:16:10 +0000 (08:16 -0300)]
[media] rtl28xxu: do not refcount rtl2832_sdr module
This driver, rtl28xxu, offers frontend service for rtl2832_sdr
module, thus we are producer and rtl2832_sdr module is consumer.
Due to that, reference counting should be done in way rtl2832_sdr
takes refrence to rtl28xxu. Remove wrong refcount.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Wed, 17 Dec 2014 05:55:41 +0000 (02:55 -0300)]
[media] rtl28xxu: fix DVB FE callback
DVB FE callback functionality went broken after I moved tuners to
demod muxed I2C adapter. That happens because driver state was
carried by I2C adapter and when mux is used there is one adapter
more in a chain.
USB adapter <-> I2C adapter <-> muxed I2C adapter
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Tue, 16 Dec 2014 17:51:33 +0000 (14:51 -0300)]
[media] rtl2832: implement sleep
Put demod to soft reset in order to save power when sleep. That drops
power usage ~30mA @5V on USB dongle I tested. In real life it does
not matter much as USB IF powers off demod too, but now it is done
twice - demod and USB IF.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Tue, 16 Dec 2014 13:09:20 +0000 (10:09 -0300)]
[media] rtl2832_sdr: convert to platform driver
That SDR driver module was abusing DVB frontend SEC (satellite
equipment controller) device and due to that it was also using
legacy DVB binding. Platform bus is pseudo-bus provided by kernel
driver model and it fits cases like that, where any other busses
are not suitable.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Mon, 15 Dec 2014 04:17:25 +0000 (01:17 -0300)]
[media] rtl2832: merge reg page as a part of reg address
Chips uses 8-bit register addresses with 5 pages. Extend register
address by using register page as a first byte of address, defining
virtual register addresses. That is common method of handling
register pages and regmap also uses it. Remove page + address
conversion glue which was there for regmap.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Sun, 14 Dec 2014 19:39:37 +0000 (16:39 -0300)]
[media] rtl2832: remove unneeded software reset from init()
There is no need to do software reset on init() as it is done a bit
later on end of set_frontend(). Software reset usually means
restarting (resetting to starting point) chip internal state machine
(FSM). Naturally it is done after all parameters are programmed.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Sun, 14 Dec 2014 15:15:55 +0000 (12:15 -0300)]
[media] rtl2832: define more demod lock statuses
Demod lock flags are derived from demod state machine states. States
are running from 1 to 11, where highest state 11 means demod is
fully locked and streaming. Naturally smaller state numbers means
there is some partial locks.
Define now state 10 as missing synch and lock.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Sat, 13 Dec 2014 03:37:43 +0000 (00:37 -0300)]
[media] rtl2832: rename driver state variable from 'priv' to 'dev'
Rename it device state variable to dev. Both priv and dev are very
common terms for such variable in kernel, but I like use dev in
order to keep drivers consistent.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Sat, 13 Dec 2014 02:16:19 +0000 (23:16 -0300)]
[media] rtl2832: add platform data callbacks for exported resources
Add callback for all of those functions which are currently
exported using EXPORT_SYMBOL. That allows us convert every user to
callbacks and eventually all exported symbols could be removed.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Tue, 9 Dec 2014 19:14:41 +0000 (16:14 -0300)]
[media] rtl2830: implement own I2C locking
Own I2C locking is needed due to two special reasons:
1) Chips uses multiple register pages/banks on single I2C slave.
Page is changed via I2C register access.
2) Chip offers muxed/gated I2C adapter for tuner. Gate/mux is
controlled by I2C register access.
Due to these reasons, I2C locking did not fit very well.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Tue, 9 Dec 2014 01:47:21 +0000 (22:47 -0300)]
[media] rtl2830: carry pointer to I2C client for every function
As a I2C driver struct i2c_client is top level structure representing
the driver. Use it as parameter to carry all needed information for
each function in order to simplify things.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Wed, 17 Dec 2014 11:10:49 +0000 (08:10 -0300)]
[media] dvb-usb-v2: add pointer to 'struct usb_interface' for driver usage
Top level pointer on USB probe is struct usb_interface *. Add that
pointer to struct dvb_usb_device that drivers could use it, for
dev_* logging and more.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>