Re: [PATCH] rtl28xxu: fix control message flaws

2015-11-06 Thread Benjamin Larsson

On 10/10/2015 06:45 PM, Antti Palosaari wrote:

Add lock to prevent concurrent access for control message as control
message function uses shared buffer. Without the lock there may be
remote control polling which messes the buffer causing IO errors.
Increase buffer size and add check for maximum supported message
length.



This patch made at least one of my devices work. Before my log was full 
of errors.


Totally unrelated I do get a fail on loading the firmware. Just retrying 
made it work eventually.


[  143.286498] mn88473 19-0018: downloading firmware from file 
'dvb-demod-mn88473-01.fw'

[  143.551497] mn88473 19-0018: firmware download failed=-32
[  143.826792] rtl2832 19-0010: i2c reg read failed -32
[  143.903215] mn88473 19-0018: downloading firmware from file 
'dvb-demod-mn88473-01.fw'

[  144.345554] mn88473 19-0018: firmware download failed=-32
[  331.060613] mn88473 19-0018: downloading firmware from file 
'dvb-demod-mn88473-01.fw'

[  331.477234] mn88473 19-0018: firmware download failed=-32
[  354.997771] rtl2832 19-0010: i2c reg read failed -32
[  358.591754] mn88473 19-0018: downloading firmware from file 
'dvb-demod-mn88473-01.fw'

[  359.115582] mn88473 19-0018: firmware parity check succeeded=0x20

MvH
Benjamin Larsson
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: ERRORS

2015-11-06 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Sat Nov  7 04:00:24 CET 2015
git branch: test
git hash:   79f5b6ae960d380c829fb67d5dadcd1d025d2775
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: 0.4.5-rc1
smatch version: host hardware:  x86_64
host os:4.2.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
linux-3.19-i686: OK
linux-4.0-i686: OK
linux-4.1.1-i686: OK
linux-4.2-i686: OK
linux-4.3-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-x86_64: OK
linux-4.1.1-x86_64: OK
linux-4.2-x86_64: OK
linux-4.3-x86_64: ERRORS
apps: WARNINGS
spec-git: OK
sparse: ERRORS
smatch: OK

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Saturday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Saturday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] [media] c8sectpfe: Combine three checks into a single if block

2015-11-06 Thread walter harms


Am 05.11.2015 19:50, schrieb SF Markus Elfring:
> From: Markus Elfring 
> Date: Thu, 5 Nov 2015 19:23:50 +0100
> 
> The variable "tsin" was checked three times in a loop iteration of the
> c8sectpfe_tuner_unregister_frontend() function.
> This implementation detail could be improved by the combination of the
> involved statements into a single if block so that this variable will be
> checked only once there.
> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c | 17 
> +
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c 
> b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
> index 07fd6d9..2dfbe8a 100644
> --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
> +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
> @@ -209,17 +209,18 @@ void c8sectpfe_tuner_unregister_frontend(struct 
> c8sectpfe *c8sectpfe,
>  
>   tsin = fei->channel_data[n];


if you do "if (!tsin) continue ;"
you can save one indent level

re,
 wh

>  
> - if (tsin && tsin->frontend) {
> - dvb_unregister_frontend(tsin->frontend);
> - dvb_frontend_detach(tsin->frontend);
> - }
> + if (tsin) {
> + if (tsin->frontend) {
> + dvb_unregister_frontend(tsin->frontend);
> + dvb_frontend_detach(tsin->frontend);
> + }
>  
> - if (tsin)
>   i2c_put_adapter(tsin->i2c_adapter);
>  
> - if (tsin && tsin->i2c_client) {
> - module_put(tsin->i2c_client->dev.driver->owner);
> - i2c_unregister_device(tsin->i2c_client);
> + if (tsin->i2c_client) {
> + module_put(tsin->i2c_client->dev.driver->owner);
> + i2c_unregister_device(tsin->i2c_client);
> + }
>   }
>   }
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Fwd: Dvb-fe-tool add features

2015-11-06 Thread Tomáš Vítek



  Hello Mauro,


   Please add to dvb-fe-tool function as a femon from dvb-apps.

   ,,-c number : samples to take (default 0 = infinite),,

   This is the number of repetitions of reading signal.

   It's important for my statistics adapter. Thanks.





--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Geniatech / Mygica T230

2015-11-06 Thread Mike Parkins
Hi Olli,
Here is the dmesg:

[ 2427.795294] dvb-usb: found a 'Mygica T230 DVB-T/T2/C' in warm state.
[ 2427.795299] power control: 1
[ 2428.030801] dvb-usb: will pass the complete MPEG2 transport stream
to the software demuxer.
[ 2428.030962] DVB: registering new adapter (Mygica T230 DVB-T/T2/C)
[ 2428.033853] i2c i2c-17: Added multiplexed i2c bus 18
[ 2428.033858] si2168 17-0064: Silicon Labs Si2168 successfully attached
[ 2428.037201] si2157 18-0060: Silicon Labs Si2147/2148/2157/2158
successfully attached
[ 2428.037213] usb 2-3: DVB: registering adapter 0 frontend 0 (Silicon
Labs Si2168)...
[ 2428.037651] input: IR-receiver inside an USB DVB receiver as
/devices/pci:00/:00:1d.7/usb2/2-3/input/input22
[ 2428.037822] dvb-usb: schedule remote query interval to 100 msecs.
[ 2428.037825] power control: 0
[ 2428.037931] dvb-usb: Mygica T230 DVB-T/T2/C successfully
initialized and connected.
[ 2443.077697] power control: 1
[ 2443.316664] si2168 17-0064: found a 'Silicon Labs Si2168-B40'
[ 2443.330381] si2168 17-0064: downloading firmware from file
'dvb-demod-si2168-b40-01.fw'
[ 2443.914601] si2168 17-0064: firmware version: 4.0.4
[ 2443.925860] si2157 18-0060: found a 'Silicon Labs Si2158-A20'
[ 2443.925893] si2157 18-0060: downloading firmware from file
'dvb-tuner-si2158-a20-01.fw'
[ 2444.992678] si2157 18-0060: firmware version: 2.1.6
[ 2445.300551] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2445.308867] dmxdev: section callback 00 b0 65 10 44 c5
[ 2445.310228] function : dvb_dmxdev_filter_set, PID=0x0064, flags=05, timeout=0
[ 2445.328722] dmxdev: section callback 02 b0 ac 10 44 c3
[ 2445.330152] function : dvb_dmxdev_filter_set, PID=0x00c8, flags=05, timeout=0
[ 2445.351512] dmxdev: section callback 02 b0 a4 10 bf c3
[ 2445.352869] function : dvb_dmxdev_filter_set, PID=0x012c, flags=05, timeout=0
[ 2445.445188] dmxdev: section callback 02 b0 a4 10 c0 e7
[ 2445.446547] function : dvb_dmxdev_filter_set, PID=0x01f4, flags=05, timeout=0
[ 2445.455193] dmxdev: section callback 02 b0 80 11 00 c1
[ 2445.456549] function : dvb_dmxdev_filter_set, PID=0x0a8c, flags=05, timeout=0
[ 2445.555496] dmxdev: section callback 02 b0 73 11 40 c1
[ 2445.556851] function : dvb_dmxdev_filter_set, PID=0x0190, flags=05, timeout=0
[ 2446.560312] function : dvb_dmxdev_filter_set, PID=0x02bc, flags=05, timeout=0
[ 2447.563434] function : dvb_dmxdev_filter_set, PID=0x0320, flags=05, timeout=0
[ 2448.566597] function : dvb_dmxdev_filter_set, PID=0x0258, flags=05, timeout=0
[ 2449.569747] function : dvb_dmxdev_filter_set, PID=0x0578, flags=05, timeout=0
[ 2450.572904] function : dvb_dmxdev_filter_set, PID=0x05dc, flags=05, timeout=0
[ 2451.576058] function : dvb_dmxdev_filter_set, PID=0x0640, flags=05, timeout=0
[ 2452.579212] function : dvb_dmxdev_filter_set, PID=0x06a4, flags=05, timeout=0
[ 2453.582369] function : dvb_dmxdev_filter_set, PID=0x0708, flags=05, timeout=0
[ 2454.585524] function : dvb_dmxdev_filter_set, PID=0x076c, flags=05, timeout=0
[ 2455.588533] function : dvb_dmxdev_filter_set, PID=0x07d0, flags=05, timeout=0
[ 2456.591563] function : dvb_dmxdev_filter_set, PID=0x0c80, flags=05, timeout=0
[ 2457.594595] function : dvb_dmxdev_filter_set, PID=0x03e8, flags=05, timeout=0
[ 2458.597793] function : dvb_dmxdev_filter_set, PID=0x044c, flags=05, timeout=0
[ 2459.600934] function : dvb_dmxdev_filter_set, PID=0x04b0, flags=05, timeout=0
[ 2460.604085] function : dvb_dmxdev_filter_set, PID=0x0514, flags=05, timeout=0
[ 2461.607246] function : dvb_dmxdev_filter_set, PID=0x0384, flags=05, timeout=0
[ 2462.610396] function : dvb_dmxdev_filter_set, PID=0x0010, flags=05, timeout=0
[ 2474.630386] function : dvb_dmxdev_filter_set, PID=0x0011, flags=05, timeout=0
[ 2476.942501] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2478.356279] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2479.666940] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2480.979264] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2482.290109] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2483.600647] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2485.116700] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2486.633288] function : dvb_dmxdev_filter_set, PID=0x, flags=05, timeout=0
[ 2487.640495] power control: 0

and here is the irc log from August when I first asked about this:

* Topic for #linuxtv set by unknown (Thu May 29 20:24:17 2008)
 is there anyone can help with a T230 usb DVB stick please?
* debianuser1 is now known as debianuser
 mp_, DVB-C with that?
 no, dvb-t
 it works as far as tuning in a mux but then no TS appears
 run: dmesg | pastebinit
 and send me the link produced
 I'd guess: you are missing either demod or tuner firmware from
/lib/firmware
 firmware is ok, 2 files and I confirmed the md5sum
 can't get pastebinit to work! bad API key
 i can cut/paste the dmesg 

[PATCH] [media] hackrf: moving pointer reference before kfree

2015-11-06 Thread Saurabh Sengar
accessing a pointer after free could possible lead to segmentation
fault, hence correcting it

Signed-off-by: Saurabh Sengar 
---
 drivers/media/usb/hackrf/hackrf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/hackrf/hackrf.c 
b/drivers/media/usb/hackrf/hackrf.c
index e05bfec..faf3670 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -1528,9 +1528,9 @@ err_v4l2_ctrl_handler_free_tx:
 err_v4l2_ctrl_handler_free_rx:
v4l2_ctrl_handler_free(>rx_ctrl_handler);
 err_kfree:
+   dev_dbg(dev->dev, "failed=%d\n", ret);
kfree(dev);
 err:
-   dev_dbg(dev->dev, "failed=%d\n", ret);
return ret;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PVR-250 Composite 3 unavailable [Re: ivtv driver]

2015-11-06 Thread Warren Sturm
On Mon, 2015-10-26 at 19:49 -0400, Andy Walls wrote:
> On October 26, 2015 7:13:52 PM EDT, Warren Sturm <
> warren.st...@gmail.com> wrote:
> > Hi Andy.
> > 
> > I don't know whether this was intended but the pvr250 lost the
> > composite 3 input when going from kernel version 4.1.10 to 4.2.3.
> > 
> > This is on a Fedora 22 x86_64 system.
> > 
> > 
> > Thanks for any insight.
> 
> Unintentional.
> 
> I'm guessing this commit was the problem:
> 
> http://git.linuxtv.org/cgit.cgi/media_tree.git/commit/drivers/media/p
> ci/ivtv/ivtv-driver.c?id=09290cc885937cab3b2d60a6d48fe3d2d3e04061
> 
> Could you confirm?
> 
> R,
> Andy

Ok.  I rebuilt the SRPM for kernel-4.2.5-201 with the patch reverted
and installed it.

uname -a
Linux wrs 4.2.5-201.fc22.x86_64 #1 SMP Fri Nov 6 00:13:17 MST 2015 x86_64 
x86_64 x86_64 GNU/Linux

Attached are the v4l2-ctl --list-inputs for the respective kernels.

Hope this is sufficient confirmation.



ioctl: VIDIOC_ENUMINPUT
Input   : 0
Name: Tuner 1
Type: 0x0001
Audioset: 0x0007
Tuner   : 0x
Standard: 0x1000 ( NTSC )
Status  : 0

Input   : 1
Name: S-Video 1
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 2
Name: Composite 1
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 3
Name: S-Video 2
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 4
Name: Composite 2
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 5
Name: Composite 3
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0
ioctl: VIDIOC_ENUMINPUT
Input   : 0
Name: Tuner 1
Type: 0x0001
Audioset: 0x0003
Tuner   : 0x
Standard: 0x1000 ( NTSC )
Status  : 0

Input   : 1
Name: S-Video 1
Type: 0x0002
Audioset: 0x0003
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 2
Name: Composite 1
Type: 0x0002
Audioset: 0x0003
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 3
Name: S-Video 2
Type: 0x0002
Audioset: 0x0003
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 4
Name: Composite 2
Type: 0x0002
Audioset: 0x0003
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0
ioctl: VIDIOC_ENUMINPUT
Input   : 0
Name: Tuner 1
Type: 0x0001
Audioset: 0x0007
Tuner   : 0x
Standard: 0x1000 ( NTSC )
Status  : 0

Input   : 1
Name: S-Video 1
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 2
Name: Composite 1
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 3
Name: S-Video 2
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 4
Name: Composite 2
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0

Input   : 5
Name: Composite 3
Type: 0x0002
Audioset: 0x0007
Tuner   : 0x
Standard: 0x00FF ( PAL NTSC SECAM )
Status  : 0


Re: [PATCH 1/3] [media] mt9v032: Add reset and standby gpios

2015-11-06 Thread Rob Herring
On Fri, Nov 06, 2015 at 02:13:43PM +0100, Markus Pargmann wrote:
> Add optional reset and standby gpios. The reset gpio is used to reset
> the chip in power_on().
> 
> The standby gpio is not used currently. It is just unset, so the chip is
> not in standby.
> 
> Signed-off-by: Markus Pargmann 
> Reviewed-by: Philipp Zabel 
> ---
>  .../devicetree/bindings/media/i2c/mt9v032.txt  |  2 ++

Acked-by: Rob Herring 

>  drivers/media/i2c/mt9v032.c| 23 
> ++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/mt9v032.txt 
> b/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
> index 202565313e82..100f0ae43269 100644
> --- a/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
> +++ b/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
> @@ -20,6 +20,8 @@ Optional Properties:
>  
>  - link-frequencies: List of allowed link frequencies in Hz. Each frequency is
>   expressed as a 64-bit big-endian integer.
> +- reset-gpios: GPIO handle which is connected to the reset pin of the chip.
> +- standby-gpios: GPIO handle which is connected to the standby pin of the 
> chip.
>  
>  For further reading on port node refer to
>  Documentation/devicetree/bindings/media/video-interfaces.txt.
> diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
> index a68ce94ee097..4aefde9634f5 100644
> --- a/drivers/media/i2c/mt9v032.c
> +++ b/drivers/media/i2c/mt9v032.c
> @@ -24,6 +24,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -251,6 +252,8 @@ struct mt9v032 {
>  
>   struct regmap *regmap;
>   struct clk *clk;
> + struct gpio_desc *reset_gpio;
> + struct gpio_desc *standby_gpio;
>  
>   struct mt9v032_platform_data *pdata;
>   const struct mt9v032_model_info *model;
> @@ -312,16 +315,26 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
>   struct regmap *map = mt9v032->regmap;
>   int ret;
>  
> + gpiod_set_value_cansleep(mt9v032->reset_gpio, 1);
> +
>   ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk);
>   if (ret < 0)
>   return ret;
>  
> + /* system clock has to be enabled before releasing the reset */
>   ret = clk_prepare_enable(mt9v032->clk);
>   if (ret)
>   return ret;
>  
>   udelay(1);
>  
> + gpiod_set_value_cansleep(mt9v032->reset_gpio, 0);
> +
> + /*
> +  * After releasing reset, it can take up to 1us until the chip is done
> +  */
> + udelay(1);
> +
>   /* Reset the chip and stop data read out */
>   ret = regmap_write(map, MT9V032_RESET, 1);
>   if (ret < 0)
> @@ -954,6 +967,16 @@ static int mt9v032_probe(struct i2c_client *client,
>   if (IS_ERR(mt9v032->clk))
>   return PTR_ERR(mt9v032->clk);
>  
> + mt9v032->reset_gpio = devm_gpiod_get_optional(>dev, "reset",
> +   GPIOD_OUT_HIGH);
> + if (IS_ERR(mt9v032->reset_gpio))
> + return PTR_ERR(mt9v032->reset_gpio);
> +
> + mt9v032->standby_gpio = devm_gpiod_get_optional(>dev, "standby",
> + GPIOD_OUT_LOW);
> + if (IS_ERR(mt9v032->standby_gpio))
> + return PTR_ERR(mt9v032->standby_gpio);
> +
>   mutex_init(>power_lock);
>   mt9v032->pdata = pdata;
>   mt9v032->model = (const void *)did->driver_data;
> -- 
> 2.6.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] [media] mt9v032: Add reset and standby gpios

2015-11-06 Thread Markus Pargmann
Add optional reset and standby gpios. The reset gpio is used to reset
the chip in power_on().

The standby gpio is not used currently. It is just unset, so the chip is
not in standby.

Signed-off-by: Markus Pargmann 
Reviewed-by: Philipp Zabel 
---
 .../devicetree/bindings/media/i2c/mt9v032.txt  |  2 ++
 drivers/media/i2c/mt9v032.c| 23 ++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/i2c/mt9v032.txt 
b/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
index 202565313e82..100f0ae43269 100644
--- a/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
+++ b/Documentation/devicetree/bindings/media/i2c/mt9v032.txt
@@ -20,6 +20,8 @@ Optional Properties:
 
 - link-frequencies: List of allowed link frequencies in Hz. Each frequency is
expressed as a 64-bit big-endian integer.
+- reset-gpios: GPIO handle which is connected to the reset pin of the chip.
+- standby-gpios: GPIO handle which is connected to the standby pin of the chip.
 
 For further reading on port node refer to
 Documentation/devicetree/bindings/media/video-interfaces.txt.
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index a68ce94ee097..4aefde9634f5 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -251,6 +252,8 @@ struct mt9v032 {
 
struct regmap *regmap;
struct clk *clk;
+   struct gpio_desc *reset_gpio;
+   struct gpio_desc *standby_gpio;
 
struct mt9v032_platform_data *pdata;
const struct mt9v032_model_info *model;
@@ -312,16 +315,26 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
struct regmap *map = mt9v032->regmap;
int ret;
 
+   gpiod_set_value_cansleep(mt9v032->reset_gpio, 1);
+
ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk);
if (ret < 0)
return ret;
 
+   /* system clock has to be enabled before releasing the reset */
ret = clk_prepare_enable(mt9v032->clk);
if (ret)
return ret;
 
udelay(1);
 
+   gpiod_set_value_cansleep(mt9v032->reset_gpio, 0);
+
+   /*
+* After releasing reset, it can take up to 1us until the chip is done
+*/
+   udelay(1);
+
/* Reset the chip and stop data read out */
ret = regmap_write(map, MT9V032_RESET, 1);
if (ret < 0)
@@ -954,6 +967,16 @@ static int mt9v032_probe(struct i2c_client *client,
if (IS_ERR(mt9v032->clk))
return PTR_ERR(mt9v032->clk);
 
+   mt9v032->reset_gpio = devm_gpiod_get_optional(>dev, "reset",
+ GPIOD_OUT_HIGH);
+   if (IS_ERR(mt9v032->reset_gpio))
+   return PTR_ERR(mt9v032->reset_gpio);
+
+   mt9v032->standby_gpio = devm_gpiod_get_optional(>dev, "standby",
+   GPIOD_OUT_LOW);
+   if (IS_ERR(mt9v032->standby_gpio))
+   return PTR_ERR(mt9v032->standby_gpio);
+
mutex_init(>power_lock);
mt9v032->pdata = pdata;
mt9v032->model = (const void *)did->driver_data;
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] [media] mt9v032: Add V4L2 controls for AEC and AGC

2015-11-06 Thread Markus Pargmann
This patch adds V4L2 controls for Auto Exposure Control and Auto Gain
Control settings. These settings include low pass filter, update
frequency of these settings and the update interval for those units.

Signed-off-by: Markus Pargmann 
---
 drivers/media/i2c/mt9v032.c | 153 
 1 file changed, 153 insertions(+)

diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 943c3f39ea73..978ae8cbb0cc 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -133,9 +133,16 @@
 #defineMT9V032_TEST_PATTERN_GRAY_DIAGONAL  (3 << 11)
 #defineMT9V032_TEST_PATTERN_ENABLE (1 << 13)
 #defineMT9V032_TEST_PATTERN_FLIP   (1 << 14)
+#define MT9V032_AEC_LPF0xa8
+#define MT9V032_AGC_LPF0xaa
+#define MT9V032_DESIRED_BIN0xa5
+#define MT9V032_AEC_UPDATE_INTERVAL0xa6
+#define MT9V032_AGC_UPDATE_INTERVAL0xa9
 #define MT9V032_AEC_AGC_ENABLE 0xaf
 #defineMT9V032_AEC_ENABLE  (1 << 0)
 #defineMT9V032_AGC_ENABLE  (1 << 1)
+#define MT9V024_AEC_MAX_SHUTTER_WIDTH  0xad
+#define MT9V032_AEC_MAX_SHUTTER_WIDTH  0xbd
 #define MT9V032_THERMAL_INFO   0xc1
 
 enum mt9v032_model {
@@ -162,6 +169,7 @@ struct mt9v032_model_data {
unsigned int min_shutter;
unsigned int max_shutter;
unsigned int pclk_reg;
+   unsigned int aec_max_shutter_reg;
 };
 
 struct mt9v032_model_info {
@@ -185,6 +193,7 @@ static const struct mt9v032_model_data mt9v032_model_data[] 
= {
.min_shutter = MT9V032_TOTAL_SHUTTER_WIDTH_MIN,
.max_shutter = MT9V032_TOTAL_SHUTTER_WIDTH_MAX,
.pclk_reg = MT9V032_PIXEL_CLOCK,
+   .aec_max_shutter_reg = MT9V032_AEC_MAX_SHUTTER_WIDTH,
}, {
/* MT9V024, MT9V034 */
.min_row_time = 690,
@@ -194,6 +203,7 @@ static const struct mt9v032_model_data mt9v032_model_data[] 
= {
.min_shutter = MT9V034_TOTAL_SHUTTER_WIDTH_MIN,
.max_shutter = MT9V034_TOTAL_SHUTTER_WIDTH_MAX,
.pclk_reg = MT9V034_PIXEL_CLOCK,
+   .aec_max_shutter_reg = MT9V024_AEC_MAX_SHUTTER_WIDTH,
},
 };
 
@@ -265,6 +275,12 @@ struct mt9v032 {
struct {
struct v4l2_ctrl *test_pattern;
struct v4l2_ctrl *test_pattern_color;
+   struct v4l2_ctrl *desired_bin;
+   struct v4l2_ctrl *aec_lpf;
+   struct v4l2_ctrl *agc_lpf;
+   struct v4l2_ctrl *aec_update_interval;
+   struct v4l2_ctrl *agc_update_interval;
+   struct v4l2_ctrl *aec_max_shutter_width;
};
 };
 
@@ -643,6 +659,33 @@ static int mt9v032_set_selection(struct v4l2_subdev 
*subdev,
  */
 
 #define V4L2_CID_TEST_PATTERN_COLOR(V4L2_CID_USER_BASE | 0x1001)
+/*
+ * Value between 1 and 64 to set the desired bin. This is effectively a measure
+ * of how bright the image is supposed to be. Both AGC and AEC try to reach
+ * this.
+ */
+#define V4L2_CID_DESIRED_BIN   (V4L2_CID_USER_BASE | 0x1002)
+/*
+ * LPF is the low pass filter capability of the chip. Both AEC and AGC have
+ * this setting. This limits the speed in which AGC/AEC adjust their settings.
+ * Possible values are 0-2. 0 means no LPF. For 1 and 2 this equation is used:
+ * if |(Calculated new exp - current exp)| > (current exp / 4)
+ * next exp = Calculated new exp
+ * else
+ * next exp = Current exp +- (Calculated new exp / 2^LPF)
+ */
+#define V4L2_CID_AEC_LPF   (V4L2_CID_USER_BASE | 0x1003)
+#define V4L2_CID_AGC_LPF   (V4L2_CID_USER_BASE | 0x1004)
+/*
+ * Value between 0 and 15. This is the number of frames being skipped before
+ * updating the auto exposure/gain.
+ */
+#define V4L2_CID_AEC_UPDATE_INTERVAL   (V4L2_CID_USER_BASE | 0x1005)
+#define V4L2_CID_AGC_UPDATE_INTERVAL   (V4L2_CID_USER_BASE | 0x1006)
+/*
+ * Maximum shutter width used for AEC.
+ */
+#define V4L2_CID_AEC_MAX_SHUTTER_WIDTH (V4L2_CID_USER_BASE | 0x1007)
 
 static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
 {
@@ -712,6 +755,28 @@ static int mt9v032_s_ctrl(struct v4l2_ctrl *ctrl)
break;
}
return regmap_write(map, MT9V032_TEST_PATTERN, data);
+
+   case V4L2_CID_DESIRED_BIN:
+   return regmap_write(map, MT9V032_DESIRED_BIN, ctrl->val);
+
+   case V4L2_CID_AEC_LPF:
+   return regmap_write(map, MT9V032_AEC_LPF, ctrl->val);
+
+   case V4L2_CID_AGC_LPF:
+   return regmap_write(map, MT9V032_AGC_LPF, ctrl->val);
+
+   case V4L2_CID_AEC_UPDATE_INTERVAL:
+ 

[PATCH 2/3] [media] mt9v032: Do not unset master_mode

2015-11-06 Thread Markus Pargmann
The power_on function of the driver resets the chip and sets the
CHIP_CONTROL register to 0. This switches the operating mode to slave.
The s_stream function sets the correct mode. But this caused problems on
a board where the camera chip is operated as master. The camera started
after a random amount of time streaming an image, I observed between 10
and 300 seconds.

The STRFM_OUT and STLN_OUT pins are not connected on this board which
may cause some issues in slave mode. I could not find any documentation
about this.

Keeping the chip in master mode after the reset helped to fix this
issue for me.

Signed-off-by: Markus Pargmann 
---
 drivers/media/i2c/mt9v032.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 4aefde9634f5..943c3f39ea73 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -344,7 +344,8 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
if (ret < 0)
return ret;
 
-   return regmap_write(map, MT9V032_CHIP_CONTROL, 0);
+   return regmap_write(map, MT9V032_CHIP_CONTROL,
+   MT9V032_CHIP_CONTROL_MASTER_MODE);
 }
 
 static void mt9v032_power_off(struct mt9v032 *mt9v032)
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html