[PATCH V2 -next] [media] media: i2c: lm3560: fix missing unlock on error in lm3560_get_ctrl().

2013-12-05 Thread Daniel Jeong
Sorry I should have checked below things before sending the first patch.
Correct reference of reading values. (rval -> reg_val)
Add the missing unlock before return from function lm3560_get_ctrl()
to avoid deadlock. 
Thank you Dan Carpenter & Sakari.


Signed-off-by: Daniel Jeong 
---
 drivers/media/i2c/lm3560.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index 3317a9a..ab5857d 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -172,28 +172,28 @@ static int lm3560_flash_brt_ctrl(struct lm3560_flash 
*flash,
 static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)
 {
struct lm3560_flash *flash = to_lm3560_flash(ctrl, led_no);
+   int rval = -EINVAL;
 
mutex_lock(&flash->lock);
 
if (ctrl->id == V4L2_CID_FLASH_FAULT) {
-   int rval;
s32 fault = 0;
unsigned int reg_val;
rval = regmap_read(flash->regmap, REG_FLAG, ®_val);
if (rval < 0)
-   return rval;
-   if (rval & FAULT_SHORT_CIRCUIT)
+   goto out;
+   if (reg_val & FAULT_SHORT_CIRCUIT)
fault |= V4L2_FLASH_FAULT_SHORT_CIRCUIT;
-   if (rval & FAULT_OVERTEMP)
+   if (reg_val & FAULT_OVERTEMP)
fault |= V4L2_FLASH_FAULT_OVER_TEMPERATURE;
-   if (rval & FAULT_TIMEOUT)
+   if (reg_val & FAULT_TIMEOUT)
fault |= V4L2_FLASH_FAULT_TIMEOUT;
ctrl->cur.val = fault;
-   return 0;
}
 
+out:
mutex_unlock(&flash->lock);
-   return -EINVAL;
+   return rval;
 }
 
 static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)
-- 
1.7.9.5

--
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

2013-12-05 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:   Fri Dec  6 04:02:22 CET 2013
git branch: test
git hash:   3f823e094b935c1882605f8720336ee23433a16d
gcc version:i686-linux-gcc (GCC) 4.8.1
sparse version: 0.4.5-rc1
host hardware:  x86_64
host os:3.12-0.slh.2-amd64

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: 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.31.14-i686: ERRORS
linux-2.6.32.27-i686: ERRORS
linux-2.6.33.7-i686: WARNINGS
linux-2.6.34.7-i686: WARNINGS
linux-2.6.35.9-i686: WARNINGS
linux-2.6.36.4-i686: WARNINGS
linux-2.6.37.6-i686: WARNINGS
linux-2.6.38.8-i686: WARNINGS
linux-2.6.39.4-i686: WARNINGS
linux-3.0.60-i686: WARNINGS
linux-3.1.10-i686: WARNINGS
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: WARNINGS
linux-3.5.7-i686: WARNINGS
linux-3.6.11-i686: WARNINGS
linux-3.7.4-i686: WARNINGS
linux-3.8-i686: WARNINGS
linux-3.9.2-i686: WARNINGS
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12-i686: OK
linux-3.13-rc1-i686: OK
linux-2.6.31.14-x86_64: ERRORS
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: WARNINGS
linux-2.6.34.7-x86_64: WARNINGS
linux-2.6.35.9-x86_64: WARNINGS
linux-2.6.36.4-x86_64: WARNINGS
linux-2.6.37.6-x86_64: WARNINGS
linux-2.6.38.8-x86_64: WARNINGS
linux-2.6.39.4-x86_64: WARNINGS
linux-3.0.60-x86_64: WARNINGS
linux-3.1.10-x86_64: WARNINGS
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: WARNINGS
linux-3.5.7-x86_64: WARNINGS
linux-3.6.11-x86_64: WARNINGS
linux-3.7.4-x86_64: WARNINGS
linux-3.8-x86_64: WARNINGS
linux-3.9.2-x86_64: WARNINGS
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12-x86_64: OK
linux-3.13-rc1-x86_64: OK
apps: WARNINGS
spec-git: OK
sparse version: 0.4.5-rc1
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.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] media: Add BCM2048 radio driver

2013-12-05 Thread ext-eero.1.nurkkala

> From: ext Nils Faerber [nils.faer...@kernelconcepts.de]
> Sent: Thursday, December 05, 2013 4:03 PM
> To: Pali Rohár; Hans Verkuil; Mauro Carvalho Chehab; 
> linux-ker...@vger.kernel.org; linux-media@vger.kernel.org; Nurkkala Eero.1 
> (EXT-Haltian/Oulu); Joni Lapilainen; Ивайло Димитров; Pavel Machek; 
> aaro.koski...@iki.fi
> Subject: Re: [PATCH] media: Add BCM2048 radio driver
>
> Am 05.12.2013 14:57, schrieb Sebastian Reichel:
>> On Thu, Dec 05, 2013 at 02:20:56PM +0100, Pali Rohár wrote:
 Anyway, I've posted the pull request. Please note, if you want
 to avoid having this driver be removed again in the future,
 then you (or someone else) should work on addressing the
 issues in the TODO file I added.
>>>
>>> Ok. CCing other people who works with n900 kernel.
>>
>> Does the bcm2048's radio part work without the bluetooth driver?
>

Hello all,
I recall that is doesn't work separately, but instead, it had to be powered
on via a separate hci command. I don't remember what it was though.
But again it maybe had to do with the configuration of the BT. Anyway,
by having no BT driver at all would make it impossible to use the radio alone.

- Eero

> At least I do not know.
> I just added the RDS data interface, I have no idea of about the
> hardware and the other parts of it, sorry.
>
>> -- Sebastian
> Cheers
>  nils
>
> --
> kernel concepts GmbH   Tel: +49-271-771091-12
> Sieghuetter Hauptweg 48
> D-57072 Siegen Mob: +49-176-21024535
> http://www.kernelconcepts.de



Re: [PATCHv5][ 3/8] staging: imx-drm: Correct BGR666 and the board's dts that use them.

2013-12-05 Thread Marek Vasut
On Thursday, December 05, 2013 at 07:28:07 PM, Denis Carikli wrote:
[...]

Can you please explain the correction here ? Why is it needed ? What was the 
problem ?

Thanks!

Best regards,
Marek Vasut
--
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] doc: no singing

2013-12-05 Thread Kees Cook
Stop that, stop that! You're not going to do a song while I'm here.

Signed-off-by: Kees Cook 
---
https://lkml.org/lkml/2013/12/4/786
http://www.youtube.com/watch?v=g3YiPC91QUk#t=62
---
 Documentation/cgroups/resource_counter.txt |2 +-
 Documentation/video4linux/si476x.txt   |2 +-
 arch/score/lib/checksum.S  |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/cgroups/resource_counter.txt 
b/Documentation/cgroups/resource_counter.txt
index c4d99ed0b418..caa6d662b230 100644
--- a/Documentation/cgroups/resource_counter.txt
+++ b/Documentation/cgroups/resource_counter.txt
@@ -95,7 +95,7 @@ to work with it.
 
  f. u64 res_counter_uncharge_until
(struct res_counter *rc, struct res_counter *top,
-unsinged long val)
+unsigned long val)
 
Almost same as res_cunter_uncharge() but propagation of uncharge
stops when rc == top. This is useful when kill a res_coutner in
diff --git a/Documentation/video4linux/si476x.txt 
b/Documentation/video4linux/si476x.txt
index 2f9b4875ab8a..616607955aaf 100644
--- a/Documentation/video4linux/si476x.txt
+++ b/Documentation/video4linux/si476x.txt
@@ -147,7 +147,7 @@ The drivers exposes following files:
   
   0x12 | readfreq  | Current tuned frequency
   
-  0x14 | freqoff   | Singed frequency offset in units of
+  0x14 | freqoff   | Signed frequency offset in units of
|   | 2ppm
   
   0x15 | rssi  | Signed value of RSSI in dBuV
diff --git a/arch/score/lib/checksum.S b/arch/score/lib/checksum.S
index 706157edc7d5..1141f2b4a501 100644
--- a/arch/score/lib/checksum.S
+++ b/arch/score/lib/checksum.S
@@ -137,7 +137,7 @@ ENTRY(csum_partial)
ldi r25, 0
mv r10, r5
cmpi.c  r5, 0x8
-   blt small_csumcpy   /* < 8(singed) bytes to copy */
+   blt small_csumcpy   /* < 8(signed) bytes to copy */
cmpi.c  r5, 0x0
beq out
andri.c r25, src, 0x1   /* odd buffer? */
-- 
1.7.9.5


-- 
Kees Cook
Chrome OS Security
--
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


[PATCHv5][ 3/8] staging: imx-drm: Correct BGR666 and the board's dts that use them.

2013-12-05 Thread Denis Carikli
Cc: Rob Herring 
Cc: Pawel Moll 
Cc: Mark Rutland 
Cc: Stephen Warren 
Cc: Ian Campbell 
Cc: devicet...@vger.kernel.org
Cc: Greg Kroah-Hartman 
Cc: driverdev-de...@linuxdriverproject.org
Cc: David Airlie 
Cc: dri-de...@lists.freedesktop.org
Cc: Mauro Carvalho Chehab 
Cc: Laurent Pinchart 
Cc: linux-media@vger.kernel.org
Cc: Sascha Hauer 
Cc: Shawn Guo 
Cc: linux-arm-ker...@lists.infradead.org
Cc: Eric Bénard 
Signed-off-by: Denis Carikli 
---
ChangeLog v5:
- New patch.
---
 arch/arm/boot/dts/imx51-apf51dev.dts|2 +-
 arch/arm/boot/dts/imx53-m53evk.dts  |2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c |4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/imx51-apf51dev.dts 
b/arch/arm/boot/dts/imx51-apf51dev.dts
index f36a3aa..3b6de6a 100644
--- a/arch/arm/boot/dts/imx51-apf51dev.dts
+++ b/arch/arm/boot/dts/imx51-apf51dev.dts
@@ -19,7 +19,7 @@
display@di1 {
compatible = "fsl,imx-parallel-display";
crtcs = <&ipu 0>;
-   interface-pix-fmt = "bgr666";
+   interface-pix-fmt = "rgb666";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ipu_disp1>;
 
diff --git a/arch/arm/boot/dts/imx53-m53evk.dts 
b/arch/arm/boot/dts/imx53-m53evk.dts
index c623774..b98c897 100644
--- a/arch/arm/boot/dts/imx53-m53evk.dts
+++ b/arch/arm/boot/dts/imx53-m53evk.dts
@@ -24,7 +24,7 @@
display@di1 {
compatible = "fsl,imx-parallel-display";
crtcs = <&ipu 1>;
-   interface-pix-fmt = "bgr666";
+   interface-pix-fmt = "rgb666";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ipu_disp1>;
 
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c 
b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
index 617e65b..b11a2aa 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
@@ -397,9 +397,9 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev,
 
/* bgr666 */
ipu_dc_map_clear(priv, IPU_DC_MAP_BGR666);
-   ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 0, 5, 0xfc); /* blue */
+   ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 0, 17, 0xfc); /* blue */
ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 1, 11, 0xfc); /* green */
-   ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 2, 17, 0xfc); /* red */
+   ipu_dc_map_config(priv, IPU_DC_MAP_BGR666, 2, 5, 0xfc); /* red */
 
/* bgr24 */
ipu_dc_map_clear(priv, IPU_DC_MAP_BGR24);
-- 
1.7.9.5

--
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


[PATCHv5][ 1/8] [media] v4l2: add new V4L2_PIX_FMT_RGB666 pixel format.

2013-12-05 Thread Denis Carikli
That new macro is needed by the imx_drm staging driver
  for supporting the QVGA display of the eukrea-cpuimx51 board.

Cc: Rob Herring 
Cc: Pawel Moll 
Cc: Mark Rutland 
Cc: Stephen Warren 
Cc: Ian Campbell 
Cc: devicet...@vger.kernel.org
Cc: Greg Kroah-Hartman 
Cc: driverdev-de...@linuxdriverproject.org
Cc: David Airlie 
Cc: dri-de...@lists.freedesktop.org
Cc: Mauro Carvalho Chehab 
Cc: Laurent Pinchart 
Cc: linux-media@vger.kernel.org
Cc: Sascha Hauer 
Cc: Shawn Guo 
Cc: linux-arm-ker...@lists.infradead.org
Cc: Eric Bénard 
Signed-off-by: Denis Carikli 
Acked-by: Mauro Carvalho Chehab 
Acked-by: Laurent Pinchart 
---
ChangeLog v3->v4:
- Added Laurent Pinchart's Ack.

ChangeLog v2->v3:
- Added some interested people in the Cc list.
- Added Mauro Carvalho Chehab's Ack.
- Added documentation.
---
 .../DocBook/media/v4l/pixfmt-packed-rgb.xml|   78 
 include/uapi/linux/videodev2.h |1 +
 2 files changed, 79 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml 
b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
index 166c8d6..f6a3e84 100644
--- a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
@@ -279,6 +279,45 @@ colorspace 
V4L2_COLORSPACE_SRGB.


  
+ 
+   V4L2_PIX_FMT_RGB666
+   'RGBH'
+   
+   r5
+   r4
+   r3
+   r2
+   r1
+   r0
+   g5
+   g4
+   
+   g3
+   g2
+   g1
+   g0
+   b5
+   b4
+   b3
+   b2
+   
+   b1
+   b0
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+ 
  
V4L2_PIX_FMT_BGR24
'BGR3'
@@ -781,6 +820,45 @@ defined in error. Drivers may interpret them as in 

  
+ 
+   V4L2_PIX_FMT_RGB666
+   'RGBH'
+   
+   r5
+   r4
+   r3
+   r2
+   r1
+   r0
+   g5
+   g4
+   
+   g3
+   g2
+   g1
+   g0
+   b5
+   b4
+   b3
+   b2
+   
+   b1
+   b0
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+ 
  
V4L2_PIX_FMT_BGR24
'BGR3'
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 437f1b0..e8ff410 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -294,6 +294,7 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16  RGB-5-5-5 
BE  */
 #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16  RGB-5-6-5 
BE  */
 #define V4L2_PIX_FMT_BGR666  v4l2_fourcc('B', 'G', 'R', 'H') /* 18  BGR-6-6-6  
  */
+#define V4L2_PIX_FMT_RGB666  v4l2_fourcc('R', 'G', 'B', 'H') /* 18  RGB-6-6-6  
  */
 #define V4L2_PIX_FMT_BGR24   v4l2_fourcc('B', 'G', 'R', '3') /* 24  BGR-8-8-8  
   */
 #define V4L2_PIX_FMT_RGB24   v4l2_fourcc('R', 'G', 'B', '3') /* 24  RGB-8-8-8  
   */
 #define V4L2_PIX_FMT_BGR32   v4l2_fourcc('B', 'G', 'R', '4') /* 32  
BGR-8-8-8-8   */
-- 
1.7.9.5

--
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


[PATCHv5][ 2/8] staging: imx-drm: Add RGB666 support for parallel display.

2013-12-05 Thread Denis Carikli
Cc: Rob Herring 
Cc: Pawel Moll 
Cc: Mark Rutland 
Cc: Stephen Warren 
Cc: Ian Campbell 
Cc: devicet...@vger.kernel.org
Cc: Greg Kroah-Hartman 
Cc: driverdev-de...@linuxdriverproject.org
Cc: David Airlie 
Cc: dri-de...@lists.freedesktop.org
Cc: Mauro Carvalho Chehab 
Cc: Laurent Pinchart 
Cc: linux-media@vger.kernel.org
Cc: Sascha Hauer 
Cc: Shawn Guo 
Cc: linux-arm-ker...@lists.infradead.org
Cc: Eric Bénard 
Signed-off-by: Denis Carikli 
---
ChangeLog v3->v5:
- Use the correct RGB order.

ChangeLog v2->v3:
- Added some interested people in the Cc list.
- Removed the commit message long desciption that was just a copy of the short
  description.
- Rebased the patch.
- Fixed a copy-paste error in the ipu_dc_map_clear parameter.
---
 .../bindings/staging/imx-drm/fsl-imx-drm.txt   |2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c|9 +
 drivers/staging/imx-drm/parallel-display.c |2 ++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt 
b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
index b876d49..2d24425 100644
--- a/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
+++ b/Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt
@@ -29,7 +29,7 @@ Required properties:
 - crtc: the crtc this display is connected to, see below
 Optional properties:
 - interface_pix_fmt: How this display is connected to the
-  crtc. Currently supported types: "rgb24", "rgb565", "bgr666"
+  crtc. Currently supported types: "rgb24", "rgb565", "bgr666", "rgb666"
 - edid: verbatim EDID data block describing attached display.
 - ddc: phandle describing the i2c bus handling the display data
   channel
diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c 
b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
index d0e3bc3..617e65b 100644
--- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
+++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c
@@ -92,6 +92,7 @@ enum ipu_dc_map {
IPU_DC_MAP_GBR24, /* TVEv2 */
IPU_DC_MAP_BGR666,
IPU_DC_MAP_BGR24,
+   IPU_DC_MAP_RGB666,
 };
 
 struct ipu_dc {
@@ -155,6 +156,8 @@ static int ipu_pixfmt_to_map(u32 fmt)
return IPU_DC_MAP_BGR666;
case V4L2_PIX_FMT_BGR24:
return IPU_DC_MAP_BGR24;
+   case V4L2_PIX_FMT_RGB666:
+   return IPU_DC_MAP_RGB666;
default:
return -EINVAL;
}
@@ -404,6 +407,12 @@ int ipu_dc_init(struct ipu_soc *ipu, struct device *dev,
ipu_dc_map_config(priv, IPU_DC_MAP_BGR24, 1, 15, 0xff); /* green */
ipu_dc_map_config(priv, IPU_DC_MAP_BGR24, 0, 23, 0xff); /* blue */
 
+   /* rgb666 */
+   ipu_dc_map_clear(priv, IPU_DC_MAP_RGB666);
+   ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 0, 5, 0xfc); /* blue */
+   ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 1, 11, 0xfc); /* green */
+   ipu_dc_map_config(priv, IPU_DC_MAP_RGB666, 2, 17, 0xfc); /* red */
+
return 0;
 }
 
diff --git a/drivers/staging/imx-drm/parallel-display.c 
b/drivers/staging/imx-drm/parallel-display.c
index 24aa9be..bb71d6d 100644
--- a/drivers/staging/imx-drm/parallel-display.c
+++ b/drivers/staging/imx-drm/parallel-display.c
@@ -222,6 +222,8 @@ static int imx_pd_probe(struct platform_device *pdev)
imxpd->interface_pix_fmt = V4L2_PIX_FMT_RGB565;
else if (!strcmp(fmt, "bgr666"))
imxpd->interface_pix_fmt = V4L2_PIX_FMT_BGR666;
+   else if (!strcmp(fmt, "rgb666"))
+   imxpd->interface_pix_fmt = V4L2_PIX_FMT_RGB666;
}
 
imxpd->dev = &pdev->dev;
-- 
1.7.9.5

--
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] omap3isp: Use devm_ioremap_resource()

2013-12-05 Thread Sakari Ailus
On Wed, Dec 04, 2013 at 06:13:34PM +0100, Laurent Pinchart wrote:
> Replace devm_request_mem_region() and devm_ioremap_nocache() with
> devm_ioremap_resource(). The behaviour remains the same and the code is
> simplified.
> 
> Signed-off-by: Laurent Pinchart 

Nice one! :)

Acked-by: Sakari Ailus 

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
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: IR devices refuses to generate events

2013-12-05 Thread Rajil Saraswat
On 5 December 2013 22:17, Sean Young  wrote:
> On Thu, Dec 05, 2013 at 10:05:45PM +0530, Rajil Saraswat wrote:
>> On 5 December 2013 18:54, Sean Young  wrote:
>>
>> > I really don't know why that would happen. If I understand it correctly
>> > this is an error that is returned by the usb host controller driver.
>> >
>> > Could you set CONFIG_USB_DEBUG and see if you get more information?
>> >
>> >
>> > Sean
>>
>> The usbmon log with CONFIG_USB_DEBUG set is attached.
>
> You should have more output in dmesg. Do you?
>
>
> Sean

Indeed i did. It is attached.
[  463.882860] hub 3-0:1.0: state 7 ports 14 chg  evt 1000
[  463.882894] hub 3-0:1.0: port 12, status 0101, change 0001, 12 Mb/s
[  463.986868] hub 3-0:1.0: debounce: port 12: total 100ms stable 100ms status 
0x101
[  464.037909] hub 3-0:1.0: port 12 not reset yet, waiting 50ms
[  464.139879] usb 3-12: new full-speed USB device number 8 using xhci_hcd
[  464.151041] usb 3-12: ep0 maxpacket = 16
[  464.151068] usb 3-12: Successful evaluate context command
[  464.151919] usb 3-12: default language 0x0409
[  464.152776] usb 3-12: udev 8, busnum 3, minor = 263
[  464.152782] usb 3-12: New USB device found, idVendor=0609, idProduct=031d
[  464.152797] usb 3-12: New USB device strings: Mfr=1, Product=2, 
SerialNumber=3
[  464.152801] usb 3-12: Product: eHome Infrared Transceiver
[  464.152805] usb 3-12: Manufacturer: SMK
[  464.152809] usb 3-12: SerialNumber: SM007r3e
[  464.152965] usb 3-12: usb_probe_device
[  464.152971] usb 3-12: configuration #1 chosen from 1 choice
[  464.153188] usb 3-12: Successful Endpoint Configure command
[  464.153324] usb 3-12: adding 3-12:1.0 (config #1, interface 0)
[  464.153376] mceusb 3-12:1.0: usb_probe_interface
[  464.153380] mceusb 3-12:1.0: usb_probe_interface - got id
[  464.153384] mceusb 3-12:1.0: mceusb_dev_probe called
[  464.153388] mceusb 3-12:1.0: acceptable outbound endpoint found
[  464.153391] mceusb 3-12:1.0: acceptable inbound endpoint found
[  464.154056] Registered IR keymap rc-rc6-mce
[  464.154173] input: Media Center Ed. eHome Infrared Remote Transceiver 
(0609:031d) as 
/devices/pci:00/:00:14.0/usb3/3-12/3-12:1.0/rc/rc4/input24
[  464.154273] rc4: Media Center Ed. eHome Infrared Remote Transceiver 
(0609:031d) as /devices/pci:00/:00:14.0/usb3/3-12/3-12:1.0/rc/rc4
[  464.154437] input: MCE IR Keyboard/Mouse (mceusb) as 
/devices/virtual/input/input25
[  464.154625] rc rc4: lirc_dev: driver ir-lirc-codec (mceusb) registered at 
minor = 1
[  464.154630] mceusb 3-12:1.0: Flushing receive buffers
[  464.154634] mceusb 3-12:1.0: receive request called (size=0x10)
[  464.154640] xhci_queue_intr_tx: 2 callbacks suppressed
[  464.154645] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.154650] mceusb 3-12:1.0: receive request complete (res=0)
[  464.154655] mceusb 3-12:1.0: receive request called (size=0x2)
[  464.154661] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.154665] mceusb 3-12:1.0: receive request complete (res=0)
[  464.154695] mceusb 3-12:1.0: setup answer received 0 bytes
[  464.154699] mceusb 3-12:1.0: Error: urb status = -71
[  464.164836] mceusb 3-12:1.0: receive request called (size=0x3)
[  464.164849] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.164856] mceusb 3-12:1.0: receive request complete (res=0)
[  464.175844] mceusb 3-12:1.0: receive request called (size=0x2)
[  464.175857] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.175864] mceusb 3-12:1.0: receive request complete (res=0)
[  464.186845] mceusb 3-12:1.0: receive request called (size=0x2)
[  464.186858] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.186865] mceusb 3-12:1.0: receive request complete (res=0)
[  464.197822] mceusb 3-12:1.0: receive request called (size=0x2)
[  464.197826] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.197828] mceusb 3-12:1.0: receive request complete (res=0)
[  464.208839] mceusb 3-12:1.0: receive request called (size=0x2)
[  464.208854] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.208861] mceusb 3-12:1.0: receive request complete (res=0)
[  464.219853] mceusb 3-12:1.0: receive request called (size=0x2)
[  464.219867] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.219874] mceusb 3-12:1.0: receive request complete (res=0)
[  464.230848] mceusb 3-12:1.0: receive request called (size=0x2)
[  464.230862] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.230868] mceusb 3-12:1.0: receive request complete (res=0)
[  464.241846] mceusb 3-12:1.0: receive request called (size=0x2)
[  464.241860] usb 3-12: Driver uses different interval (8 microframes) than 
xHCI (1 microframe)
[  464.241866] mceusb 3-12:1.0: rec

Re: IR devices refuses to generate events

2013-12-05 Thread Sean Young
On Thu, Dec 05, 2013 at 10:05:45PM +0530, Rajil Saraswat wrote:
> On 5 December 2013 18:54, Sean Young  wrote:
> 
> > I really don't know why that would happen. If I understand it correctly
> > this is an error that is returned by the usb host controller driver.
> >
> > Could you set CONFIG_USB_DEBUG and see if you get more information?
> >
> >
> > Sean
> 
> The usbmon log with CONFIG_USB_DEBUG set is attached.

You should have more output in dmesg. Do you?


Sean
--
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: IR devices refuses to generate events

2013-12-05 Thread Rajil Saraswat
On 5 December 2013 18:54, Sean Young  wrote:

> I really don't know why that would happen. If I understand it correctly
> this is an error that is returned by the usb host controller driver.
>
> Could you set CONFIG_USB_DEBUG and see if you get more information?
>
>
> Sean

The usbmon log with CONFIG_USB_DEBUG set is attached.

Rajil
88012970b6c0 2355372779 C Ii:3:001:1 0:2048 2 = 0010
88012970b6c0 2355372796 S Ii:3:001:1 -115:2048 4 <
880109444300 2355372849 S Ci:3:001:0 s a3 00  000c 0004 4 <
880109444300 2355372860 C Ci:3:001:0 0 4 = 01010100
880109444300 2355372863 S Co:3:001:0 s 23 01 0010 000c  0
880109444300 2355372866 C Co:3:001:0 0 0
880109444300 2355372874 S Ci:3:001:0 s a3 00  000c 0004 4 <
880109444300 2355372876 C Ci:3:001:0 0 4 = 0101
8800bc893840 2355398895 S Ci:3:001:0 s a3 00  000c 0004 4 <
8800bc893840 2355398910 C Ci:3:001:0 0 4 = 0101
8801287d9f00 2355424880 S Ci:3:001:0 s a3 00  000c 0004 4 <
8801287d9f00 2355424888 C Ci:3:001:0 0 4 = 0101
8801287d9f00 2355450846 S Ci:3:001:0 s a3 00  000c 0004 4 <
8801287d9f00 2355450852 C Ci:3:001:0 0 4 = 0101
880109492b40 2355476880 S Ci:3:001:0 s a3 00  000c 0004 4 <
880109492b40 2355476895 C Ci:3:001:0 0 4 = 0101
880109492b40 2355476948 S Co:3:001:0 s 23 03 0004 000c  0
880109492b40 2355476952 C Co:3:001:0 0 0
880109444300 2355527872 S Ci:3:001:0 s a3 00  000c 0004 4 <
880109444300 2355527886 C Ci:3:001:0 0 4 = 1101
8800bc893840 2355578897 S Ci:3:001:0 s a3 00  000c 0004 4 <
8800bc893840 2355578907 C Ci:3:001:0 0 4 = 03011000
8801287d9f00 2355629887 S Co:3:001:0 s 23 01 0014 000c  0
8801287d9f00 2355629904 C Co:3:001:0 0 0
880109492b40 2355640863 S Ci:3:007:0 s 80 06 0100  0008 8 <
880109492b40 2355641001 C Ci:3:007:0 0 8 = 12011001 0010
880109492b40 2355641057 S Ci:3:007:0 s 80 06 0100  0012 18 <
880109492b40 2355641343 C Ci:3:007:0 0 18 = 12011001 0010 09061d03 
0102 0301
880109492b40 2355641389 S Ci:3:007:0 s 80 06 0200  0009 9 <
880109492b40 2355641560 C Ci:3:007:0 0 9 = 09022000 010100a0 32
880109444300 2355641607 S Ci:3:007:0 s 80 06 0200  0020 32 <
880109444300 2355641906 C Ci:3:007:0 0 32 = 09022000 010100a0 32090400 
0002 ff000705 01021000 00070581 0210
880109444300 2355641958 S Ci:3:007:0 s 80 06 0300  00ff 255 <
880109444300 2355642116 C Ci:3:007:0 0 4 = 04030904
880109444300 2355642142 S Ci:3:007:0 s 80 06 0302 0409 00ff 255 <
880109444300 2355642566 C Ci:3:007:0 0 54 = 36036500 48006f00 6d006500 
20004900 6e006600 72006100 72006500 64002000
880109444300 2355642614 S Ci:3:007:0 s 80 06 0301 0409 00ff 255 <
880109444300 2355642749 C Ci:3:007:0 0 8 = 08035300 4d004b00
880109444300 2355642793 S Ci:3:007:0 s 80 06 0303 0409 00ff 255 <
880109444300 2355643022 C Ci:3:007:0 0 18 = 12035300 4d003000 30003700 
72003300 6500
8801287d9000 2355643522 S Co:3:007:0 s 00 09 0001   0
8801287d9000 2355643639 C Co:3:007:0 0 0
8801287d9c00 2355643741 S Ci:3:007:0 s 80 06 0301 0409 00ff 255 <
8801287d9c00 2355643924 C Ci:3:007:0 0 8 = 08035300 4d004b00
8801287d9c00 2355643965 S Ci:3:007:0 s 80 06 0302 0409 00ff 255 <
8801287d9c00 2355644419 C Ci:3:007:0 0 54 = 36036500 48006f00 6d006500 
20004900 6e006600 72006100 72006500 64002000
8801287d99c0 2355645266 S Ii:3:007:1 -115:1 16 <
880123114480 2355645291 S Io:3:007:1 -115:1 2 = ff22
8801287d99c0 2355645319 C Ii:3:007:1 -71:0 0
880123114480 2355645351 C Io:3:007:1 -71:0 0
8801231143c0 2355655885 S Io:3:007:1 -115:1 3 = 00ffaa
8801231143c0 2355655952 C Io:3:007:1 -71:0 0
880109492d80 2355666836 S Io:3:007:1 -115:1 2 = ff18
880109492d80 2355666906 C Io:3:007:1 -71:0 0
880109444b40 2355677876 S Io:3:007:1 -115:1 2 = 9f05
880109444b40 2355677946 C Io:3:007:1 -71:0 0
880109444cc0 2355688849 S Io:3:007:1 -115:1 2 = 9f16
880109444cc0 2355688927 C Io:3:007:1 -71:0 0
8800bc893000 2355699875 S Io:3:007:1 -115:1 2 = 9f07
8800bc893000 2355699944 C Io:3:007:1 -71:0 0
880123114900 2355710890 S Io:3:007:1 -115:1 2 = 9f13
880123114900 2355710957 C Io:3:007:1 -71:0 0
880109492e40 2355721890 S Io:3:007:1 -115:1 2 = 9f0d
880109492e40 2355721957 C Io:3:007:1 -71:0 0
880109444840 2355732906 S Io:3:007:1 -115:1 2 = 9f15
880109444840 2355732974 C Io:3:007:1 -71:0 0
880109444780 2355743875 S Io:3:007:1 -115:1 3 = ff1100
880109444780 2355743933 C Io:3:007:1 -71:0 0
8800bc893b40 2355754907 S Io:3:007:1 -115:1 3 = ff1101
8800bc893b40 2355754969 C Io:3:007:1 -71:0 0
8801287d9480 2358052888 C Ii:3:003:2 0:1 2 = 81b5
8801287d9480 2358052929 S Ii:3:003:2 -115:1 16 <
8801287d9480 2358053886 C Ii:3:003:2 0:1 2 = 8111
8801287d9480 2358053923 S Ii:3:003:2 -115:1 16 <
8801287d9480 2358054883 C Ii:3:003:2 0:1 4 = 838a088a
8801287d9

[PATCH] libdvbv5: more fixes in the T2 delivery descriptor handler

2013-12-05 Thread Nikolaus Schulz
* Fix a couple of memcpy calls, and remove a bogus one
* Properly use lengths of centre_frequency loop and subcell_info loop
  (they count bytes, not entries)

Signed-off-by: Nikolaus Schulz 
---
 lib/libdvbv5/descriptors/desc_t2_delivery.c |   35 ++-
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/lib/libdvbv5/descriptors/desc_t2_delivery.c 
b/lib/libdvbv5/descriptors/desc_t2_delivery.c
index ab4361d..07a0956 100644
--- a/lib/libdvbv5/descriptors/desc_t2_delivery.c
+++ b/lib/libdvbv5/descriptors/desc_t2_delivery.c
@@ -32,6 +32,7 @@ void dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
struct dvb_desc_t2_delivery *d = desc;
unsigned char *p = (unsigned char *) buf;
size_t desc_len = ext->length - 1, len, len2;
+   uint8_t nmemb;
int i;
 
len = offsetof(struct dvb_desc_t2_delivery, bitfield);
@@ -42,7 +43,7 @@ void dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
return;
}
if (desc_len < len2) {
-   memcpy(p, buf, len);
+   memcpy(d, p, len);
bswap16(d->system_id);
 
if (desc_len != len)
@@ -50,44 +51,41 @@ void dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms 
*parms,
 
return;
}
-   memcpy(p, buf, len2);
+   memcpy(d, p, len2);
p += len2;
 
-   len = desc_len - (p - buf);
-   memcpy(&d->centre_frequency, p, len);
-   p += len;
-
if (d->tfs_flag)
-   d->frequency_loop_length = 1;
+   d->frequency_loop_length = sizeof(*d->centre_frequency);
else {
d->frequency_loop_length = *p;
p++;
}
+   nmemb = d->frequency_loop_length / sizeof(*d->centre_frequency);
 
-   d->centre_frequency = calloc(d->frequency_loop_length,
-sizeof(*d->centre_frequency));
+   d->centre_frequency = calloc(nmemb, sizeof(*d->centre_frequency));
if (!d->centre_frequency) {
dvb_perror("Out of memory");
return;
}
 
-   memcpy(d->centre_frequency, p, sizeof(*d->centre_frequency) * 
d->frequency_loop_length);
-   p += sizeof(*d->centre_frequency) * d->frequency_loop_length;
+   memcpy(d->centre_frequency, p, d->frequency_loop_length);
+   p += d->frequency_loop_length;
 
-   for (i = 0; i < d->frequency_loop_length; i++)
+   for (i = 0; i < nmemb; i++)
bswap32(d->centre_frequency[i]);
 
d->subcel_info_loop_length = *p;
p++;
+   nmemb = d->subcel_info_loop_length / sizeof(*d->subcell);
 
-   d->subcell = calloc(d->subcel_info_loop_length, sizeof(*d->subcell));
+   d->subcell = calloc(nmemb, sizeof(*d->subcell));
if (!d->subcell) {
dvb_perror("Out of memory");
return;
}
-   memcpy(d->subcell, p, sizeof(*d->subcell) * d->subcel_info_loop_length);
+   memcpy(d->subcell, p, d->subcel_info_loop_length);
 
-   for (i = 0; i < d->subcel_info_loop_length; i++)
+   for (i = 0; i < nmemb; i++)
bswap16(d->subcell[i].transposer_frequency);
 }
 
@@ -97,6 +95,7 @@ void dvb_desc_t2_delivery_print(struct dvb_v5_fe_parms *parms,
 {
const struct dvb_desc_t2_delivery *d = desc;
int i;
+   uint8_t nmemb;
 
dvb_log("|   DVB-T2 delivery");
dvb_log("|   plp_id%d", d->plp_id);
@@ -113,10 +112,12 @@ void dvb_desc_t2_delivery_print(struct dvb_v5_fe_parms 
*parms,
dvb_log("|   bandwidth %d", d->bandwidth);
dvb_log("|   SISO MISO %d", d->SISO_MISO);
 
-   for (i = 0; i < d->frequency_loop_length; i++)
+   nmemb = d->frequency_loop_length / sizeof(*d->centre_frequency);
+   for (i = 0; i < nmemb; i++)
dvb_log("|   centre frequency[%d]   %d", i, 
d->centre_frequency[i]);
 
-   for (i = 0; i < d->subcel_info_loop_length; i++) {
+   nmemb = d->subcel_info_loop_length / sizeof(*d->subcell);
+   for (i = 0; i < nmemb; i++) {
dvb_log("|   cell_id_extension[%d]  %d", i, 
d->subcell[i].cell_id_extension);
dvb_log("|   transposer frequency   %d", 
d->subcell[i].transposer_frequency);
}
-- 
1.7.2.5

--
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] media: Add BCM2048 radio driver

2013-12-05 Thread Nils Faerber
Am 05.12.2013 14:57, schrieb Sebastian Reichel:
> On Thu, Dec 05, 2013 at 02:20:56PM +0100, Pali Rohár wrote:
>>> Anyway, I've posted the pull request. Please note, if you want
>>> to avoid having this driver be removed again in the future,
>>> then you (or someone else) should work on addressing the
>>> issues in the TODO file I added.
>>
>> Ok. CCing other people who works with n900 kernel.
> 
> Does the bcm2048's radio part work without the bluetooth driver?

At least I do not know.
I just added the RDS data interface, I have no idea of about the
hardware and the other parts of it, sorry.

> -- Sebastian
Cheers
  nils

-- 
kernel concepts GmbH   Tel: +49-271-771091-12
Sieghuetter Hauptweg 48
D-57072 Siegen Mob: +49-176-21024535
http://www.kernelconcepts.de



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] media: Add BCM2048 radio driver

2013-12-05 Thread Sebastian Reichel
On Thu, Dec 05, 2013 at 02:20:56PM +0100, Pali Rohár wrote:
> > Anyway, I've posted the pull request. Please note, if you want
> > to avoid having this driver be removed again in the future,
> > then you (or someone else) should work on addressing the
> > issues in the TODO file I added.
> 
> Ok. CCing other people who works with n900 kernel.

Does the bcm2048's radio part work without the bluetooth driver?

-- Sebastian


signature.asc
Description: Digital signature


Re: IR devices refuses to generate events

2013-12-05 Thread Sean Young
On Sat, Nov 30, 2013 at 12:52:17AM +0530, Rajil Saraswat wrote:
>  i have an Asus H87 Pro motherboard on which i am trying to use my
> mceusb receiver. The device refuses to generate any events. Strangely,
> it does work on one of my laptops.
> 
>  I have attached usbmon traces of it working and not working. Any idea
> what may be the problem?

The first command the mceusb driver sends is get 0xff22, get emulator 
version. In the usbmon output where it works, this gets an answer. In the
output where it does not work this command and nothing following it gets
answered.

--works log--
driver starts here:
> ddec7b40 2117802193 S Ii:2:009:1 -115:1 16 <
> ddec7a80 2117802245 S Io:2:009:1 -115:1 2 = ff22
and gets an answer:
> ddec7a80 2117803457 C Io:2:009:1 0:1 2 >
> ddec7b40 2117804472 C Ii:2:009:1 0:1 2 = fffe

-notworks log--
driver starts here:
> 880129745480 1549633365 S Ii:3:011:1 -115:1 16 <
> 880110cce900 1549633377 S Io:3:011:1 -115:1 2 = ff22

If I read the usbmon log correctly the result is -EPROTO.

> 880129745480 1549633448 C Ii:3:011:1 -71:0 0
> 880110cce900 1549633486 C Io:3:011:1 -71:0 0

And the same for the following commands.

> 880110ccecc0 1549643496 S Io:3:011:1 -115:1 3 = 00ffaa
> 880110ccecc0 1549643563 C Io:3:011:1 -71:0 0
> 880113aabb40 1549654508 S Io:3:011:1 -115:1 2 = ff18
> 880113aabb40 1549654567 C Io:3:011:1 -71:0 0
> 880129be6a80 1549665495 S Io:3:011:1 -115:1 2 = 9f05
> 880129be6a80 1549665554 C Io:3:011:1 -71:0 0
> 880129745540 1549676497 S Io:3:011:1 -115:1 2 = 9f16
> 880129745540 1549676557 C Io:3:011:1 -71:0 0
> 880110ccecc0 1549687510 S Io:3:011:1 -115:1 2 = 9f07
> 880110ccecc0 1549687570 C Io:3:011:1 -71:0 0
> 880113aab6c0 1549698509 S Io:3:011:1 -115:1 2 = 9f13
> 880113aab6c0 1549698569 C Io:3:011:1 -71:0 0
> 880129be60c0 1549709510 S Io:3:011:1 -115:1 2 = 9f0d
> 880129be60c0 1549709570 C Io:3:011:1 -71:0 0
> 880129745e40 1549720510 S Io:3:011:1 -115:1 2 = 9f15
> 880129745e40 1549720570 C Io:3:011:1 -71:0 0
> 880110cce900 1549731510 S Io:3:011:1 -115:1 3 = ff1100
> 880110cce900 1549731573 C Io:3:011:1 -71:0 0
> 880113aab9c0 1549742511 S Io:3:011:1 -115:1 3 = ff1101
> 880113aab9c0 1549742573 C Io:3:011:1 -71:0 0

I really don't know why that would happen. If I understand it correctly
this is an error that is returned by the usb host controller driver.

Could you set CONFIG_USB_DEBUG and see if you get more information?


Sean
--
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] media: Add BCM2048 radio driver

2013-12-05 Thread Pali Rohár
On Thursday 05 December 2013 08:52:30 Hans Verkuil wrote:
> On 12/02/2013 09:51 PM, Pali Rohár wrote:
> > On Monday 04 November 2013 12:39:44 Hans Verkuil wrote:
> >> Hi Pali,
> >> 
> >> On 10/26/2013 10:45 PM, Pali Rohár wrote:
> >>> On Saturday 26 October 2013 22:22:09 Hans Verkuil wrote:
> > Hans, so can it be added to drivers/staging/media tree?
>  
>  Yes, that is an option. It's up to you to decide what you
>  want. Note that if no cleanup work is done on the staging
>  driver for a long time, then it can be removed again.
>  
>  Regards,
>  
>  Hans
> >>> 
> >>> Ok, so if you can add it to staging tree. When driver will
> >>> be in mainline other developers can look at it too. Now
> >>> when driver is hidden, nobody know where to find it... You
> >>> can see how upstream development for Nokia N900 HW going
> >>> on: http://elinux.org/N900
> >> 
> >> Please check my tree:
> >> 
> >> http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/ref
> >> s/h eads/bcm
> >> 
> >> If you're OK, then I'll queue it for 3.14 (it's too late
> >> for 3.13).
> >> 
> >> Regards,
> >> 
> >>Hans
> > 
> > Hi, sorry for late reply. I looked into your tree and
> > difference is that you only removed "linux/slab.h" include.
> > So it it is not needed, then it is OK.
> 
> I *added* slab.h :-)
> 

Right, I looked at reverse diff :-)

> Anyway, I've posted the pull request. Please note, if you want
> to avoid having this driver be removed again in the future,
> then you (or someone else) should work on addressing the
> issues in the TODO file I added.
> 
> Regards,
> 
>   Hans

Ok. CCing other people who works with n900 kernel.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: This is a digitally signed message part.


Re: advice on Easycap dongles and VBI interface..

2013-12-05 Thread Ezequiel Garcia
Hi Andrea and Hans,

On Thu, Dec 05, 2013 at 12:53:32PM +0100, Hans Verkuil wrote:
> 
> > - finally which approach do you suggest for supporting this ancient
> > feature, if feasibiliy tests are ok: - a libusb quick hack? - an
> > implementation of the bindings between user level /dev/vbi and
> > underlying SAA711x routines?
> 
> The problem is that I don't believe we have any stk1160 documentation.

I do have the stk1160 chip datasheet. However, it's not publicly
available and I'm not sure I should disclose it (although syntek never
advise me against it). In additio, the datasheet is not very verbose
and the information is scarce and often incomplete.

> And I wonder if the device can support VBI at all.
> 

Apparently it does: at least there's a flag to "enable" VBI mode.

> You are better off choosing devices that already have VBI support: the
> em28xx supports it, so do bt8xx, cx18 and ivtv.
> 

I agree with this. I don't have any VBI source so there's no way I can
work on this (not to mention it's not something lots of users need).
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
--
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: advice on Easycap dongles and VBI interface..

2013-12-05 Thread Hans Verkuil
Hi Andrea,

On 12/05/13 11:43, Andrea Venturi wrote:
> i'm working on a project for legacy support of a teletext server with
> composite output interface.
> 
> i supposed to "ingest" teletext using the /dev/vbi support on linux
> so i've got an Easycap dongle
> 
> Bus 001 Device 008: ID 05e1:0408 Syntek Semiconductor Co., Ltd
> STK1160 Video Capture Device
> 
> AFAIK (i didn't open) it's using a video decoder SC7113 supposed to
> be a clone of SAA7113.
> 
> this device is supposed to work on an Ubuntu 12.04 with old kernel
> 3.2 so i had to blacklist the stock "RE" kernel module easycap and
> install the "retrofit" from here:
> 
> https://github.com/ezequielgarcia/stk1160-standalone
> 
> i see the saa7115 is loaded and i can also see audio and video
> through mplayer..
> 
> $ lsmod Module  Size  Used by saa7115
> 18447  1 stk116027732  0 videobuf2_core 28148
> 1 stk1160 snd_ac97_codec110213  1 stk1160 
> 
> but in the dev fs there's no sign of /dev/vbi interface..
> 
> so my questions are:
> 
> - are these SAA7113 clones really copycat with all the features
> supported?

I believe so, yes.

> - has the SAA711x driver ever been used for /dev/vbi feature? i used
> to work with Bt878 cards for that feature.

It's been tested for saa7114 and saa7115, but I'm not sure if it was ever
tested for saa7113. The chip can do it, and the saa7115 driver should as well,
but the combination of saa7113 + VBI is very rare.

> - is the stock 3.x mainline kernel of the stk1160 really
> improved/different/VBI enabled?

No, it doesn't have VBI support.

> - is there a way to extract VBI lines on /dev/video0?

No.

> - is there an easy way to enable or at least test (directly on the
> USB interface) the VBI interface?

No.

> - finally which approach do you suggest for supporting this ancient
> feature, if feasibiliy tests are ok: - a libusb quick hack? - an
> implementation of the bindings between user level /dev/vbi and
> underlying SAA711x routines?

The problem is that I don't believe we have any stk1160 documentation.
And I wonder if the device can support VBI at all.

You are better off choosing devices that already have VBI support: the
em28xx supports it, so do bt8xx, cx18 and ivtv.

Regards,

Hans
--
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


[GIT PULL] s5p-jpeg codec driver update for Exynos4x12 SoCs

2013-12-05 Thread Sylwester Nawrocki
The following changes since commit 3f823e094b935c1882605f8720336ee23433a16d:

  [media] exynos4-is: Simplify fimc-is hardware polling helpers (2013-12-04 
15:54:19 -0200)

are available in the git repository at:

  git://linuxtv.org/snawrocki/samsung.git v3.14-s5p-jpeg-exynos4x12

for you to fetch changes up to 4990e9e72df0382a032fdb20b187ec34f13f7ddc:

  s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs (2013-12-04 
23:56:52 +0100)


Jacek Anaszewski (16):
  s5p-jpeg: Reorder quantization tables
  s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder
  s5p-jpeg: Fix erroneous condition while validating bytesperline value
  s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function
  s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly
  s5p-jpeg: Fix clock resource management
  s5p-jpeg: Fix lack of spin_lock protection
  s5p-jpeg: Synchronize cached controls with V4L2 core
  s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
  s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec
  s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
  s5p-jpeg: Ensure correct capture format for Exynos4x12
  s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder
  s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value
  s5p-jpeg: Ensure setting correct value of the chroma subsampling control
  s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs

Seung-Woo Kim (1):
  s5p-jpeg: Fix encoder and decoder video dev names

Sylwester Nawrocki (1):
  s5p-jpeg: Add initial device tree support for S5PV210/Exynos4210 SoCs

 .../bindings/media/exynos-jpeg-codec.txt   |   11 +
 drivers/media/platform/s5p-jpeg/Makefile   |2 +-
 drivers/media/platform/s5p-jpeg/jpeg-core.c| 1097 
 drivers/media/platform/s5p-jpeg/jpeg-core.h|   75 +-
 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c   |  293 ++
 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h   |   44 +
 .../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} |   82 +-
 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h  |   63 ++
 drivers/media/platform/s5p-jpeg/jpeg-regs.h|  215 +++-
 9 files changed, 1634 insertions(+), 248 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/media/exynos-jpeg-codec.txt
 create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c
 create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h
 rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (71%)
 create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h
--
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 v10 0/2] S5K5BAF camera sensor driver

2013-12-05 Thread Andrzej Hajda
Hi,

This is the 10th iteration of S5K5BAF camera patch (time for celebration).
All changes are described in patches.

Regards
Andrzej

Andrzej Hajda (2):
  s5k5baf: add camera sensor driver
  s5k5baf: add DT bindings for camera sensor

 .../devicetree/bindings/media/samsung-s5k5baf.txt  |   58 +
 MAINTAINERS|7 +
 drivers/media/i2c/Kconfig  |7 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/s5k5baf.c| 2043 
 5 files changed, 2116 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/samsung-s5k5baf.txt
 create mode 100644 drivers/media/i2c/s5k5baf.c

-- 
1.8.3.2

--
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 v10 2/2] s5k5baf: add DT bindings for camera sensor

2013-12-05 Thread Andrzej Hajda
The patch adds the DT bindings documentation for
Samsung S5K5BAF Image Sensor.

Signed-off-by: Andrzej Hajda 
Signed-off-by: Kyungmin Park 
Acked-by: Mark Rutland 
---
v10
- bindings moved to separate patch,
- improved clocks description.
---
 .../devicetree/bindings/media/samsung-s5k5baf.txt  | 58 ++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/samsung-s5k5baf.txt

diff --git a/Documentation/devicetree/bindings/media/samsung-s5k5baf.txt 
b/Documentation/devicetree/bindings/media/samsung-s5k5baf.txt
new file mode 100644
index 000..1f51e04
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/samsung-s5k5baf.txt
@@ -0,0 +1,58 @@
+Samsung S5K5BAF UXGA 1/5" 2M CMOS Image Sensor with embedded SoC ISP
+
+
+Required properties:
+
+- compatible : "samsung,s5k5baf";
+- reg: I2C slave address of the sensor;
+- vdda-supply: analog power supply 2.8V (2.6V to 3.0V);
+- vddreg-supply  : regulator input power supply 1.8V (1.7V to 1.9V)
+   or 2.8V (2.6V to 3.0);
+- vddio-supply   : I/O power supply 1.8V (1.65V to 1.95V)
+   or 2.8V (2.5V to 3.1V);
+- stbyn-gpios: GPIO connected to STDBYN pin;
+- rstn-gpios : GPIO connected to RSTN pin;
+- clocks : list of phandle and clock specifier pairs
+   according to common clock bindings for the
+   clocks described in clock-names;
+- clock-names: should include "mclk" for the sensor's master clock;
+
+Optional properties:
+
+- clock-frequency : the frequency at which the "mclk" clock should be
+   configured to operate, in Hz; if this property is not
+   specified default 24 MHz value will be used.
+
+The device node should contain one 'port' child node with one child 'endpoint'
+node, according to the bindings defined in Documentation/devicetree/bindings/
+media/video-interfaces.txt. The following are properties specific to those
+nodes.
+
+endpoint node
+-
+
+- data-lanes : (optional) specifies MIPI CSI-2 data lanes as covered in
+  video-interfaces.txt. If present it should be <1> - the device
+  supports only one data lane without re-mapping.
+
+Example:
+
+s5k5bafx@2d {
+   compatible = "samsung,s5k5baf";
+   reg = <0x2d>;
+   vdda-supply = <&cam_io_en_reg>;
+   vddreg-supply = <&vt_core_15v_reg>;
+   vddio-supply = <&vtcam_reg>;
+   stbyn-gpios = <&gpl2 0 1>;
+   rstn-gpios = <&gpl2 1 1>;
+   clock-names = "mclk";
+   clocks = <&clock_cam 0>;
+   clock-frequency = <2400>;
+
+   port {
+   s5k5bafx_ep: endpoint {
+   remote-endpoint = <&csis1_ep>;
+   data-lanes = <1>;
+   };
+   };
+};
-- 
1.8.3.2

--
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


advice on Easycap dongles and VBI interface..

2013-12-05 Thread Andrea Venturi
i'm working on a project for legacy support of a teletext server with 
composite output interface.


i supposed to "ingest" teletext using the /dev/vbi support on linux so 
i've got an Easycap dongle


Bus 001 Device 008: ID 05e1:0408 Syntek Semiconductor Co., Ltd STK1160 
Video Capture Device


AFAIK (i didn't open) it's using a video decoder SC7113 supposed to be a 
clone of SAA7113.


this device is supposed to work on an Ubuntu 12.04 with old kernel 3.2 
so i had to blacklist the stock "RE" kernel module easycap and install 
the "retrofit" from here:


  https://github.com/ezequielgarcia/stk1160-standalone

i see the saa7115 is loaded and i can also see audio and video through 
mplayer..


 $ lsmod
 Module  Size  Used by
 saa711518447  1
 stk116027732  0
 videobuf2_core 28148  1 stk1160
 snd_ac97_codec110213  1 stk1160
 

 but in the dev fs there's no sign of /dev/vbi interface..

so my questions are:

- are these SAA7113 clones really copycat with all the features supported?

- has the SAA711x driver ever been used for /dev/vbi feature? i used to 
work with Bt878 cards for that feature.


- is the stock 3.x mainline kernel of the stk1160 really 
improved/different/VBI enabled?


- is there a way to extract VBI lines on /dev/video0?

- is there an easy way to enable or at least test (directly on the USB 
interface) the VBI interface?


- finally which approach do you suggest for supporting this ancient 
feature, if feasibiliy tests are ok:

  - a libusb quick hack?
  - an implementation of the bindings between user level /dev/vbi and 
underlying SAA711x routines?


bests

andrea venturi

--
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 for 3.13] vb2: regression fix: always set length field.

2013-12-05 Thread Marek Szyprowski

Hello,

On 2013-12-04 15:14, Hans Verkuil wrote:

Commit dc77523c5da5513df1bbc74db2a522a94f4cec0e ensured that m.offset is
only set for the MMAP memory mode by calling __setup_offsets only for that
mode.

However, __setup_offsets also initializes the length fields, and that should
be done regardless of the memory mode. Because of that change the v4l2-ctl
test application fails for the USERPTR mode.

This fix creates a __setup_lengths function that sets the length, and
__setup_offsets just sets the offset and no longer touches the length.

Signed-off-by: Hans Verkuil 


Acked-by: Marek Szyprowski 


---
  drivers/media/v4l2-core/videobuf2-core.c | 21 -
  1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 57ba131..0edc165 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -145,6 +145,25 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb)
  }
  
  /**

+ * __setup_lengths() - setup initial lengths for every plane in
+ * every buffer on the queue
+ */
+static void __setup_lengths(struct vb2_queue *q, unsigned int n)
+{
+   unsigned int buffer, plane;
+   struct vb2_buffer *vb;
+
+   for (buffer = q->num_buffers; buffer < q->num_buffers + n; ++buffer) {
+   vb = q->bufs[buffer];
+   if (!vb)
+   continue;
+
+   for (plane = 0; plane < vb->num_planes; ++plane)
+   vb->v4l2_planes[plane].length = q->plane_sizes[plane];
+   }
+}
+
+/**
   * __setup_offsets() - setup unique offsets ("cookies") for every plane in
   * every buffer on the queue
   */
@@ -169,7 +188,6 @@ static void __setup_offsets(struct vb2_queue *q, unsigned 
int n)
continue;
  
  		for (plane = 0; plane < vb->num_planes; ++plane) {

-   vb->v4l2_planes[plane].length = q->plane_sizes[plane];
vb->v4l2_planes[plane].m.mem_offset = off;
  
  			dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n",

@@ -241,6 +259,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum 
v4l2_memory memory,
q->bufs[q->num_buffers + buffer] = vb;
}
  
+	__setup_lengths(q, buffer);

if (memory == V4L2_MEMORY_MMAP)
__setup_offsets(q, buffer);
  


Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

--
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: Can't open mfc v5 encode but decode can

2013-12-05 Thread Kamil Debski
Hi Randy,

> -Original Message-
> From: randy [mailto:lxr1...@hotmail.com]
> Sent: Thursday, December 05, 2013 1:27 AM
> To: linux-media@vger.kernel.org
> Cc: Kamil Debski; m.szyprow...@samsung.com; kyungmin.p...@samsung.com;
> m.che...@samsung.com; jtp.p...@samsung.com
> Subject: Re: Can't open mfc v5 encode but decode can
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> ? 2013?12?03? 18:44, Kamil Debski ??:
> > Hi Randy,
> >
> > We also experienced this issue. One of the changes in the v4l2 core
> > affected the MFC driver. A fix for MFC has been prepared by Marek
> > Szyprowski and should be sent out soon.
> >
> When it is sending, may you CC me, I will test it.
> > Also another tip - in 3.13 a check on bytesused and length fields in
> > planes array has been implemented. So make sure to set them
> > appropriately.
> >
> > Best wishes,
> 
> Could you give me some example code of using samsung mfc v5 encode?
> I only get some sample from samsung BSP's android-4.2.2, in
> hardware/samsung_slsi/exynos4/multimedia/ , has
> codecs/video/exynos4/mfc_v4l2/enc/src/SsbSipMfcEncAPI.c achived this?
> Thanks

You can find the example applications here:
http://git.infradead.org/users/kmpark/public-apps

Best wishes, 
-- 
Kamil Debski
Samsung R&D Institute Poland

--
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 v9] s5k5baf: add camera sensor driver

2013-12-05 Thread Mark Rutland
On Wed, Dec 04, 2013 at 11:17:43PM +, Sylwester Nawrocki wrote:
> On 10/31/2013 04:29 PM, Andrzej Hajda wrote:
> > Driver for Samsung S5K5BAF UXGA 1/5" 2M CMOS Image Sensor
> > with embedded SoC ISP.
> > The driver exposes the sensor as two V4L2 subdevices:
> > - S5K5BAF-CIS - pure CMOS Image Sensor, fixed 1600x1200 format,
> >no controls.
> > - S5K5BAF-ISP - Image Signal Processor, formats up to 1600x1200,
> >pre/post ISP cropping, downscaling via selection API, controls.
> >
> > Signed-off-by: Sylwester Nawrocki
> > Signed-off-by: Andrzej Hajda
> > Signed-off-by: Kyungmin Park
> > ---
> > Hi,
> >
> > This is the 9th iteration of the patch.
> > In this iteration 'binary' blobs from source
> > file have been moved to separate firmware file.
> > Firmware file will be uploaded to appropriate
> > repository.
> [...]
> > v9
> > - patch, ccm and cis configuration blobs moved to
> >firmware set files,
> > - minor improvements of bindings,
> > - cosmetic changes
>
> Hi Mark,

Hi Sylwester,

>
> What do you think about this DT binding now, could we have your Ack ?

Other than a minor nit below, the binding looks fine to me.

With the fixed, for the binding:

Acked-by: Mark Rutland 

> I think we still need to move the DT binding into a separate patch.

If you're going to post the patch again, then please do split the
binding into a separate patch.

[...]

> > diff --git a/Documentation/devicetree/bindings/media/samsung-s5k5baf.txt 
> > b/Documentation/devicetree/bindings/media/samsung-s5k5baf.txt
> > new file mode 100644
> > index 000..23ebe0f
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/media/samsung-s5k5baf.txt
> > @@ -0,0 +1,57 @@
> > +Samsung S5K5BAF UXGA 1/5" 2M CMOS Image Sensor with embedded SoC ISP
> > +
> > +
> > +Required properties:
> > +
> > +- compatible   : "samsung,s5k5baf";
> > +- reg  : I2C slave address of the sensor;
> > +- vdda-supply  : analog power supply 2.8V (2.6V to 3.0V);
> > +- vddreg-supply: regulator input power supply 1.8V (1.7V to 1.9V)
> > + or 2.8V (2.6V to 3.0);
> > +- vddio-supply : I/O power supply 1.8V (1.65V to 1.95V)
> > + or 2.8V (2.5V to 3.1V);
> > +- stbyn-gpios  : GPIO connected to STDBYN pin;
> > +- rstn-gpios   : GPIO connected to RSTN pin;
> > +- clocks   : clock-specifiers (per the common clock bindings) for the
> > + clocks described in clock-names;

Clocks are referred to by phandle + clock-specifier pairs rather than
just clock-specifiers, it would be nice to fix up the terminology here.

Thanks,
Mark.
--
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


[RFCv3 PATCH 05/10] vb2: don't set index, don't start streaming for write()

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

Two fixes:

- there is no need to set the index when calling dqbuf: dqbuf will
  overwrite it.
- __vb2_init_fileio already starts streaming for write(), so there is
  no need to do it again in __vb2_perform_fileio. It can never have
  worked anyway: either __vb2_init_fileio succeeds in starting streaming
  or it is never going to happen.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 1e7da46..f415fd7 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2402,7 +2402,6 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
memset(&fileio->b, 0, sizeof(fileio->b));
fileio->b.type = q->type;
fileio->b.memory = q->memory;
-   fileio->b.index = index;
ret = vb2_internal_dqbuf(q, &fileio->b, nonblock);
dprintk(5, "file io: vb2_dqbuf result: %d\n", ret);
if (ret)
@@ -2484,15 +2483,6 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
 * Switch to the next buffer
 */
fileio->index = (index + 1) % q->num_buffers;
-
-   /*
-* Start streaming if required.
-*/
-   if (!read && !q->streaming) {
-   ret = vb2_internal_streamon(q, q->type);
-   if (ret)
-   return ret;
-   }
}
 
/*
-- 
1.8.4.3

--
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


[RFCv3 PATCH 01/10] vb2: push the mmap semaphore down to __buf_prepare()

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

Rather than taking the mmap semaphore at a relatively high-level function,
push it down to the place where it is really needed.

It was placed in vb2_queue_or_prepare_buf() to prevent racing with other
vb2 calls. The only way I can see that a race can happen is when two
threads queue the same buffer. The solution for that it to introduce
a PREPARING state.

Moving it down offers opportunities to simplify the code.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 82 ++--
 include/media/videobuf2-core.h   |  2 +
 2 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 57ba131..634dc95 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -462,6 +462,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
struct v4l2_buffer *b)
case VB2_BUF_STATE_PREPARED:
b->flags |= V4L2_BUF_FLAG_PREPARED;
break;
+   case VB2_BUF_STATE_PREPARING:
case VB2_BUF_STATE_DEQUEUED:
/* nothing */
break;
@@ -1207,6 +1208,7 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
 static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b)
 {
struct vb2_queue *q = vb->vb2_queue;
+   struct rw_semaphore *mmap_sem;
int ret;
 
ret = __verify_length(vb, b);
@@ -1216,12 +1218,31 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
return ret;
}
 
+   vb->state = VB2_BUF_STATE_PREPARING;
switch (q->memory) {
case V4L2_MEMORY_MMAP:
ret = __qbuf_mmap(vb, b);
break;
case V4L2_MEMORY_USERPTR:
+   /*
+* In case of user pointer buffers vb2 allocators need to get 
direct
+* access to userspace pages. This requires getting the mmap 
semaphore
+* for read access in the current process structure. The same 
semaphore
+* is taken before calling mmap operation, while both 
qbuf/prepare_buf
+* and mmap are called by the driver or v4l2 core with the 
driver's lock
+* held. To avoid an AB-BA deadlock (mmap_sem then driver's 
lock in mmap
+* and driver's lock then mmap_sem in qbuf/prepare_buf) the 
videobuf2
+* core releases the driver's lock, takes mmap_sem and then 
takes the
+* driver's lock again.
+*/
+   mmap_sem = ¤t->mm->mmap_sem;
+   call_qop(q, wait_prepare, q);
+   down_read(mmap_sem);
+   call_qop(q, wait_finish, q);
+
ret = __qbuf_userptr(vb, b);
+
+   up_read(mmap_sem);
break;
case V4L2_MEMORY_DMABUF:
ret = __qbuf_dmabuf(vb, b);
@@ -1235,8 +1256,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
ret = call_qop(q, buf_prepare, vb);
if (ret)
dprintk(1, "qbuf: buffer preparation failed: %d\n", ret);
-   else
-   vb->state = VB2_BUF_STATE_PREPARED;
+   vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED;
 
return ret;
 }
@@ -1247,80 +1267,47 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue 
*q, struct v4l2_buffer *b,
   struct v4l2_buffer *,
   struct vb2_buffer *))
 {
-   struct rw_semaphore *mmap_sem = NULL;
struct vb2_buffer *vb;
int ret;
 
-   /*
-* In case of user pointer buffers vb2 allocators need to get direct
-* access to userspace pages. This requires getting the mmap semaphore
-* for read access in the current process structure. The same semaphore
-* is taken before calling mmap operation, while both qbuf/prepare_buf
-* and mmap are called by the driver or v4l2 core with the driver's lock
-* held. To avoid an AB-BA deadlock (mmap_sem then driver's lock in mmap
-* and driver's lock then mmap_sem in qbuf/prepare_buf) the videobuf2
-* core releases the driver's lock, takes mmap_sem and then takes the
-* driver's lock again.
-*
-* To avoid racing with other vb2 calls, which might be called after
-* releasing the driver's lock, this operation is performed at the
-* beginning of qbuf/prepare_buf processing. This way the queue status
-* is consistent after getting the driver's lock back.
-*/
-   if (q->memory == V4L2_MEMORY_USERPTR) {
-   mmap_sem = ¤t->mm->mmap_sem;
-   call_qop(q, wait_prepare, q);
-   down_read(mmap_sem);
-   call_qop(q, wait_finish, q);
-   }
-
if (q-

[RFCv3 PATCH 10/10] vb2: fix race condition between REQBUFS and QBUF/PREPARE_BUF.

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

When preparing a buffer the queue lock is released for a short while
if the memory mode is USERPTR (see __buf_prepare for the details), which
would allow a race with a REQBUFS which can free the buffers. Removing the
buffers from underneath __buf_prepare is obviously a bad idea, so we
check if any of the buffers is in the state PREPARING, and if so we
just return -EAGAIN.

If this happens, then the application does something really strange. The
REQBUFS call can be retried safely, since this situation is transient.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 7a489aa..e814d87 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -284,10 +284,28 @@ static void __vb2_free_mem(struct vb2_queue *q, unsigned 
int buffers)
  * related information, if no buffers are left return the queue to an
  * uninitialized state. Might be called even if the queue has already been 
freed.
  */
-static void __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
+static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers)
 {
unsigned int buffer;
 
+   /*
+* Sanity check: when preparing a buffer the queue lock is released for
+* a short while (see __buf_prepare for the details), which would allow
+* a race with a reqbufs which can call this function. Removing the
+* buffers from underneath __buf_prepare is obviously a bad idea, so we
+* check if any of the buffers is in the state PREPARING, and if so we
+* just return -EAGAIN.
+*/
+   for (buffer = q->num_buffers - buffers; buffer < q->num_buffers;
+++buffer) {
+   if (q->bufs[buffer] == NULL)
+   continue;
+   if (q->bufs[buffer]->state == VB2_BUF_STATE_PREPARING) {
+   dprintk(1, "reqbufs: preparing buffers, cannot free\n");
+   return -EAGAIN;
+   }
+   }
+
/* Call driver-provided cleanup function for each buffer, if provided */
if (q->ops->buf_cleanup) {
for (buffer = q->num_buffers - buffers; buffer < q->num_buffers;
@@ -312,6 +330,7 @@ static void __vb2_queue_free(struct vb2_queue *q, unsigned 
int buffers)
if (!q->num_buffers)
q->memory = 0;
INIT_LIST_HEAD(&q->queued_list);
+   return 0;
 }
 
 /**
@@ -644,7 +663,9 @@ static int __reqbufs(struct vb2_queue *q, struct 
v4l2_requestbuffers *req)
return -EBUSY;
}
 
-   __vb2_queue_free(q, q->num_buffers);
+   ret = __vb2_queue_free(q, q->num_buffers);
+   if (ret)
+   return ret;
 
/*
 * In case of REQBUFS(0) return immediately without calling
-- 
1.8.4.3

--
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


[RFCv3 PATCH 07/10] vb2: add thread support

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

In order to implement vb2 DVB support you need to be able to start
a kernel thread that queues and dequeues buffers, calling a callback
function for every buffer. This patch adds support for that.

It's based on drivers/media/v4l2-core/videobuf-dvb.c, but with all the DVB
specific stuff stripped out, thus making it much more generic.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 139 +++
 include/media/videobuf2-core.h   |  32 +++
 2 files changed, 171 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index f415fd7..1434e23 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -6,6 +6,9 @@
  * Author: Pawel Osciak 
  *Marek Szyprowski 
  *
+ * The vb2_thread implementation was based on code from videobuf-dvb.c:
+ * (c) 2004 Gerd Knorr  [SUSE Labs]
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation.
@@ -18,6 +21,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -2508,6 +2513,140 @@ size_t vb2_write(struct vb2_queue *q, const char __user 
*data, size_t count,
 }
 EXPORT_SYMBOL_GPL(vb2_write);
 
+struct vb2_threadio_data {
+   struct task_struct *thread;
+   vb2_thread_fnc fnc;
+   void *priv;
+   bool stop;
+};
+
+static int vb2_thread(void *data)
+{
+   struct vb2_queue *q = data;
+   struct vb2_threadio_data *threadio = q->threadio;
+   struct vb2_fileio_data *fileio = q->fileio;
+   int prequeue = 0;
+   int index = 0;
+   int ret = 0;
+
+   if (V4L2_TYPE_IS_OUTPUT(q->type))
+   prequeue = q->num_buffers;
+
+   set_freezable();
+
+   for (;;) {
+   struct vb2_buffer *vb;
+
+   /*
+* Call vb2_dqbuf to get buffer back.
+*/
+   memset(&fileio->b, 0, sizeof(fileio->b));
+   fileio->b.type = q->type;
+   fileio->b.memory = q->memory;
+   if (prequeue) {
+   fileio->b.index = index++;
+   prequeue--;
+   } else {
+   call_qop(q, wait_finish, q);
+   ret = vb2_internal_dqbuf(q, &fileio->b, 0);
+   call_qop(q, wait_prepare, q);
+   dprintk(5, "file io: vb2_dqbuf result: %d\n", ret);
+   }
+   if (threadio->stop)
+   break;
+   if (ret)
+   break;
+   try_to_freeze();
+
+   vb = q->bufs[fileio->b.index];
+   if (!(fileio->b.flags & V4L2_BUF_FLAG_ERROR))
+   ret = threadio->fnc(vb, threadio->priv);
+   if (ret)
+   break;
+   call_qop(q, wait_finish, q);
+   ret = vb2_internal_qbuf(q, &fileio->b);
+   call_qop(q, wait_prepare, q);
+   if (ret)
+   break;
+   }
+
+   /* Hmm, linux becomes *very* unhappy without this ... */
+   while (!kthread_should_stop()) {
+   set_current_state(TASK_INTERRUPTIBLE);
+   schedule();
+   }
+   return 0;
+}
+
+/*
+ * This function should not be used for anything else but the videobuf2-dvb
+ * support. If you think you have another good use-case for this, then please
+ * contact the linux-media mailinglist first.
+ */
+int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv,
+const char *thread_name)
+{
+   struct vb2_threadio_data *threadio;
+   int ret = 0;
+
+   if (q->threadio)
+   return -EBUSY;
+   if (vb2_is_busy(q))
+   return -EBUSY;
+   if (WARN_ON(q->fileio))
+   return -EBUSY;
+
+   threadio = kzalloc(sizeof(*threadio), GFP_KERNEL);
+   if (threadio == NULL)
+   return -ENOMEM;
+   threadio->fnc = fnc;
+   threadio->priv = priv;
+
+   ret = __vb2_init_fileio(q, !V4L2_TYPE_IS_OUTPUT(q->type));
+   dprintk(3, "file io: vb2_init_fileio result: %d\n", ret);
+   if (ret)
+   goto nomem;
+   q->threadio = threadio;
+   threadio->thread = kthread_run(vb2_thread, q, "vb2-%s", thread_name);
+   if (IS_ERR(threadio->thread)) {
+   ret = PTR_ERR(threadio->thread);
+   threadio->thread = NULL;
+   goto nothread;
+   }
+   return 0;
+
+nothread:
+   __vb2_cleanup_fileio(q);
+nomem:
+   kfree(threadio);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(vb2_thread_start);
+
+int vb2_thread_stop(struct vb2_queue *q)
+{
+   struct vb2_threadio_data *threadio = q->threadio;
+   struct vb2_fileio_data *fileio = q->fileio;
+   int err;
+
+ 

[RFCv3 PATCH 09/10] vb2: Improve file I/O emulation to handle buffers in any order

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

videobuf2 file I/O emulation assumed that buffers dequeued from the
driver would return in the order they were enqueued in the driver.

Improve the file I/O emulator's book-keeping to remove this assumption.

Also set the buf->size properly if a write() dequeues a buffer and the
VB2_FILEIO_WRITE_IMMEDIATELY flag is set.

Based on an initial patch by Andy Walls.

Signed-off-by: Hans Verkuil 
Reviewed-by: Andy Walls 
---
 drivers/media/v4l2-core/videobuf2-core.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 1434e23..7a489aa 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2317,6 +2317,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int 
read)
goto err_reqbufs;
fileio->bufs[i].queued = 1;
}
+   fileio->index = q->num_buffers;
}
 
/*
@@ -2392,15 +2393,11 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
}
fileio = q->fileio;
 
-   index = fileio->index;
-   buf = &fileio->bufs[index];
-
/*
 * Check if we need to dequeue the buffer.
 */
-   if (buf->queued) {
-   struct vb2_buffer *vb;
-
+   index = fileio->index;
+   if (index >= q->num_buffers) {
/*
 * Call vb2_dqbuf to get buffer back.
 */
@@ -2413,12 +2410,18 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
return ret;
fileio->dq_count += 1;
 
+   index = fileio->b.index;
+   buf = &fileio->bufs[index];
+   
/*
 * Get number of bytes filled by the driver
 */
-   vb = q->bufs[index];
-   buf->size = vb2_get_plane_payload(vb, 0);
+   buf->pos = 0;
buf->queued = 0;
+   buf->size = read ? vb2_get_plane_payload(q->bufs[index], 0)
+: vb2_plane_size(q->bufs[index], 0);
+   } else {
+   buf = &fileio->bufs[index];
}
 
/*
@@ -2481,13 +2484,10 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
char __user *data, size_
 */
buf->pos = 0;
buf->queued = 1;
-   buf->size = q->bufs[0]->v4l2_planes[0].length;
+   buf->size = vb2_plane_size(q->bufs[index], 0);
fileio->q_count += 1;
-
-   /*
-* Switch to the next buffer
-*/
-   fileio->index = (index + 1) % q->num_buffers;
+   if (fileio->index < q->num_buffers)
+   fileio->index++;
}
 
/*
-- 
1.8.4.3

--
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


[RFCv3 PATCH 06/10] vb2: return ENODATA in start_streaming in case of too few buffers.

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/davinci/vpbe_display.c   | 2 +-
 drivers/media/platform/davinci/vpif_capture.c   | 2 +-
 drivers/media/platform/davinci/vpif_display.c   | 2 +-
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c| 2 +-
 drivers/media/platform/s5p-tv/mixer_video.c | 2 +-
 drivers/media/platform/soc_camera/mx2_camera.c  | 2 +-
 drivers/staging/media/davinci_vpfe/vpfe_video.c | 2 ++
 7 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe_display.c 
b/drivers/media/platform/davinci/vpbe_display.c
index eac472b..53be7fc 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -347,7 +347,7 @@ static int vpbe_start_streaming(struct vb2_queue *vq, 
unsigned int count)
/* If buffer queue is empty, return error */
if (list_empty(&layer->dma_queue)) {
v4l2_err(&vpbe_dev->v4l2_dev, "buffer queue is empty\n");
-   return -EINVAL;
+   return -ENODATA;
}
/* Get the next frame from the buffer queue */
layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next,
diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index 52ac5e6..4b04a27 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -277,7 +277,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
if (list_empty(&common->dma_queue)) {
spin_unlock_irqrestore(&common->irqlock, flags);
vpif_dbg(1, debug, "buffer queue is empty\n");
-   return -EIO;
+   return -ENODATA;
}
 
/* Get the next frame from the buffer queue */
diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index c31bcf1..c5070dc 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -239,7 +239,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, 
unsigned int count)
if (list_empty(&common->dma_queue)) {
spin_unlock_irqrestore(&common->irqlock, flags);
vpif_err("buffer queue is empty\n");
-   return -EIO;
+   return -ENODATA;
}
 
/* Get the next frame from the buffer queue */
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 4ff3b6c..3bdfe85 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1863,7 +1863,7 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, 
unsigned int count)
if (ctx->src_bufs_cnt < ctx->pb_count) {
mfc_err("Need minimum %d OUTPUT buffers\n",
ctx->pb_count);
-   return -EINVAL;
+   return -ENODATA;
}
}
 
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c 
b/drivers/media/platform/s5p-tv/mixer_video.c
index 81b97db..220ec31 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -948,7 +948,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned 
int count)
 
if (count == 0) {
mxr_dbg(mdev, "no output buffers queued\n");
-   return -EINVAL;
+   return -ENODATA;
}
 
/* block any changes in output configuration */
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c 
b/drivers/media/platform/soc_camera/mx2_camera.c
index 45a0276..587e3d1 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -659,7 +659,7 @@ static int mx2_start_streaming(struct vb2_queue *q, 
unsigned int count)
unsigned long flags;
 
if (count < 2)
-   return -EINVAL;
+   return -ENODATA;
 
spin_lock_irqsave(&pcdev->lock, flags);
 
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c 
b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 24d98a6..a81b0ab 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -1201,6 +1201,8 @@ static int vpfe_start_streaming(struct vb2_queue *vq, 
unsigned int count)
unsigned long addr;
int ret;
 
+   if (count == 0)
+   return -ENODATA;
ret = mutex_lock_interruptible(&video->lock);
if (ret)
goto streamoff;
-- 
1.8.4.3

--
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


[RFCv3 PATCH 08/10] vb2: Add videobuf2-dvb support.

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

With the new vb2_thread_start/stop core code it is very easy to implement
videobuf2-dvb. This should simplify converting existing videobuf drivers to
vb2.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/Kconfig |   4 +
 drivers/media/v4l2-core/Makefile|   1 +
 drivers/media/v4l2-core/videobuf2-dvb.c | 336 
 include/media/videobuf2-dvb.h   |  58 ++
 4 files changed, 399 insertions(+)
 create mode 100644 drivers/media/v4l2-core/videobuf2-dvb.c
 create mode 100644 include/media/videobuf2-dvb.h

diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
index 8c05565..8cc76da 100644
--- a/drivers/media/v4l2-core/Kconfig
+++ b/drivers/media/v4l2-core/Kconfig
@@ -84,6 +84,10 @@ config VIDEOBUF2_DMA_SG
select VIDEOBUF2_CORE
select VIDEOBUF2_MEMOPS
 
+config VIDEOBUF2_DVB
+   tristate
+   select VIDEOBUF2_CORE
+
 config VIDEO_V4L2_INT_DEVICE
tristate "V4L2 int device (DEPRECATED)"
depends on VIDEO_V4L2
diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index 1a85eee..c73ac0d 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o
 obj-$(CONFIG_VIDEOBUF2_VMALLOC) += videobuf2-vmalloc.o
 obj-$(CONFIG_VIDEOBUF2_DMA_CONTIG) += videobuf2-dma-contig.o
 obj-$(CONFIG_VIDEOBUF2_DMA_SG) += videobuf2-dma-sg.o
+obj-$(CONFIG_VIDEOBUF2_DVB) += videobuf2-dvb.o
 
 ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
diff --git a/drivers/media/v4l2-core/videobuf2-dvb.c 
b/drivers/media/v4l2-core/videobuf2-dvb.c
new file mode 100644
index 000..d092698
--- /dev/null
+++ b/drivers/media/v4l2-core/videobuf2-dvb.c
@@ -0,0 +1,336 @@
+/*
+ *
+ * some helper function for simple DVB cards which simply DMA the
+ * complete transport stream and let the computer sort everything else
+ * (i.e. we are using the software demux, ...).  Also uses the
+ * video-buf to manage DMA buffers.
+ *
+ * (c) 2004 Gerd Knorr  [SUSE Labs]
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* -- */
+
+MODULE_AUTHOR("Gerd Knorr  [SuSE Labs]");
+MODULE_LICENSE("GPL");
+
+/* -- */
+
+static int dvb_fnc(struct vb2_buffer *vb, void *priv)
+{
+   struct vb2_dvb *dvb = priv;
+
+   dvb_dmx_swfilter(&dvb->demux, vb2_plane_vaddr(vb, 0),
+ vb2_get_plane_payload(vb, 0));
+   return 0;
+}
+
+static int vb2_dvb_start_feed(struct dvb_demux_feed *feed)
+{
+   struct dvb_demux *demux = feed->demux;
+   struct vb2_dvb *dvb = demux->priv;
+   int rc = 0;
+
+   if (!demux->dmx.frontend)
+   return -EINVAL;
+
+   mutex_lock(&dvb->lock);
+   dvb->nfeeds++;
+
+   if (!dvb->dvbq.threadio) {
+   rc = vb2_thread_start(&dvb->dvbq, dvb_fnc, dvb, dvb->name);
+   if (rc)
+   dvb->nfeeds--;
+   }
+   if (!rc)
+   rc = dvb->nfeeds;
+   mutex_unlock(&dvb->lock);
+   return rc;
+}
+
+static int vb2_dvb_stop_feed(struct dvb_demux_feed *feed)
+{
+   struct dvb_demux *demux = feed->demux;
+   struct vb2_dvb *dvb = demux->priv;
+   int err = 0;
+
+   mutex_lock(&dvb->lock);
+   dvb->nfeeds--;
+   if (0 == dvb->nfeeds)
+   err = vb2_thread_stop(&dvb->dvbq);
+   mutex_unlock(&dvb->lock);
+   return err;
+}
+
+static int vb2_dvb_register_adapter(struct vb2_dvb_frontends *fe,
+ struct module *module,
+ void *adapter_priv,
+ struct device *device,
+ char *adapter_name,
+ short *adapter_nr,
+ int mfe_shared)
+{
+   int result;
+
+   mutex_init(&fe->lock);
+
+   /* register adapter */
+   result = dvb_register_adapter(&fe->adapter, adapter_name, module,
+   device, adapter_nr);
+   if (result < 0) {
+   pr_warn("%s: dvb_register_adapter failed (errno = %d)\n",
+  adapter_name, result);
+   }
+   fe->adapter.priv = adapter_priv;
+   fe->adapter.mfe_shared = mfe_shared;
+
+   return result;
+}
+
+static int vb2_dvb_register_frontend(struct dvb_adapter *adapter,
+   struct vb2_dvb *dvb)
+{
+   int result;
+
+   /* register frontend */
+   result = dvb_register_frontend(adapter, dvb->frontend);
+   if (result < 0) {
+   pr_warn("%

[RFCv3 PATCH 02/10] vb2: simplify qbuf/prepare_buf by removing callback.

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

The callback used to merge the common code of the qbuf/prepare_buf
code can be removed now that the mmap_sem handling is pushed down to
__buf_prepare(). This makes the code more readable.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 118 +++
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 634dc95..1754d3f 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1262,14 +1262,8 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
 }
 
 static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b,
-   const char *opname,
-   int (*handler)(struct vb2_queue *,
-  struct v4l2_buffer *,
-  struct vb2_buffer *))
+   const char *opname)
 {
-   struct vb2_buffer *vb;
-   int ret;
-
if (q->fileio) {
dprintk(1, "%s(): file io in progress\n", opname);
return -EBUSY;
@@ -1285,8 +1279,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, 
struct v4l2_buffer *b,
return -EINVAL;
}
 
-   vb = q->bufs[b->index];
-   if (NULL == vb) {
+   if (q->bufs[b->index] == NULL) {
/* Should never happen */
dprintk(1, "%s(): buffer is NULL\n", opname);
return -EINVAL;
@@ -1297,30 +1290,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, 
struct v4l2_buffer *b,
return -EINVAL;
}
 
-   ret = __verify_planes_array(vb, b);
-   if (ret)
-   return ret;
-
-   ret = handler(q, b, vb);
-   if (!ret) {
-   /* Fill buffer information for the userspace */
-   __fill_v4l2_buffer(vb, b);
-
-   dprintk(1, "%s() of buffer %d succeeded\n", opname, 
vb->v4l2_buf.index);
-   }
-   return ret;
-}
-
-static int __vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b,
-struct vb2_buffer *vb)
-{
-   if (vb->state != VB2_BUF_STATE_DEQUEUED) {
-   dprintk(1, "%s(): invalid buffer state %d\n", __func__,
-   vb->state);
-   return -EINVAL;
-   }
-
-   return __buf_prepare(vb, b);
+   return __verify_planes_array(q->bufs[b->index], b);
 }
 
 /**
@@ -1340,20 +1310,68 @@ static int __vb2_prepare_buf(struct vb2_queue *q, 
struct v4l2_buffer *b,
  */
 int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
-   return vb2_queue_or_prepare_buf(q, b, "prepare_buf", __vb2_prepare_buf);
+   int ret = vb2_queue_or_prepare_buf(q, b, "prepare_buf");
+   struct vb2_buffer *vb;
+
+   if (ret)
+   return ret;
+
+   vb = q->bufs[b->index];
+   if (vb->state != VB2_BUF_STATE_DEQUEUED) {
+   dprintk(1, "%s(): invalid buffer state %d\n", __func__,
+   vb->state);
+   return -EINVAL;
+   }
+
+   ret = __buf_prepare(vb, b);
+   if (!ret) {
+   /* Fill buffer information for the userspace */
+   __fill_v4l2_buffer(vb, b);
+
+   dprintk(1, "%s() of buffer %d succeeded\n", __func__, 
vb->v4l2_buf.index);
+   }
+   return ret;
 }
 EXPORT_SYMBOL_GPL(vb2_prepare_buf);
 
-static int __vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b,
- struct vb2_buffer *vb)
+/**
+ * vb2_qbuf() - Queue a buffer from userspace
+ * @q: videobuf2 queue
+ * @b: buffer structure passed from userspace to vidioc_qbuf handler
+ * in driver
+ *
+ * Should be called from vidioc_qbuf ioctl handler of a driver.
+ * This function:
+ * 1) verifies the passed buffer,
+ * 2) if necessary, calls buf_prepare callback in the driver (if provided), in
+ *which driver-specific buffer initialization can be performed,
+ * 3) if streaming is on, queues the buffer in driver by the means of buf_queue
+ *callback for processing.
+ *
+ * The return values from this function are intended to be directly returned
+ * from vidioc_qbuf handler in driver.
+ */
+int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
-   int ret;
+   int ret = vb2_queue_or_prepare_buf(q, b, "qbuf");
+   struct vb2_buffer *vb;
+
+   if (ret)
+   return ret;
+
+   vb = q->bufs[b->index];
+   if (vb->state != VB2_BUF_STATE_DEQUEUED) {
+   dprintk(1, "%s(): invalid buffer state %d\n", __func__,
+   vb->state);
+   return -EINVAL;
+   }
 
switch (vb->state) {
case VB2_BUF_STATE_DEQUEUED:
ret = __buf_prepare(vb, b);
if (ret)

[RFCv3 PATCH 03/10] vb2: remove the 'fileio = NULL' hack.

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

The read/write implementation in vb2 reuses existing vb2 functions, but
it sets q->fileio to NULL before calling them in order to skip the
'q->fileio != NULL' check.

This works today due to the synchronous nature of read/write, but it
1) is ugly, and 2) will fail in an asynchronous use-case such as a
thread queuing and dequeuing buffers. This last example will be necessary
in order to implement vb2 DVB support.

This patch removes the hack by splitting up the dqbuf/qbuf/streamon/streamoff
functions into an external and an internal version. The external version
checks q->fileio and then calls the internal version. The read/write
implementation now just uses the internal version, removing the need to
set q->fileio to NULL.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 223 ---
 1 file changed, 112 insertions(+), 111 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 1754d3f..10821a2 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1264,11 +1264,6 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
struct v4l2_buffer *b)
 static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b,
const char *opname)
 {
-   if (q->fileio) {
-   dprintk(1, "%s(): file io in progress\n", opname);
-   return -EBUSY;
-   }
-
if (b->type != q->type) {
dprintk(1, "%s(): invalid buffer type\n", opname);
return -EINVAL;
@@ -1310,9 +1305,15 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, 
struct v4l2_buffer *b,
  */
 int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
-   int ret = vb2_queue_or_prepare_buf(q, b, "prepare_buf");
struct vb2_buffer *vb;
+   int ret;
+
+   if (q->fileio) {
+   dprintk(1, "%s(): file io in progress\n", __func__);
+   return -EBUSY;
+   }
 
+   ret = vb2_queue_or_prepare_buf(q, b, "prepare_buf");
if (ret)
return ret;
 
@@ -1334,24 +1335,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct 
v4l2_buffer *b)
 }
 EXPORT_SYMBOL_GPL(vb2_prepare_buf);
 
-/**
- * vb2_qbuf() - Queue a buffer from userspace
- * @q: videobuf2 queue
- * @b: buffer structure passed from userspace to vidioc_qbuf handler
- * in driver
- *
- * Should be called from vidioc_qbuf ioctl handler of a driver.
- * This function:
- * 1) verifies the passed buffer,
- * 2) if necessary, calls buf_prepare callback in the driver (if provided), in
- *which driver-specific buffer initialization can be performed,
- * 3) if streaming is on, queues the buffer in driver by the means of buf_queue
- *callback for processing.
- *
- * The return values from this function are intended to be directly returned
- * from vidioc_qbuf handler in driver.
- */
-int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
+static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
int ret = vb2_queue_or_prepare_buf(q, b, "qbuf");
struct vb2_buffer *vb;
@@ -1402,6 +1386,33 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
dprintk(1, "%s() of buffer %d succeeded\n", __func__, 
vb->v4l2_buf.index);
return 0;
 }
+
+/**
+ * vb2_qbuf() - Queue a buffer from userspace
+ * @q: videobuf2 queue
+ * @b: buffer structure passed from userspace to vidioc_qbuf handler
+ * in driver
+ *
+ * Should be called from vidioc_qbuf ioctl handler of a driver.
+ * This function:
+ * 1) verifies the passed buffer,
+ * 2) if necessary, calls buf_prepare callback in the driver (if provided), in
+ *which driver-specific buffer initialization can be performed,
+ * 3) if streaming is on, queues the buffer in driver by the means of buf_queue
+ *callback for processing.
+ *
+ * The return values from this function are intended to be directly returned
+ * from vidioc_qbuf handler in driver.
+ */
+int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
+{
+   if (q->fileio) {
+   dprintk(1, "%s(): file io in progress\n", __func__);
+   return -EBUSY;
+   }
+
+   return vb2_internal_qbuf(q, b);
+}
 EXPORT_SYMBOL_GPL(vb2_qbuf);
 
 /**
@@ -1550,37 +1561,11 @@ static void __vb2_dqbuf(struct vb2_buffer *vb)
}
 }
 
-/**
- * vb2_dqbuf() - Dequeue a buffer to the userspace
- * @q: videobuf2 queue
- * @b: buffer structure passed from userspace to vidioc_dqbuf handler
- * in driver
- * @nonblocking: if true, this call will not sleep waiting for a buffer if no
- *  buffers ready for dequeuing are present. Normally the driver
- *  would be passing (file->f_flags & O_NONBLOCK) here
- *
- * Should be called from vidioc_dqbuf ioctl handler of a driver.
- * This

vb2: various cleanups and improvements

2013-12-05 Thread Hans Verkuil
This patch series does some cleanups in the qbuf/prepare_buf handling
(the first two patches). The third patch removes the 'fileio = NULL'
hack. That hack no longer works when dealing with asynchronous calls
from a kernel thread so it had to be fixed.

The next three patches implement retrying start_streaming() if there are
not enough buffers queued for the DMA engine to start. I know that there
are more drivers that can be simplified with this feature available in
the core. Those drivers do the retry of start_streaming in the buf_queue
op which frankly defeats the purpose of having a central start_streaming
op. But I leave it to the driver developers to decide whether or not to
cleanup their drivers.

The big advantage is that apps can just call STREAMON first, then start
queuing buffers without having to know the minimum number of buffers that
have to be queued before the DMA engine will kick in. It always annoyed
me that vb2 didn't take care of that for me as it is easy enough to do.

The next two patches add vb2 thread support which is necessary
for both videobuf2-dvb (the vb2 replacement of videobuf-dvb) and for e.g.
alsa drivers where you use the same trick as with dvb.

The thread implementation has been tested with both alsa recording and
playback for an internal driver (sorry, I can't share the source yet).

The next patch adds a fix based on a patch from Andy that removes the
file I/O emulation assumption that buffers are dequeued in the same
order that they were enqueued.

The final patch fixes another race condition between QBUF/PREPARE_BUF
and REQBUFS in the USERPTR case, also caused by the fact that __prepare_buf
temporarily unlocks the queue lock. The race was found by Laurent.

Regards,

Hans

New in v3:

- Added a comment to the thread_start function making it explicit that
  it is for use with videobuf2-dvb only.
- Added patch 10/10 to address yet another race condition.

New in v2:

- Added a PREPARING state in patch 1 to prevent a race condition that Laurent
  mentioned (two QBUF calls with the same index number at the same time).
- Changed some minor issues in patch 4 that Laurent mentioned in his review.
- Added the reworked version of Andy's original patch to remove the order
  assumption in the file I/O emulation.

--
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


[RFCv3 PATCH 04/10] vb2: retry start_streaming in case of insufficient buffers.

2013-12-05 Thread Hans Verkuil
From: Hans Verkuil 

If start_streaming returns -ENODATA, then it will be retried the next time
a buffer is queued. This means applications no longer need to know how many
buffers need to be queued before STREAMON can be called. This is particularly
useful for output stream I/O.

If a DMA engine needs at least X buffers before it can start streaming, then
for applications to get a buffer out as soon as possible they need to know
the minimum number of buffers to queue before STREAMON can be called. You can't
just try STREAMON after every buffer since on failure STREAMON will dequeue
all your buffers. (Is that a bug or a feature? Frankly, I'm not sure).

This patch simplifies applications substantially: they can just call STREAMON
at the beginning and then start queuing buffers and the DMA engine will
kick in automagically once enough buffers are available.

This also fixes using write() to stream video: the fileio implementation
calls streamon without having any queued buffers, which will fail today for
any driver that requires a minimum number of buffers.

Signed-off-by: Hans Verkuil 
---
 drivers/media/v4l2-core/videobuf2-core.c | 68 ++--
 include/media/videobuf2-core.h   | 15 +--
 2 files changed, 66 insertions(+), 17 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 10821a2..1e7da46 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1335,6 +1335,39 @@ int vb2_prepare_buf(struct vb2_queue *q, struct 
v4l2_buffer *b)
 }
 EXPORT_SYMBOL_GPL(vb2_prepare_buf);
 
+/**
+ * vb2_start_streaming() - Attempt to start streaming.
+ * @q: videobuf2 queue
+ *
+ * If there are not enough buffers, then retry_start_streaming is set to
+ * 1 and 0 is returned. The next time a buffer is queued and
+ * retry_start_streaming is 1, this function will be called again to
+ * retry starting the DMA engine.
+ */
+static int vb2_start_streaming(struct vb2_queue *q)
+{
+   int ret;
+
+   /* Tell the driver to start streaming */
+   ret = call_qop(q, start_streaming, q, atomic_read(&q->queued_count));
+
+   /*
+* If there are not enough buffers queued to start streaming, then
+* the start_streaming operation will return -ENODATA and you have to
+* retry when the next buffer is queued.
+*/
+   if (ret == -ENODATA) {
+   dprintk(1, "qbuf: not enough buffers, retry when more buffers 
are queued.\n");
+   q->retry_start_streaming = 1;
+   return 0;
+   }
+   if (ret)
+   dprintk(1, "qbuf: driver refused to start streaming\n");
+   else
+   q->retry_start_streaming = 0;
+   return ret;
+}
+
 static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
 {
int ret = vb2_queue_or_prepare_buf(q, b, "qbuf");
@@ -1383,6 +1416,12 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct 
v4l2_buffer *b)
/* Fill buffer information for the userspace */
__fill_v4l2_buffer(vb, b);
 
+   if (q->retry_start_streaming) {
+   ret = vb2_start_streaming(q);
+   if (ret)
+   return ret;
+   }
+
dprintk(1, "%s() of buffer %d succeeded\n", __func__, 
vb->v4l2_buf.index);
return 0;
 }
@@ -1532,7 +1571,8 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q)
return -EINVAL;
}
 
-   wait_event(q->done_wq, !atomic_read(&q->queued_count));
+   if (!q->retry_start_streaming)
+   wait_event(q->done_wq, !atomic_read(&q->queued_count));
return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_wait_for_all_buffers);
@@ -1646,6 +1686,11 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
 {
unsigned int i;
 
+   if (q->retry_start_streaming) {
+   q->retry_start_streaming = 0;
+   q->streaming = 0;
+   }
+
/*
 * Tell driver to stop all transactions and release all queued
 * buffers.
@@ -1695,12 +1740,9 @@ static int vb2_internal_streamon(struct vb2_queue *q, 
enum v4l2_buf_type type)
list_for_each_entry(vb, &q->queued_list, queued_entry)
__enqueue_in_driver(vb);
 
-   /*
-* Let driver notice that streaming state has been enabled.
-*/
-   ret = call_qop(q, start_streaming, q, atomic_read(&q->queued_count));
+   /* Tell driver to start streaming. */
+   ret = vb2_start_streaming(q);
if (ret) {
-   dprintk(1, "streamon: driver refused to start streaming\n");
__vb2_queue_cancel(q);
return ret;
}
@@ -2270,15 +2312,15 @@ static int __vb2_init_fileio(struct vb2_queue *q, int 
read)
goto err_reqbufs;
fileio->bufs[i].queued = 1;
}
-
-   /*
-* Start streaming.
-