Re: [PATCH v12][ 06/12] ARM: dts: imx5*, imx6*: correct display-timings nodes.

2014-04-09 Thread Lothar Waßmann
Hi,

Shawn Guo wrote:
 On Mon, Apr 07, 2014 at 02:44:45PM +0200, Denis Carikli wrote:
  The imx-drm driver can't use the de-active and
  pixelclk-active display-timings properties yet.
  
  Instead the data-enable and the pixel data clock
  polarity are hardcoded in the imx-drm driver.
  
  So theses properties are now set to keep
  the same behaviour when imx-drm will start
  using them.
  
  Signed-off-by: Denis Carikli de...@eukrea.com
  ---
  ChangeLog v9-v10:
  - New patch that was splitted out of:
staging imx-drm: Use de-active and pixelclk-active
display-timings.
  ---
   arch/arm/boot/dts/imx51-babbage.dts   |2 ++
   arch/arm/boot/dts/imx53-m53evk.dts|2 ++
   arch/arm/boot/dts/imx53-tx53-x03x.dts |2 +-
   arch/arm/boot/dts/imx6qdl-gw53xx.dtsi |2 ++
   arch/arm/boot/dts/imx6qdl-gw54xx.dtsi |2 ++
   arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi |2 ++
   arch/arm/boot/dts/imx6qdl-sabreauto.dtsi  |2 ++
   arch/arm/boot/dts/imx6qdl-sabrelite.dtsi  |2 ++
   arch/arm/boot/dts/imx6qdl-sabresd.dtsi|2 ++
   9 files changed, 17 insertions(+), 1 deletion(-)
 
 ...
 
  diff --git a/arch/arm/boot/dts/imx53-tx53-x03x.dts 
  b/arch/arm/boot/dts/imx53-tx53-x03x.dts
  index 0217dde3..4092a81 100644
  --- a/arch/arm/boot/dts/imx53-tx53-x03x.dts
  +++ b/arch/arm/boot/dts/imx53-tx53-x03x.dts
  @@ -93,7 +93,7 @@
  hsync-active = 0;
  vsync-active = 0;
  de-active = 1;
  -   pixelclk-active = 1;
  +   pixelclk-active = 0;
 
 @Lothar, is this change correct?
 
No, the ET0430 display which is affected by this patch actually has an
inverted clock wrt the other displays of the family.

'pixelclk-active = 1' is the correct setting for this display!

Thanks, Shawn for the reminder.


Lothar Waßmann
-- 
___

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | i...@karo-electronics.de
___
--
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 7/8] [media] s5p_jpeg: Prevent JPEG 4:2:0 YUV 4:2:0 decompression

2014-04-09 Thread Jacek Anaszewski

On 04/08/2014 09:49 AM, Sachin Kamat wrote:

Hi Jacek,

On 7 April 2014 18:46, Jacek Anaszewski j.anaszew...@samsung.com wrote:

Prevent decompression of a JPEG 4:2:0 with odd width to
the YUV 4:2:0 compliant formats for Exynos4x12 SoCs and
adjust capture format to RGB565 in such a case. This is
required because the configuration would produce a raw
image with broken luma component.

Signed-off-by: Jacek Anaszewski j.anaszew...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

snip


+   if (ctx-subsampling == V4L2_JPEG_CHROMA_SUBSAMPLING_420 
+   (ctx-out_q.w  1) 
+   (pix-pixelformat == V4L2_PIX_FMT_NV12 ||
+pix-pixelformat == V4L2_PIX_FMT_NV21 ||
+pix-pixelformat == V4L2_PIX_FMT_YUV420)) {
+   pix-pixelformat = V4L2_PIX_FMT_RGB565;
+   fmt = s5p_jpeg_find_format(ctx, pix-pixelformat,
+   FMT_TYPE_CAPTURE);
+   v4l2_info(ctx-jpeg-v4l2_dev,
+ Adjusted capture fourcc to RGB565. Decompression\n
+ of a JPEG file with 4:2:0 subsampling and odd\n
+ width to the YUV 4:2:0 compliant formats produces\n
+ a raw image with broken luma component.\n);


This could be made a comment in the code rather than a info message.



Hello Sachin,

Thanks for the review. I put it into info message because this is
rather hard for the user to figure out why the adjustment occurred,
bearing in mind that JPEG with the same subsampling and even width
is decompressed properly. This is not a common adjustment like
alignment, and thus in my opinion it requires displaying the
information. Are there some rules that say what cases are relevant
for using the v4l2_info macro?

Regards,
Jacek Anaszewski
--
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 7/8] [media] s5p_jpeg: Prevent JPEG 4:2:0 YUV 4:2:0 decompression

2014-04-09 Thread Sachin Kamat
Hi Jacek,

On 9 April 2014 13:01, Jacek Anaszewski j.anaszew...@samsung.com wrote:
 On 04/08/2014 09:49 AM, Sachin Kamat wrote:


 Hello Sachin,

 Thanks for the review. I put it into info message because this is
 rather hard for the user to figure out why the adjustment occurred,
 bearing in mind that JPEG with the same subsampling and even width
 is decompressed properly. This is not a common adjustment like
 alignment, and thus in my opinion it requires displaying the
 information. Are there some rules that say what cases are relevant
 for using the v4l2_info macro?

Not really, but generally info messages are concise and detailed explanations
provided as part of comments.

-- 
With warm regards,
Sachin
--
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 7/8] [media] s5p_jpeg: Prevent JPEG 4:2:0 YUV 4:2:0 decompression

2014-04-09 Thread Jacek Anaszewski

On 04/09/2014 09:56 AM, Sachin Kamat wrote:

Hi Jacek,

On 9 April 2014 13:01, Jacek Anaszewski j.anaszew...@samsung.com wrote:

On 04/08/2014 09:49 AM, Sachin Kamat wrote:





Hello Sachin,

Thanks for the review. I put it into info message because this is
rather hard for the user to figure out why the adjustment occurred,
bearing in mind that JPEG with the same subsampling and even width
is decompressed properly. This is not a common adjustment like
alignment, and thus in my opinion it requires displaying the
information. Are there some rules that say what cases are relevant
for using the v4l2_info macro?


Not really, but generally info messages are concise and detailed explanations
provided as part of comments.



Thanks for the explanation, I will stick to it.

Regards,
Jacek Anaszewski
--
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


Kworld PlusTV All in One PI610 - need help

2014-04-09 Thread Julian Day
Hi,

I have this board which I think is about 2007 vintange. It has a PLX
PCI6140 PCI-PCI bridge, with both a TI TSB43AB22 IEEE1394 FireWire
controller and an NXP SAA7131E on the far side.

The tuner is a TDA8275A and the DVB-T decoder is the TDA10046A. It
reports a subsystem ID of 17de:7256.

The card has inputs for DVB-T/ATV, FM, S-Video, composite, stereo
audio and IR remote in addition to two Firewire ports.

In saa7134-cards.c I added an entry to the saa7134_pci_tbl so that it
is recognised. I also created a new entry in saa7134_boards, so that I
can experiment with the settings for this card, as I don't know that
it is going to be exactly the same as anything else:

[SAA7134_BOARD_KWORLD_PI610] = {
.name  = Kworld PlusTV All in One (PI610),
.tuner_type= TUNER_PHILIPS_TDA8290,
.radio_type= UNSET,
.tuner_addr= ADDR_UNSET,
.radio_addr= ADDR_UNSET,
.mpeg  = SAA7134_MPEG_DVB,
.inputs = {{
.name = name_tv,
.vmux = 1,
.amux = TV,
.tv   = 1,
}},
.radio = {
.name = name_radio,
.amux = TV,
}

I know I could probably add more inputs for the Composite/S-Video
inputs, but I don't know which mux settings they would be on yet, I
suspect that is trial and error. Also probably a bit more is needed to
get the IR remote working. Is there any wisdom for determining GPIO
settings?

So, next in saa7134-dvb.c, I think I need a tda1004x_config for this
board, so that I can use that in dvb_init(), which is where I'm really
stuck. I've no idea where to get the parameters for this struct.
I presume that agc_config will be TDA_10046_AGC_TDA827x and
.request_firmware will need to be set to
philips_tda1004x_request_firmware.

It seems that existing implementations are either 4MHz or 16MHz
xtal_freq. On this board there is what I take to be a 20.000 MHz
oscillator, (It's just marked 20.000) right next to the TDA10046A, no
sign of either a 4MHz or 16MHz source. How does this relate to
xtal_freq and if_freq? Looking at the dvb frontend for tda1004x.c, it
seems like a PLL is used to generate either a 48MHz or 53MHz clock
from this xtal. I would suppose that 48MHz is correct, in that it
should be like the 16MHz source, but with an N of 4 instead of 3,
which I think would imply that if_freq would be 045.

I guess demod_address is likely to be 0x8 and tuner_address is likely
to be 0x61 or 0x60. I think 0x61 seems more like it. What else needs
to be set there and is there any guidance on how to probe this type of
info?

With these mods scan shows tuning failed for every channel:
 tune to: 
 47400:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE
WARNING:  tuning failed!!!

and:
julian@pabay:~$ dmesg |grep -i saa
[   19.248098] saa7130/34: v4l2 driver version 0, 2, 17 loaded
[   19.248462] saa7133[0]: found at :04:08.0, rev: 209, irq: 16,
latency: 64, mmio: 0xfe6fb000
[   19.248467] saa7133[0]: subsystem: 17de:7256, board: Kworld PlusTV
All in One (PI610) [card=193,autodetected]
[   19.248482] saa7133[0]: board init: gpio is 100
[   19.400046] saa7133[0]: i2c eeprom 00: de 17 56 72 54 20 1c 00 43
43 a9 1c 55 d2 b2 92
[   19.400058] saa7133[0]: i2c eeprom 10: ff ff ff 0f ff 20 ff ff ff
ff ff ff ff ff ff 01
[   19.400068] saa7133[0]: i2c eeprom 20: 01 40 01 03 03 01 01 03 08
ff 00 fe ff ff ff ff
[   19.400077] saa7133[0]: i2c eeprom 30: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400087] saa7133[0]: i2c eeprom 40: ff 21 00 c2 96 10 03 32 15
56 ff ff ff ff ff ff
[   19.400096] saa7133[0]: i2c eeprom 50: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400106] saa7133[0]: i2c eeprom 60: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400115] saa7133[0]: i2c eeprom 70: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400124] saa7133[0]: i2c eeprom 80: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400134] saa7133[0]: i2c eeprom 90: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400143] saa7133[0]: i2c eeprom a0: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400153] saa7133[0]: i2c eeprom b0: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400162] saa7133[0]: i2c eeprom c0: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400171] saa7133[0]: i2c eeprom d0: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400181] saa7133[0]: i2c eeprom e0: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   19.400190] saa7133[0]: i2c eeprom f0: ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
[   24.053223] saa7133[0]: dsp access wait timeout [bit=WRR]
[   24.053764] saa7133[0]: dsp access wait timeout [bit=WRR]
[   24.116116] saa7133[0]: registered device video0 [v4l2]
[   24.116202] saa7133[0]: registered device vbi0
[   24.116260] saa7133[0]: registered device radio0
[   24.174563] saa7134 ALSA driver for DMA sound loaded
[   24.174590] saa7133[0]/alsa: saa7133[0] at 0xfe6fb000 irq 16
registered as 

Re: [PATCHv2 1/3] phy: Add exynos-simple-phy driver

2014-04-09 Thread Andrzej Hajda
Hi Tomasz,

On 04/08/2014 04:37 PM, Tomasz Stanislawski wrote:
 Add exynos-simple-phy driver to support a single register
 PHY interfaces present on Exynos4 SoC.
 
 Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
 ---
  .../devicetree/bindings/phy/samsung-phy.txt|   24 +++
  drivers/phy/Kconfig|5 +
  drivers/phy/Makefile   |1 +
  drivers/phy/exynos-simple-phy.c|  154 
 
  4 files changed, 184 insertions(+)
  create mode 100644 drivers/phy/exynos-simple-phy.c
 
 diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
 b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 index b422e38..f97c4c3 100644
 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
 +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 @@ -114,3 +114,27 @@ Example:
   compatible = samsung,exynos-sataphy-i2c;
   reg = 0x38;
   };
 +
 +Samsung S5P/EXYNOS SoC series SIMPLE PHY
 +-
 +
 +Required properties:
 +- compatible : should be one of the listed compatibles:
 + - samsung,exynos4210-simple-phy
 + - samsung,exynos4412-simple-phy
 +- reg : offset and length of the register set;
 +- #phy-cells : from the generic phy bindings, must be 1;
 +
 +For samsung,exynos4210-simple-phy compatible PHYs the second cell in
 +the PHY specifier identifies the PHY and its meaning is as follows:
 +  0 - HDMI PHY,
 +  1 - DAC PHY,
 +  2 - ADC PHY,
 +  3 - PCIE PHY.
 +  4 - SATA PHY.
 +
 +For samsung,exynos4412-simple-phy compatible PHYs the second cell in
 +the PHY specifier identifies the PHY and its meaning is as follows:
 +  0 - HDMI PHY,
 +  1 - ADC PHY,

What about using preprocessor macros?

 +
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index 3bb05f1..65ab783 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -166,4 +166,9 @@ config PHY_XGENE
   help
 This option enables support for APM X-Gene SoC multi-purpose PHY.
  
 +config EXYNOS_SIMPLE_PHY
 + tristate Exynos Simple PHY driver
 + help
 +   Support for 1-bit PHY controllers on SoCs from Exynos family.
 +
  endmenu
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index 2faf78e..88c5b60 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -18,3 +18,4 @@ obj-$(CONFIG_PHY_EXYNOS4210_USB2)   += phy-exynos4210-usb2.o
  obj-$(CONFIG_PHY_EXYNOS4X12_USB2)+= phy-exynos4x12-usb2.o
  obj-$(CONFIG_PHY_EXYNOS5250_USB2)+= phy-exynos5250-usb2.o
  obj-$(CONFIG_PHY_XGENE)  += phy-xgene.o
 +obj-$(CONFIG_EXYNOS_SIMPLE_PHY)  += exynos-simple-phy.o
 diff --git a/drivers/phy/exynos-simple-phy.c b/drivers/phy/exynos-simple-phy.c
 new file mode 100644
 index 000..57ad338
 --- /dev/null
 +++ b/drivers/phy/exynos-simple-phy.c
 @@ -0,0 +1,154 @@
 +/*
 + * Exynos Simple PHY driver
 + *
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + * Author: Tomasz Stanislawski t.stanisl...@samsung.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/of_address.h
 +#include linux/of_device.h
 +#include linux/phy/phy.h
 +
 +#define EXYNOS_PHY_ENABLE(1  0)
 +
 +static int exynos_phy_power_on(struct phy *phy)
 +{
 + void __iomem *reg = phy_get_drvdata(phy);
 + u32 val;
 +
 + val = readl(reg);
 + val |= EXYNOS_PHY_ENABLE;
 + writel(val, reg);
 +
 + return 0;
 +}
 +
 +static int exynos_phy_power_off(struct phy *phy)
 +{
 + void __iomem *reg = phy_get_drvdata(phy);
 + u32 val;
 +
 + val = readl(reg);
 + val = ~EXYNOS_PHY_ENABLE;
 + writel(val, reg);
 +
 + return 0;
 +}
 +
 +static struct phy_ops exynos_phy_ops = {
 + .power_on   = exynos_phy_power_on,
 + .power_off  = exynos_phy_power_off,
 + .owner  = THIS_MODULE,
 +};
 +
 +static const u32 exynos4210_offsets[] = {
 + 0x0700, /* HDMI_PHY */
 + 0x070C, /* DAC_PHY */
 + 0x0718, /* ADC_PHY */
 + 0x071C, /* PCIE_PHY */
 + 0x0720, /* SATA_PHY */
 + ~0, /* end mark */
 +};
 +
 +static const u32 exynos4412_offsets[] = {
 + 0x0700, /* HDMI_PHY */
 + 0x0718, /* ADC_PHY */
 + ~0, /* end mark */
 +};

Why have you selected only these registers?
According to specs Exynos 4210 has 9 and 4412 has 7 control registers
with 'phy-enable' functionality.
I guess MIPI would require little more work as it has also reset bits,
but it will be still better than separate driver.

 +
 +static const struct of_device_id exynos_phy_of_match[] = {
 + { .compatible = samsung,exynos4210-simple-phy,
 +   .data = exynos4210_offsets},
 + { .compatible = 

Progressive and continuous record of a DVB stream

2014-04-09 Thread shacky
Hi.

I need to make a continuous (H24) recording of some DVB-S and DVB-T
streams and I wish to let me to play it during its recording, without
waiting for the file closing.

The purpose is having something like a DVR which lets me to play a DVB
stream selecting a date/time, so I will also need to index every
recorded file trunk for channel, date and time (and I can make this in
a database).

I need to record every channel I find in the same MUX in a different TS file.

Is there any utility that could help me what I need?
Could you give me some advises, please?
I looked for some best practices but I didn't find anything special
regarding this question.

Thank you very much.
Bye!
--
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: gspca second isoc endpoint / kinect depth

2014-04-09 Thread Hans de Goede
Hi,

On 04/08/2014 08:13 PM, Alexander Sosna wrote:
 Hi,
 
 I took drivers/media/usb/gspca/kinect.c as skeleton to build a depth
 driver for the kinect camera.
 
 I needed to implement this feature because libfreenect performs so badly
 on the raspberry pi that you can't get a single frame.
 
 The kinecet has two isoc endpoints but gspca only uses the first.
 To get it running I made a dirty hack to drivers/media/usb/gspca/gspca.c
 I changed usb_host_endpoint *alt_xfer(...) so that it always returns the
 second endpoint, which is not really good for everyone.
 
 
 My driver is not ready for upstream now, it can not coexist with the
 current gspca_kinect so you have to decide if you want to load the video
 or the depth driver. Would be better to have one driver to do it all.
 
 But in the meantime I would like to ask for ideas about a more clean
 solution to get other isoc endpoints.
 
 There was already a little discussion about this when kinect.c was
 written by Antonio Ospite:
 http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/26194
 
 http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/26213
 
 Has something changed?

No.

 Is there a point against making multiple endpoints available?

No.

 Better solution?

Not that I know of.

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


Re: [PATCHv2 1/3] phy: Add exynos-simple-phy driver

2014-04-09 Thread Rahul Sharma
Hi Tomasz,

On 9 April 2014 14:07, Andrzej Hajda a.ha...@samsung.com wrote:
 Hi Tomasz,

 On 04/08/2014 04:37 PM, Tomasz Stanislawski wrote:
 Add exynos-simple-phy driver to support a single register
 PHY interfaces present on Exynos4 SoC.

 Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
 ---
  .../devicetree/bindings/phy/samsung-phy.txt|   24 +++
  drivers/phy/Kconfig|5 +
  drivers/phy/Makefile   |1 +
  drivers/phy/exynos-simple-phy.c|  154 
 
  4 files changed, 184 insertions(+)
  create mode 100644 drivers/phy/exynos-simple-phy.c

 diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
 b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 index b422e38..f97c4c3 100644
 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
 +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 @@ -114,3 +114,27 @@ Example:
   compatible = samsung,exynos-sataphy-i2c;
   reg = 0x38;
   };
 +
 +Samsung S5P/EXYNOS SoC series SIMPLE PHY
 +-
 +
 +Required properties:
 +- compatible : should be one of the listed compatibles:
 + - samsung,exynos4210-simple-phy
 + - samsung,exynos4412-simple-phy
 +- reg : offset and length of the register set;
 +- #phy-cells : from the generic phy bindings, must be 1;
 +
 +For samsung,exynos4210-simple-phy compatible PHYs the second cell in
 +the PHY specifier identifies the PHY and its meaning is as follows:
 +  0 - HDMI PHY,
 +  1 - DAC PHY,
 +  2 - ADC PHY,
 +  3 - PCIE PHY.
 +  4 - SATA PHY.
 +
 +For samsung,exynos4412-simple-phy compatible PHYs the second cell in
 +the PHY specifier identifies the PHY and its meaning is as follows:
 +  0 - HDMI PHY,
 +  1 - ADC PHY,

 What about using preprocessor macros?

 +
 diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
 index 3bb05f1..65ab783 100644
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -166,4 +166,9 @@ config PHY_XGENE
   help
 This option enables support for APM X-Gene SoC multi-purpose PHY.

 +config EXYNOS_SIMPLE_PHY
 + tristate Exynos Simple PHY driver
 + help
 +   Support for 1-bit PHY controllers on SoCs from Exynos family.
 +
  endmenu
 diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
 index 2faf78e..88c5b60 100644
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -18,3 +18,4 @@ obj-$(CONFIG_PHY_EXYNOS4210_USB2)   += 
 phy-exynos4210-usb2.o
  obj-$(CONFIG_PHY_EXYNOS4X12_USB2)+= phy-exynos4x12-usb2.o
  obj-$(CONFIG_PHY_EXYNOS5250_USB2)+= phy-exynos5250-usb2.o
  obj-$(CONFIG_PHY_XGENE)  += phy-xgene.o
 +obj-$(CONFIG_EXYNOS_SIMPLE_PHY)  += exynos-simple-phy.o
 diff --git a/drivers/phy/exynos-simple-phy.c 
 b/drivers/phy/exynos-simple-phy.c
 new file mode 100644
 index 000..57ad338
 --- /dev/null
 +++ b/drivers/phy/exynos-simple-phy.c
 @@ -0,0 +1,154 @@
 +/*
 + * Exynos Simple PHY driver
 + *
 + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 + * Author: Tomasz Stanislawski t.stanisl...@samsung.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/io.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/of_address.h
 +#include linux/of_device.h
 +#include linux/phy/phy.h
 +
 +#define EXYNOS_PHY_ENABLE(1  0)
 +
 +static int exynos_phy_power_on(struct phy *phy)
 +{
 + void __iomem *reg = phy_get_drvdata(phy);
 + u32 val;
 +
 + val = readl(reg);
 + val |= EXYNOS_PHY_ENABLE;
 + writel(val, reg);
 +
 + return 0;
 +}
 +
 +static int exynos_phy_power_off(struct phy *phy)
 +{
 + void __iomem *reg = phy_get_drvdata(phy);
 + u32 val;
 +
 + val = readl(reg);
 + val = ~EXYNOS_PHY_ENABLE;
 + writel(val, reg);
 +
 + return 0;
 +}
 +
 +static struct phy_ops exynos_phy_ops = {
 + .power_on   = exynos_phy_power_on,
 + .power_off  = exynos_phy_power_off,
 + .owner  = THIS_MODULE,
 +};
 +
 +static const u32 exynos4210_offsets[] = {
 + 0x0700, /* HDMI_PHY */
 + 0x070C, /* DAC_PHY */
 + 0x0718, /* ADC_PHY */
 + 0x071C, /* PCIE_PHY */
 + 0x0720, /* SATA_PHY */
 + ~0, /* end mark */
 +};
 +
 +static const u32 exynos4412_offsets[] = {
 + 0x0700, /* HDMI_PHY */
 + 0x0718, /* ADC_PHY */
 + ~0, /* end mark */
 +};

 Why have you selected only these registers?
 According to specs Exynos 4210 has 9 and 4412 has 7 control registers
 with 'phy-enable' functionality.
 I guess MIPI would require little more work as it has also reset bits,
 but it will be still better than separate driver.

 +
 +static const struct of_device_id exynos_phy_of_match[] = {
 + { .compatible = samsung,exynos4210-simple-phy,

Re: [PATCHv2 1/3] phy: Add exynos-simple-phy driver

2014-04-09 Thread Sylwester Nawrocki
Hi,

On 09/04/14 11:12, Rahul Sharma wrote:
 Idea looks good. How about keeping compatible which is independent
 of SoC, something like samsung,exynos-simple-phy and provide Reg
 and Bit through phy provider node. This way we can avoid SoC specific
 hardcoding in phy driver and don't need to look into dt bindings for
 each new SoC.

I believe it is a not recommended approach.

 We can use syscon interface to access PMU bits like USB phy.
 PMU is already registered as system controller

Yes, that sounds good. This way we could avoid overlapping memory
mapped register regions specified in 'reg' properties in the device
tree.

-- 
Thanks,
Sylwester
--
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: [PATCHv2 2/3] drm: exynos: hdmi: use hdmiphy as PHY

2014-04-09 Thread Andrzej Hajda
Hi Tomasz,

On 04/08/2014 04:37 PM, Tomasz Stanislawski wrote:
 The HDMIPHY (physical interface) is controlled by a single
 bit in a power controller's regiter. It was implemented
 as clock. It was a simple but effective hack.

This power controller register has also bits to control HDMI clock
divider ratio. I guess current drivers do not change it, but how do you
want to implement access to it if some HDMI driver in the future will
need to change ratio. I guess in case of clk it would be easier.

Regards
Andrzej


--
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: [PATCHv2 2/3] drm: exynos: hdmi: use hdmiphy as PHY

2014-04-09 Thread Rahul Sharma
Hi Andrzej,

On 9 April 2014 16:00, Andrzej Hajda a.ha...@samsung.com wrote:
 Hi Tomasz,

 On 04/08/2014 04:37 PM, Tomasz Stanislawski wrote:
 The HDMIPHY (physical interface) is controlled by a single
 bit in a power controller's regiter. It was implemented
 as clock. It was a simple but effective hack.

 This power controller register has also bits to control HDMI clock
 divider ratio. I guess current drivers do not change it, but how do you
 want to implement access to it if some HDMI driver in the future will
 need to change ratio. I guess in case of clk it would be easier.

If it is really required to change this divider, it should be registered as
a clock provider in clock driver exposing single divider clock.

Regards,
Rahul Sharma


 Regards
 Andrzej


 ___
 dri-devel mailing list
 dri-de...@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
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: [PATCHv2 2/3] drm: exynos: hdmi: use hdmiphy as PHY

2014-04-09 Thread Tomasz Stanislawski
Hi Andrzej,
This issue could be solved by exporting a regmap from PMU driver
or Exynos clock provider for the usage by exynos-simple-phy.
The operations on PHYs from exynos-simple-phy provider would
be chained to PMU driver and protected by a spinlock in the regmap.

Luckily, the divider is not used as far as I know.

Regards,
Tomasz Stanislawski

On 04/09/2014 12:30 PM, Andrzej Hajda wrote:
 Hi Tomasz,
 
 On 04/08/2014 04:37 PM, Tomasz Stanislawski wrote:
 The HDMIPHY (physical interface) is controlled by a single
 bit in a power controller's regiter. It was implemented
 as clock. It was a simple but effective hack.
 
 This power controller register has also bits to control HDMI clock
 divider ratio. I guess current drivers do not change it, but how do you
 want to implement access to it if some HDMI driver in the future will
 need to change ratio. I guess in case of clk it would be easier.
 
 Regards
 Andrzej
 
 

--
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: [PATCHv2 1/3] phy: Add exynos-simple-phy driver

2014-04-09 Thread Tomasz Stanislawski
Hi Rahul,

On 04/09/2014 11:12 AM, Rahul Sharma wrote:
 Hi Tomasz,
 
 On 9 April 2014 14:07, Andrzej Hajda a.ha...@samsung.com wrote:
 Hi Tomasz,

 On 04/08/2014 04:37 PM, Tomasz Stanislawski wrote:
 Add exynos-simple-phy driver to support a single register
 PHY interfaces present on Exynos4 SoC.

 Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com

[snip]

 +
 + regs = devm_ioremap(dev, res-start, res-end - res-start);
 + if (!regs) {
 + dev_err(dev, failed to ioremap registers\n);
 + return -EFAULT;
 + }

 Why not devm_ioremap_resource? If not, resource_size function calculates
 length of resource correctly.

 Anyway I like the idea of implementing multiple phys in one driver.
 The only drawback I see is that some phys will be created even there are
 no consumers for them. To avoid such situation you can try to use
 lazy approach - create phy only if there is request for it,
 exynos_phy_xlate callback should allow this.

 Regards
 Andrzej

 
 Idea looks good. How about keeping compatible which is independent
 of SoC, something like samsung,exynos-simple-phy and provide Reg
 and Bit through phy provider node. This way we can avoid SoC specific
 hardcoding in phy driver and don't need to look into dt bindings for
 each new SoC.

A very nice idea BUT there is a very strong pressure from DT guys
to avoid adding any bit fields/offsets/masks in DT nodes.

Hopefully, as long as driver name starts with exynos- prefix
one can hide SoCs specific tricks deep inside driver code.

The idea behind this driver was not to create a generic phy for 1-bit
devices but rather to hide SoC-specific issues from client drivers
like DRM-HDMI.

 
 We can use syscon interface to access PMU bits like USB phy.
 PMU is already registered as system controller
 

Ok. I will try to use it in PATCHv3.

 Regards,
 Rahul Sharma.
 

Regards,
Tomasz Stanislawski


--
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: [PATCHv2 1/3] phy: Add exynos-simple-phy driver

2014-04-09 Thread Andreas Oberritter
Hello Andrzej,

On 09.04.2014 10:37, Andrzej Hajda wrote:
 +static int exynos_phy_probe(struct platform_device *pdev)
 +{
 +const struct of_device_id *of_id = of_match_device(
 +of_match_ptr(exynos_phy_of_match), pdev-dev);
 +const u32 *offsets = of_id-data;
 +int count;
 +struct device *dev = pdev-dev;
 +struct phy **phys;
 +struct resource *res;
 +void __iomem *regs;
 +int i;
 +struct phy_provider *phy_provider;
 +
 +/* count number of phys to create */
 +for (count = 0; offsets[count] != ~0; ++count)
 +;
 
 count = ARRAY_SIZE(offsets) - 1;

u32 *offsets is not an array.

Regards,
Andreas
--
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] [media] V4L: s5c73m3: Fix build after v4l2_of_get_next_endpoint rename

2014-04-09 Thread Krzysztof Kozlowski
Fix build error after v4l2_of_get_next_endpoint rename (fd9fdb78a9bf:
[media] of: move graph helpers from drivers/media/v4l2-core...):

drivers/media/i2c/s5c73m3/s5c73m3-core.c: In function 
‘s5c73m3_get_platform_data’:
drivers/media/i2c/s5c73m3/s5c73m3-core.c:1619:2: error: implicit declaration of 
function ‘v4l2_of_get_next_endpoint’ [-Werror=implicit-function-declaration]
drivers/media/i2c/s5c73m3/s5c73m3-core.c:1619:10: warning: assignment makes 
pointer from integer without a cast [enabled by default]

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
---
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c 
b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index a4459301b5f8..ee0f57e01b56 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1616,7 +1616,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 
*state)
if (ret  0)
return -EINVAL;
 
-   node_ep = v4l2_of_get_next_endpoint(node, NULL);
+   node_ep = of_graph_get_next_endpoint(node, NULL);
if (!node_ep) {
dev_warn(dev, no endpoint defined for node: %s\n,
node-full_name);
-- 
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


Re: [PATCH v12][ 09/12] drm/panel: Add Eukrea mbimxsd51 displays.

2014-04-09 Thread Thierry Reding
On Mon, Apr 07, 2014 at 02:44:48PM +0200, Denis Carikli wrote:
[...]
 +static const struct panel_desc eukrea_mbimxsd51_dvisvga = {
 + .modes = eukrea_mbimxsd51_dvisvga_mode,
 + .num_modes = 1,
 + .size = {
 + .width = 0,
 + .height = 0,
 + },
 +};
[...]
 +static const struct panel_desc eukrea_mbimxsd51_dvivga = {
 + .modes = eukrea_mbimxsd51_dvivga_mode,
 + .num_modes = 1,
 + .size = {
 + .width = 0,
 + .height = 0,
 + },
 +};

Surely these two panels have a physical size?

Thierry


pgprwiymAtwfE.pgp
Description: PGP signature


Re: Kworld PlusTV All in One PI610 - need help

2014-04-09 Thread Steven Toth
I don't know the 7131 but the following advice is generic for any USB,
PCI or PCIE device:

Essentially, when correctly configured, the tuner will output an
Intermediate Frequency (IF). This is the frequency you've selected to
tune, for example 474MHz, isolated into a 8MHz band and shifted down
to a different frequency that the 10046 demodulator is designed to
receive. Typicaly IFs are 44Mhz, 6MHz or variations of.

So, rule #1, match the IF on the tuner to the IF settings for the
10046 demodulator. These are typically passed to tuner and demodulator
parts during dvb_attach with tuner and demodualtor specific
structures. Generally, this is very simple to to. If you create a
miss-match, the demodulator is never going to lock, no matter how many
times you tune the tuner to a new 474, 482 etc frequency.

Rule #2, you need reliable communication via i2c to the tuner. Look
for any i2c errors during communication.

 I guess demod_address is likely to be 0x8 and tuner_address is likely
 to be 0x61 or 0x60. I think 0x61 seems more like it. What else needs
 to be set there and is there any guidance on how to probe this type of
 info?

I typically probe the i2c bus using a logic analyzer to do this with a
PCI device. Often, poking at the windows driver configuration files
can reveal the I2C addresses but ideally, look directly at the I2C bus
when running the device under windows.


 With these mods scan shows tuning failed for every channel:
 tune to: 
 47400:INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_3_4:FEC_AUTO:QAM_16:TRANSMISSION_MODE_2K:GUARD_INTERVAL_1_32:HIERARCHY_NONE
 WARNING:  tuning failed!!!

My advice, don't rely on scanning. Find an exact and strong frequency
that's working reliably for you with another product and focus
specificially on that frequency when test the new PCI board. Use tzap
exclusive as a test tool until you see the tool report a LOCKED
status.

Once you have a LOCK, use the dvbtraffic tool in addition to tzap to
help diagnose, no other s/w tools should be required.


 and:
 julian@pabay:~$ dmesg |grep -i saa
 [   19.248098] saa7130/34: v4l2 driver version 0, 2, 17 loaded
 [   19.248462] saa7133[0]: found at :04:08.0, rev: 209, irq: 16,
 latency: 64, mmio: 0xfe6fb000
 [   19.248467] saa7133[0]: subsystem: 17de:7256, board: Kworld PlusTV
 All in One (PI610) [card=193,autodetected]
 [   19.248482] saa7133[0]: board init: gpio is 100
 [   19.400046] saa7133[0]: i2c eeprom 00: de 17 56 72 54 20 1c 00 43
 43 a9 1c 55 d2 b2 92
 [   19.400058] saa7133[0]: i2c eeprom 10: ff ff ff 0f ff 20 ff ff ff
 ff ff ff ff ff ff 01
 [   19.400068] saa7133[0]: i2c eeprom 20: 01 40 01 03 03 01 01 03 08
 ff 00 fe ff ff ff ff
 [   19.400077] saa7133[0]: i2c eeprom 30: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400087] saa7133[0]: i2c eeprom 40: ff 21 00 c2 96 10 03 32 15
 56 ff ff ff ff ff ff
 [   19.400096] saa7133[0]: i2c eeprom 50: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400106] saa7133[0]: i2c eeprom 60: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400115] saa7133[0]: i2c eeprom 70: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400124] saa7133[0]: i2c eeprom 80: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400134] saa7133[0]: i2c eeprom 90: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400143] saa7133[0]: i2c eeprom a0: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400153] saa7133[0]: i2c eeprom b0: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400162] saa7133[0]: i2c eeprom c0: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400171] saa7133[0]: i2c eeprom d0: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400181] saa7133[0]: i2c eeprom e0: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   19.400190] saa7133[0]: i2c eeprom f0: ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff
 [   24.053223] saa7133[0]: dsp access wait timeout [bit=WRR]
 [   24.053764] saa7133[0]: dsp access wait timeout [bit=WRR]
 [   24.116116] saa7133[0]: registered device video0 [v4l2]
 [   24.116202] saa7133[0]: registered device vbi0
 [   24.116260] saa7133[0]: registered device radio0
 [   24.174563] saa7134 ALSA driver for DMA sound loaded
 [   24.174590] saa7133[0]/alsa: saa7133[0] at 0xfe6fb000 irq 16
 registered as card -2
 [   24.179995] saa7133[0]: dsp access wait timeout [bit=WRR]
 [   24.180539] saa7133[0]: dsp access wait timeout [bit=WRR]
 [   24.185216] saa7133[0]: dsp access wait timeout [bit=WRR]
 [   24.185756] saa7133[0]: dsp access wait timeout [bit=WRR]
 [   24.640035] DVB: registering new adapter (saa7133[0])
 [   24.640043] saa7134 :04:08.0: DVB: registering adapter 0
 frontend 0 (Philips TDA10046H DVB-T)...
 [   25.632561] saa7133[0]: dsp access wait timeout [bit=WRR]

Once you have the demodulator locking, he next issue you'll
potentially come across is the MPEG interfacing between the
demodulator and the PCI controller. These are settings, usually passed
in the 10046 struct during 

[PATCH 0/8] Current imx-drm queue

2014-04-09 Thread Russell King - ARM Linux
Hi,

The following patches are those which I currently have queued up for
Greg for merging into his stable tree when he's next accepting patches.
If you have any concerns about these patches, please let me know in
a timely fashion.

I've re-ordered and cherry-picked some of Denis' patches, as I can't
take the patches which touch arch/arm/boot/dts.  Some other method is
going to have to be found to deal with those changes.

The unfortunate thing is that without the DT changes able to be merged
in a timely and sane manner, in a way which does not result in breaking
this driver, it pushes the point where we can finally think about moving
this driver out of drivers/staging back even further.

It seems arm-soc want to be obtuse, so let's let them be obtuse and show
what damage it does to being able to make progress.

Thanks.

Denis Carikli (3):
  imx-drm: Match ipu_di_signal_cfg's clk_pol with its description.
  v4l2: add new V4L2_PIX_FMT_RGB666 pixel format.
  imx-drm: Add RGB666 support for parallel display.

Fabio Estevam (2):
  imx-drm: ipu-dmfc: Remove unneeded 'dmfc' check
  imx-drm: imx-ldb: Use snprintf()

Philipp Zabel (3):
  imx-drm: Move IPU_PIX_FMT_GBR24 definition into imx-ipu-v3.h
  imx-drm: ipu-dc: Use usleep_range instead of msleep
  imx-drm: imx-ldb: Add drm_panel support

 Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml | 39 
+++
 Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt |  3 ++-
 drivers/staging/imx-drm/Kconfig   |  1 +
 drivers/staging/imx-drm/imx-drm.h |  4 
 drivers/staging/imx-drm/imx-ldb.c | 25 
+++--
 drivers/staging/imx-drm/imx-tve.c |  1 +
 drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h   |  2 ++
 drivers/staging/imx-drm/ipu-v3/ipu-dc.c   | 11 
++-
 drivers/staging/imx-drm/ipu-v3/ipu-di.c   |  2 +-
 drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c |  3 ---
 drivers/staging/imx-drm/ipuv3-crtc.c  |  2 +-
 drivers/staging/imx-drm/parallel-display.c|  2 ++
 include/uapi/linux/videodev2.h|  1 +
 13 files changed, 83 insertions(+), 13 deletions(-)


-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
--
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 7/8] v4l2: add new V4L2_PIX_FMT_RGB666 pixel format.

2014-04-09 Thread Russell King
From: Denis Carikli de...@eukrea.com
To: linux-arm-ker...@lists.infradead.org

That new macro is needed by the imx_drm staging driver
  for supporting the QVGA display of the eukrea-cpuimx51 board.

Signed-off-by: Denis Carikli de...@eukrea.com
Acked-by: Mauro Carvalho Chehab m.che...@samsung.com
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
Acked-by: Philipp Zabel p.za...@pengutronix.de
Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk
---
 .../DocBook/media/v4l/pixfmt-packed-rgb.xml| 39 ++
 include/uapi/linux/videodev2.h |  1 +
 2 files changed, 40 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml 
b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
index 166c8d65e4f7..3207295c15fa 100644
--- a/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt-packed-rgb.xml
@@ -279,6 +279,45 @@ colorspace 
constantV4L2_COLORSPACE_SRGB/constant./para
entry/entry
entry/entry
  /row
+ row id=V4L2-PIX-FMT-RGB666
+   entryconstantV4L2_PIX_FMT_RGB666/constant/entry
+   entry'RGBH'/entry
+   entry/entry
+   entryrsubscript5/subscript/entry
+   entryrsubscript4/subscript/entry
+   entryrsubscript3/subscript/entry
+   entryrsubscript2/subscript/entry
+   entryrsubscript1/subscript/entry
+   entryrsubscript0/subscript/entry
+   entrygsubscript5/subscript/entry
+   entrygsubscript4/subscript/entry
+   entry/entry
+   entrygsubscript3/subscript/entry
+   entrygsubscript2/subscript/entry
+   entrygsubscript1/subscript/entry
+   entrygsubscript0/subscript/entry
+   entrybsubscript5/subscript/entry
+   entrybsubscript4/subscript/entry
+   entrybsubscript3/subscript/entry
+   entrybsubscript2/subscript/entry
+   entry/entry
+   entrybsubscript1/subscript/entry
+   entrybsubscript0/subscript/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+   entry/entry
+ /row
  row id=V4L2-PIX-FMT-BGR24
entryconstantV4L2_PIX_FMT_BGR24/constant/entry
entry'BGR3'/entry
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 6ae7bbe988cc..3051d67fcf5a 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.8.3.1

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


Linuxtv.org www is down

2014-04-09 Thread Antti Palosaari

Moikka!

http://linuxtv.org/ seems to be down currently. Server still answers to 
ping...


regards
Antti

--
http://palosaari.fi/
--
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: Linuxtv.org www is down

2014-04-09 Thread Antti Palosaari

On 09.04.2014 16:00, Antti Palosaari wrote:

Moikka!

http://linuxtv.org/ seems to be down currently. Server still answers to
ping...


wow, it is now alive again...

Antti
--
http://palosaari.fi/
--
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] staging: media: omap24xx: fix up some checkpatch.pl issues

2014-04-09 Thread Vitaly Osipov
tcm825x.c:

ERROR: Macros with complex values should be enclosed in parenthesis
WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then 
dev_info(dev, ... then pr_info(...  to printk(KERN_INFO ...

tcm825x.h:

ERROR: Macros with complex values should be enclosed in parenthesis

Signed-off-by: Vitaly Osipov vitaly.osi...@gmail.com
---
 drivers/staging/media/omap24xx/tcm825x.c |   40 +++---
 drivers/staging/media/omap24xx/tcm825x.h |4 +--
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/omap24xx/tcm825x.c 
b/drivers/staging/media/omap24xx/tcm825x.c
index f4dd32d..48186a4 100644
--- a/drivers/staging/media/omap24xx/tcm825x.c
+++ b/drivers/staging/media/omap24xx/tcm825x.c
@@ -89,10 +89,10 @@ static const struct tcm825x_reg rgb565  =   { 0x02, 
TCM825X_PICFMT };
 
 /* Our own specific controls */
 #define V4L2_CID_ALC   V4L2_CID_PRIVATE_BASE
-#define V4L2_CID_H_EDGE_EN V4L2_CID_PRIVATE_BASE + 1
-#define V4L2_CID_V_EDGE_EN V4L2_CID_PRIVATE_BASE + 2
-#define V4L2_CID_LENS  V4L2_CID_PRIVATE_BASE + 3
-#define V4L2_CID_MAX_EXPOSURE_TIME V4L2_CID_PRIVATE_BASE + 4
+#define V4L2_CID_H_EDGE_EN (V4L2_CID_PRIVATE_BASE + 1)
+#define V4L2_CID_V_EDGE_EN (V4L2_CID_PRIVATE_BASE + 2)
+#define V4L2_CID_LENS  (V4L2_CID_PRIVATE_BASE + 3)
+#define V4L2_CID_MAX_EXPOSURE_TIME (V4L2_CID_PRIVATE_BASE + 4)
 #define V4L2_CID_LAST_PRIV V4L2_CID_MAX_EXPOSURE_TIME
 
 /*  Video controls  */
@@ -350,8 +350,8 @@ static int tcm825x_write_default_regs(struct i2c_client 
*client,
int err;
const struct tcm825x_reg *next = reglist;
 
-   while (!((next-reg == TCM825X_REG_TERM)
- (next-val == TCM825X_VAL_TERM))) {
+   while (!((next-reg == TCM825X_REG_TERM) 
+(next-val == TCM825X_VAL_TERM))) {
err = tcm825x_write_reg(client, next-reg, next-val);
if (err) {
dev_err(client-dev, register writing failed\n);
@@ -472,7 +472,7 @@ static int tcm825x_configure(struct v4l2_int_device *s)
 }
 
 static int ioctl_queryctrl(struct v4l2_int_device *s,
-   struct v4l2_queryctrl *qc)
+  struct v4l2_queryctrl *qc)
 {
struct vcontrol *control;
 
@@ -487,7 +487,7 @@ static int ioctl_queryctrl(struct v4l2_int_device *s,
 }
 
 static int ioctl_g_ctrl(struct v4l2_int_device *s,
-struct v4l2_control *vc)
+   struct v4l2_control *vc)
 {
struct tcm825x_sensor *sensor = s-priv;
struct i2c_client *client = sensor-i2c_client;
@@ -532,7 +532,7 @@ static int ioctl_g_ctrl(struct v4l2_int_device *s,
 }
 
 static int ioctl_s_ctrl(struct v4l2_int_device *s,
-struct v4l2_control *vc)
+   struct v4l2_control *vc)
 {
struct tcm825x_sensor *sensor = s-priv;
struct i2c_client *client = sensor-i2c_client;
@@ -571,7 +571,7 @@ static int ioctl_s_ctrl(struct v4l2_int_device *s,
 }
 
 static int ioctl_enum_fmt_cap(struct v4l2_int_device *s,
-  struct v4l2_fmtdesc *fmt)
+ struct v4l2_fmtdesc *fmt)
 {
int index = fmt-index;
 
@@ -637,7 +637,7 @@ static int ioctl_try_fmt_cap(struct v4l2_int_device *s,
 }
 
 static int ioctl_s_fmt_cap(struct v4l2_int_device *s,
-   struct v4l2_format *f)
+  struct v4l2_format *f)
 {
struct tcm825x_sensor *sensor = s-priv;
struct v4l2_pix_format *pix = f-fmt.pix;
@@ -655,7 +655,7 @@ static int ioctl_s_fmt_cap(struct v4l2_int_device *s,
 }
 
 static int ioctl_g_fmt_cap(struct v4l2_int_device *s,
-   struct v4l2_format *f)
+  struct v4l2_format *f)
 {
struct tcm825x_sensor *sensor = s-priv;
 
@@ -665,7 +665,7 @@ static int ioctl_g_fmt_cap(struct v4l2_int_device *s,
 }
 
 static int ioctl_g_parm(struct v4l2_int_device *s,
-struct v4l2_streamparm *a)
+   struct v4l2_streamparm *a)
 {
struct tcm825x_sensor *sensor = s-priv;
struct v4l2_captureparm *cparm = a-parm.capture;
@@ -683,7 +683,7 @@ static int ioctl_g_parm(struct v4l2_int_device *s,
 }
 
 static int ioctl_s_parm(struct v4l2_int_device *s,
-struct v4l2_streamparm *a)
+   struct v4l2_streamparm *a)
 {
struct tcm825x_sensor *sensor = s-priv;
struct v4l2_fract *timeperframe = a-parm.capture.timeperframe;
@@ -693,8 +693,8 @@ static int ioctl_s_parm(struct v4l2_int_device *s,
if (a-type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
 
-   if ((timeperframe-numerator == 0)
-   || 

[PATCH 2/2] [RFC] reservation: add suppport for read-only access using rcu

2014-04-09 Thread Maarten Lankhorst
This adds 3 more functions to deal with rcu.

reservation_object_wait_timeout_rcu() will wait on all fences of the
reservation_object, without obtaining the ww_mutex.

reservation_object_test_signaled_rcu() will test if all fences of the
reservation_object are signaled without using the ww_mutex.

reservation_object_get_excl() is added because touching the fence_excl
member directly will trigger a sparse warning.

Signed-off-by: Maarten Lankhorst maarten.lankho...@canonical.com
---
 drivers/base/dma-buf.c  |   46 +++--
 drivers/base/reservation.c  |  147 +--
 include/linux/fence.h   |   22 ++
 include/linux/reservation.h |   40 
 4 files changed, 224 insertions(+), 31 deletions(-)

diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index d89a98d2c37b..fc2d7546b8b0 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -151,14 +151,22 @@ static unsigned int dma_buf_poll(struct file *file, 
poll_table *poll)
if (!events)
return 0;
 
-   ww_mutex_lock(resv-lock, NULL);
+   rcu_read_lock();
 
-   fobj = resv-fence;
-   if (!fobj)
-   goto out;
+   fobj = rcu_dereference(resv-fence);
+   if (fobj) {
+   shared_count = ACCESS_ONCE(fobj-shared_count);
+   smp_mb(); /* shared_count needs transitivity wrt fence_excl */
+   } else
+   shared_count = 0;
+   fence_excl = rcu_dereference(resv-fence_excl);
 
-   shared_count = fobj-shared_count;
-   fence_excl = resv-fence_excl;
+   /*
+* This would have needed a smp_read_barrier_depends()
+* because shared_count needs to be read before shared[i], but
+* spin_lock_irq and spin_unlock_irq provide even stronger
+* guarantees.
+*/
 
if (fence_excl  (!(events  POLLOUT) || shared_count == 0)) {
struct dma_buf_poll_cb_t *dcb = dmabuf-cb_excl;
@@ -176,14 +184,20 @@ static unsigned int dma_buf_poll(struct file *file, 
poll_table *poll)
spin_unlock_irq(dmabuf-poll.lock);
 
if (events  pevents) {
-   if (!fence_add_callback(fence_excl, dcb-cb,
+   if (!fence_get_rcu(fence_excl)) {
+   /* force a recheck */
+   events = ~pevents;
+   dma_buf_poll_cb(NULL, dcb-cb);
+   } else if (!fence_add_callback(fence_excl, dcb-cb,
   dma_buf_poll_cb)) {
events = ~pevents;
+   fence_put(fence_excl);
} else {
/*
 * No callback queued, wake up any additional
 * waiters.
 */
+   fence_put(fence_excl);
dma_buf_poll_cb(NULL, dcb-cb);
}
}
@@ -205,13 +219,25 @@ static unsigned int dma_buf_poll(struct file *file, 
poll_table *poll)
goto out;
 
for (i = 0; i  shared_count; ++i) {
-   struct fence *fence = fobj-shared[i];
-
+   struct fence *fence = fence_get_rcu(fobj-shared[i]);
+   if (!fence) {
+   /*
+* fence refcount dropped to zero, this means
+* that fobj has been freed
+*
+* call dma_buf_poll_cb and force a recheck!
+*/
+   events = ~POLLOUT;
+   dma_buf_poll_cb(NULL, dcb-cb);
+   break;
+   }
if (!fence_add_callback(fence, dcb-cb,
dma_buf_poll_cb)) {
+   fence_put(fence);
events = ~POLLOUT;
break;
}
+   fence_put(fence);
}
 
/* No callback queued, wake up any additional waiters. */
@@ -220,7 +246,7 @@ static unsigned int dma_buf_poll(struct file *file, 
poll_table *poll)
}
 
 out:
-   ww_mutex_unlock(resv-lock);
+   rcu_read_unlock();
return events;
 }
 
diff --git a/drivers/base/reservation.c b/drivers/base/reservation.c
index b82a5b630a8e..4cdce63140b8 100644
--- a/drivers/base/reservation.c
+++ b/drivers/base/reservation.c
@@ -87,9 +87,13 @@ reservation_object_add_shared_inplace(struct 
reservation_object *obj,
struct fence *old_fence = fobj-shared[i];
 
fence_get(fence);
+   /* for 

[PATCH 0/2] Updates to fence api

2014-04-09 Thread Maarten Lankhorst
The following series implements small updates to the fence api.
I've found them useful when implementing the fence API in ttm and i915.

The last patch enables RCU on top of the api. I've found this less
useful, but it was the condition on which Thomas Hellstrom was ok
with converting TTM to fence, so I had to keep it in.

If nobody objects I'll probably merge that patch through drm, because
some care is needed in ttm before it can flip the switch on rcu.

---

Maarten Lankhorst (2):
  reservation: update api and add some helpers
  [RFC] reservation: add suppport for read-only access using rcu

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


[RFC PATCH 1/2] drivers/base: add new devres_update() interface to devres_*

2014-04-09 Thread Shuah Khan
Media devices often have hardware resources that are shared
across several functions. For instance, TV tuner cards often
have MUXes, converters, radios, tuners, etc. that are shared
across various functions. However, v4l2, alsa, DVB, usbfs, and
all other drivers have no knowledge of what resources are
shared. For example, users can't access DVB and alsa at the same
time, or the DVB and V4L analog API at the same time, since many
only have one converter that can be in either analog or digital
mode. Accessing and/or changing mode of a converter while it is
in use by another function results in video stream error.

A shared devres that can be locked and unlocked by various drivers
that control media functions on a single media device is needed to
address the above problems.

A token devres that can be looked up by a token for locking, try
locking, unlocking will help avoid adding data structure
dependencies between various media drivers. This token is a unique
string that can be constructed from a common data structure such as
struct device, bus_name, and hardware address.

A new devres_* interface to update the status of this token resource
to busy when locked and free when unlocked is necessary to implement
this new managed resource.

devres_update() searches for the resource that matches supplied match
criteria similar to devres_find(). When a match is found, it calls
the update function caller passed in.

Signed-off-by: Shuah Khan shuah...@samsung.com
---
 drivers/base/devres.c  |   36 
 include/linux/device.h |4 
 2 files changed, 40 insertions(+)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index db4e264..8620600 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -272,6 +272,42 @@ void * devres_find(struct device *dev, dr_release_t 
release,
 EXPORT_SYMBOL_GPL(devres_find);
 
 /**
+ * devres_update - Find device resource and call update function
+ * @dev: Device to lookup resource from
+ * @release: Look for resources associated with this release function
+ * @match: Match function - must be specified
+ * @match_data: Data for the match function
+ * @update: Update function - must be specified
+ *
+ * Find the latest devres of @dev which is associated with @release
+ * and for which @match returns 1. If match is found, update will be
+ * called. This is intended for changes to status type data in a devres
+ *
+ * RETURNS:
+ * Pointer to found and updated devres, NULL if not found.
+ */
+void *devres_update(struct device *dev, dr_release_t release,
+  dr_match_t match, void *match_data, dr_update_t update)
+{
+   struct devres *dr;
+   unsigned long flags;
+
+   if (!match || !update)
+   return NULL;
+
+   spin_lock_irqsave(dev-devres_lock, flags);
+   dr = find_dr(dev, release, match, match_data);
+   if (dr)
+   update(dev, dr-data);
+   spin_unlock_irqrestore(dev-devres_lock, flags);
+
+   if (dr)
+   return dr-data;
+   return NULL;
+}
+EXPORT_SYMBOL_GPL(devres_update);
+
+/**
  * devres_get - Find devres, if non-existent, add one atomically
  * @dev: Device to lookup or add devres for
  * @new_res: Pointer to new initialized devres to add if not found
diff --git a/include/linux/device.h b/include/linux/device.h
index 233bbbe..39749df 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -576,6 +576,7 @@ extern int device_schedule_callback_owner(struct device 
*dev,
 /* device resource management */
 typedef void (*dr_release_t)(struct device *dev, void *res);
 typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
+typedef void (*dr_update_t)(struct device *dev, void *data);
 
 #ifdef CONFIG_DEBUG_DEVRES
 extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
@@ -593,6 +594,9 @@ extern void devres_free(void *res);
 extern void devres_add(struct device *dev, void *res);
 extern void *devres_find(struct device *dev, dr_release_t release,
 dr_match_t match, void *match_data);
+extern void *devres_update(struct device *dev, dr_release_t release,
+   dr_match_t match, void *match_data,
+   dr_update_t update);
 extern void *devres_get(struct device *dev, void *new_res,
dr_match_t match, void *match_data);
 extern void *devres_remove(struct device *dev, dr_release_t release,
-- 
1.7.10.4

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


[RFC PATCH 2/2] drivers/base: add managed token devres interfaces

2014-04-09 Thread Shuah Khan
Media devices often have hardware resources that are shared
across several functions. For instance, TV tuner cards often
have MUXes, converters, radios, tuners, etc. that are shared
across various functions. However, v4l2, alsa, DVB, usbfs, and
all other drivers have no knowledge of what resources are
shared. For example, users can't access DVB and alsa at the same
time, or the DVB and V4L analog API at the same time, since many
only have one converter that can be in either analog or digital
mode. Accessing and/or changing mode of a converter while it is
in use by another function results in video stream error.

A shared devres that can be locked and unlocked by various drivers
that control media functions on a single media device is needed to
address the above problems.

A token devres that can be looked up by a token for locking, try
locking, unlocking will help avoid adding data structure
dependencies between various media drivers. This token is a unique
string that can be constructed from a common data structure such as
struct device, bus_name, and hardware address.

The devm_token_* interfaces manage access to token resource.

Interfaces:
devm_token_create()
devm_token_destroy()
devm_token_lock()
devm_token_unlock()
Usage:
Create token:
Call devm_token_create() with a token id which is a unique
string.
Lock token: Call devm_token_lock() to lock or try lock a token.
Unlock token: Call devm_token_unlock().
Destroy token: Call devm_token_destroy() to delete the token.

Signed-off-by: Shuah Khan shuah...@samsung.com
---
 drivers/base/Makefile|2 +-
 drivers/base/token_devres.c  |  204 ++
 include/linux/token_devres.h |   19 
 3 files changed, 224 insertions(+), 1 deletion(-)
 create mode 100644 drivers/base/token_devres.c
 create mode 100644 include/linux/token_devres.h

diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 04b314e..924665b 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -4,7 +4,7 @@ obj-y   := component.o core.o bus.o dd.o 
syscore.o \
   driver.o class.o platform.o \
   cpu.o firmware.o init.o map.o devres.o \
   attribute_container.o transport_class.o \
-  topology.o container.o
+  topology.o container.o token_devres.o
 obj-$(CONFIG_DEVTMPFS) += devtmpfs.o
 obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
 obj-y  += power/
diff --git a/drivers/base/token_devres.c b/drivers/base/token_devres.c
new file mode 100644
index 000..e7436c5
--- /dev/null
+++ b/drivers/base/token_devres.c
@@ -0,0 +1,204 @@
+/*
+ * drivers/base/token_devres.c - managed token resource
+ *
+ * Copyright (c) 2014 Shuah Khan shuah...@samsung.com
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * This file is released under the GPLv2.
+ */
+/*
+ * Media devices often have hardware resources that are shared
+ * across several functions. For instance, TV tuner cards often
+ * have MUXes, converters, radios, tuners, etc. that are shared
+ * across various functions. However, v4l2, alsa, DVB, usbfs, and
+ * all other drivers have no knowledge of what resources are
+ * shared. For example, users can't access DVB and alsa at the same
+ * time, or the DVB and V4L analog API at the same time, since many
+ * only have one converter that can be in either analog or digital
+ * mode. Accessing and/or changing mode of a converter while it is
+ * in use by another function results in video stream error.
+ *
+ * A shared devres that can be locked and unlocked by various drivers
+ * that control media functions on a single media device is needed to
+ * address the above problems.
+ *
+ * A token devres that can be looked up by a token for locking, try
+ * locking, unlocking will help avoid adding data structure
+ * dependencies between various media drivers. This token is a unique
+ * string that can be constructed from a common data structure such as
+ * struct device, bus_name, and hardware address.
+ *
+ * The devm_token_* interfaces manage access to token resource.
+ *
+ * Interfaces:
+ * devm_token_create()
+ * devm_token_destroy()
+ * devm_token_lock()
+ * devm_token_unlock()
+ * Usage:
+ * Create token:
+ * Call devm_token_create() with a token id which is
+ * a unique string.
+ * Lock token:
+ * Call devm_token_lock() to lock or try lock a token.
+ * Unlock token:
+ * Call devm_token_unlock().
+ * Destroy token:
+ * Call devm_token_destroy() to delete the token.
+ *
+*/
+#include linux/device.h
+#include linux/token_devres.h
+
+#define TOKEN_DEVRES_FREE  0
+#define TOKEN_DEVRES_BUSY  1
+
+struct token_devres {
+   int status;
+   charid[];
+};
+
+struct tkn_match {
+   int status;
+   const   char *id;
+};
+

[RFC PATCH 0/2] managed token devres interfaces

2014-04-09 Thread Shuah Khan
Media devices often have hardware resources that are shared
across several functions. For instance, TV tuner cards often
have MUXes, converters, radios, tuners, etc. that are shared
across various functions. However, v4l2, alsa, DVB, usbfs, and
all other drivers have no knowledge of what resources are
shared. For example, users can't access DVB and alsa at the same
time, or the DVB and V4L analog API at the same time, since many
only have one converter that can be in either analog or digital
mode. Accessing and/or changing mode of a converter while it is
in use by another function results in video stream error.

A shared devres that can be locked and unlocked by various drivers
that control media functions on a single media device is needed to
address the above problems.

A token devres that can be looked up by a token for locking, try
locking, unlocking will help avoid adding data structure
dependencies between various media drivers. This token is a unique
string that can be constructed from a common data structure such as
struct device, bus_name, and hardware address.

The devm_token_* interfaces manage access to token resource.

Interfaces:
devm_token_create()
devm_token_destroy()
devm_token_lock()
devm_token_unlock()
Usage:
Create token:
Call devm_token_create() with a token id which is a unique
string.
Lock token: Call devm_token_lock() to lock or try lock a token.
Unlock token: Call devm_token_unlock().
Destroy token: Call devm_token_destroy() to delete the token.

A new devres_* interface to update the status of this token resource
to busy when locked and free when unlocked is necessary to implement
this new managed resource.

devres_update() searches for the resource that matches supplied match
criteria similar to devres_find(). When a match is found, it calls
the update function caller passed in.

This patch set adds a new devres_update) interface and token devres
interfaces.

Test Cases for token devres interfaces: (passed)
 - Create, lock, unlock, and destroy sequence.
 - Try lock while it is locked. Returns -EBUSY as expected.
 - Try lock after destroy. Returns -ENODEV as expected.
 - Unlock while it is unlocked. Returns 0 as expected. This is a no-op. 
 - Try unlock after destroy. Returns -ENODEV as expected.

Special notes for Mauro Chehab:
 - Please evaluate if these token devres interfaces cover all media driver
   use-cases. If not what is needed to cover them.
 - For use-case testing, I generated a string from em28xx device, as this
   is common for all em28xx extensions: (hope this holds true when em28xx
   uses snd-usb-audio
 - Construct string with (dev is struct em28xx *dev)
format: tuner:%s-%s-%d
with the following:
dev_name(dev-udev-dev)
dev-udev-bus-bus_name
dev-tuner_addr
 - I added test code to em28xx_card_setup() to test the interfaces:
   example token from this test code generated with the format above:

usb 8-1: devm_token_create(): created token: tuner:8-1-:00:10.1-0

Shuah Khan (2):
  drivers/base: add new devres_update() interface to devres_*
  drivers/base: add managed token devres interfaces

 drivers/base/Makefile|2 +-
 drivers/base/devres.c|   36 
 drivers/base/token_devres.c  |  204 ++
 include/linux/device.h   |4 +
 include/linux/token_devres.h |   19 
 5 files changed, 264 insertions(+), 1 deletion(-)
 create mode 100644 drivers/base/token_devres.c
 create mode 100644 include/linux/token_devres.h

-- 
1.7.10.4

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


[PATCH 1/2] reservation: update api and add some helpers

2014-04-09 Thread Maarten Lankhorst
Move the list of shared fences to a struct, and return it in
reservation_object_get_list().

Add reservation_object_reserve_shared(), which reserves space
in the reservation_object for 1 more shared fence.

reservation_object_add_shared_fence() and
reservation_object_add_excl_fence() are used to assign a new
fence to a reservation_object pointer, to complete a reservation.

Signed-off-by: Maarten Lankhorst maarten.lankho...@canonical.com
---
 drivers/base/dma-buf.c  |   35 +++---
 drivers/base/fence.c|4 +
 drivers/base/reservation.c  |  154 +++
 include/linux/fence.h   |6 ++
 include/linux/reservation.h |   48 +++--
 kernel/sched/core.c |1 
 6 files changed, 228 insertions(+), 20 deletions(-)

diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index 96338bf7f457..d89a98d2c37b 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -134,7 +134,10 @@ static unsigned int dma_buf_poll(struct file *file, 
poll_table *poll)
 {
struct dma_buf *dmabuf;
struct reservation_object *resv;
+   struct reservation_object_list *fobj;
+   struct fence *fence_excl;
unsigned long events;
+   unsigned shared_count;
 
dmabuf = file-private_data;
if (!dmabuf || !dmabuf-resv)
@@ -150,12 +153,18 @@ static unsigned int dma_buf_poll(struct file *file, 
poll_table *poll)
 
ww_mutex_lock(resv-lock, NULL);
 
-   if (resv-fence_excl  (!(events  POLLOUT) ||
-resv-fence_shared_count == 0)) {
+   fobj = resv-fence;
+   if (!fobj)
+   goto out;
+
+   shared_count = fobj-shared_count;
+   fence_excl = resv-fence_excl;
+
+   if (fence_excl  (!(events  POLLOUT) || shared_count == 0)) {
struct dma_buf_poll_cb_t *dcb = dmabuf-cb_excl;
unsigned long pevents = POLLIN;
 
-   if (resv-fence_shared_count == 0)
+   if (shared_count == 0)
pevents |= POLLOUT;
 
spin_lock_irq(dmabuf-poll.lock);
@@ -167,19 +176,20 @@ static unsigned int dma_buf_poll(struct file *file, 
poll_table *poll)
spin_unlock_irq(dmabuf-poll.lock);
 
if (events  pevents) {
-   if (!fence_add_callback(resv-fence_excl,
-   dcb-cb, dma_buf_poll_cb))
+   if (!fence_add_callback(fence_excl, dcb-cb,
+  dma_buf_poll_cb)) {
events = ~pevents;
-   else
+   } else {
/*
 * No callback queued, wake up any additional
 * waiters.
 */
dma_buf_poll_cb(NULL, dcb-cb);
+   }
}
}
 
-   if ((events  POLLOUT)  resv-fence_shared_count  0) {
+   if ((events  POLLOUT)  shared_count  0) {
struct dma_buf_poll_cb_t *dcb = dmabuf-cb_shared;
int i;
 
@@ -194,15 +204,18 @@ static unsigned int dma_buf_poll(struct file *file, 
poll_table *poll)
if (!(events  POLLOUT))
goto out;
 
-   for (i = 0; i  resv-fence_shared_count; ++i)
-   if (!fence_add_callback(resv-fence_shared[i],
-   dcb-cb, dma_buf_poll_cb)) {
+   for (i = 0; i  shared_count; ++i) {
+   struct fence *fence = fobj-shared[i];
+
+   if (!fence_add_callback(fence, dcb-cb,
+   dma_buf_poll_cb)) {
events = ~POLLOUT;
break;
}
+   }
 
/* No callback queued, wake up any additional waiters. */
-   if (i == resv-fence_shared_count)
+   if (i == shared_count)
dma_buf_poll_cb(NULL, dcb-cb);
}
 
diff --git a/drivers/base/fence.c b/drivers/base/fence.c
index 8fff13fb86cf..f780f9b3d418 100644
--- a/drivers/base/fence.c
+++ b/drivers/base/fence.c
@@ -170,7 +170,7 @@ void release_fence(struct kref *kref)
if (fence-ops-release)
fence-ops-release(fence);
else
-   kfree(fence);
+   free_fence(fence);
 }
 EXPORT_SYMBOL(release_fence);
 
@@ -448,7 +448,7 @@ static void seqno_release(struct fence *fence)
if (f-ops-release)
f-ops-release(fence);
else
-   kfree(f);
+   free_fence(fence);
 }
 
 static long seqno_wait(struct fence *fence, bool intr, signed long timeout)
diff --git a/drivers/base/reservation.c b/drivers/base/reservation.c
index a73fbf3b8e56..b82a5b630a8e 100644
--- 

[PATCH] rtl28xxu: do not hard depend on staging SDR module

2014-04-09 Thread Antti Palosaari
RTL2832 SDR extension module is currently on staging. SDR module
headers were included from staging causing direct dependency staging
directory. As a solution, add needed headers to main driver.
Motivation of that change comes from Luis / driver backports project.

Another issues was a little too heavy looking error log DVB: Unable
to find symbol rtl2832_sdr_attach() when staging module was disabled.
Get rid of it too by introducing own version of dvb_attach() macro
without the error text.

Reported-by: Luis R. Rodriguez mcg...@do-not-panic.com
Cc: backpo...@vger.kernel.org
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/Makefile   |  1 -
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 48 +
 2 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/Makefile 
b/drivers/media/usb/dvb-usb-v2/Makefile
index 7407b83..bc38f03 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -41,4 +41,3 @@ ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
 ccflags-y += -I$(srctree)/drivers/media/tuners
 ccflags-y += -I$(srctree)/drivers/media/common
-ccflags-y += -I$(srctree)/drivers/staging/media/rtl2832u_sdr
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index c83c16c..f58a952 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -24,7 +24,6 @@
 
 #include rtl2830.h
 #include rtl2832.h
-#include rtl2832_sdr.h
 
 #include qt1010.h
 #include mt2060.h
@@ -36,6 +35,45 @@
 #include tua9001.h
 #include r820t.h
 
+/*
+ * RTL2832_SDR module is in staging. That logic is added in order to avoid any
+ * hard dependency to drivers/staging/ directory as we want compile mainline
+ * driver even whole staging directory is missing.
+ */
+#include media/v4l2-subdev.h
+
+#ifdef CONFIG_MEDIA_ATTACH
+#define dvb_attach_sdr(FUNCTION, ARGS...) ({ \
+   void *__r = NULL; \
+   typeof(FUNCTION) __a = symbol_request(FUNCTION); \
+   if (__a) { \
+   __r = (void *) __a(ARGS); \
+   if (__r == NULL) \
+   symbol_put(FUNCTION); \
+   } \
+   __r; \
+})
+
+#else
+#define dvb_attach_sdr(FUNCTION, ARGS...) ({ \
+   FUNCTION(ARGS); \
+})
+
+#endif
+
+#if IS_ENABLED(CONFIG_DVB_RTL2832_SDR)
+extern struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
+   struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
+   struct v4l2_subdev *sd);
+#else
+static inline struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
+   struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
+   struct v4l2_subdev *sd)
+{
+   return NULL;
+}
+#endif
+
 static int rtl28xxu_disable_rc;
 module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644);
 MODULE_PARM_DESC(disable_rc, disable RTL2832U remote controller);
@@ -908,7 +946,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_fc0012_config, NULL);
break;
case TUNER_RTL2832_FC0013:
@@ -920,7 +958,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_fc0013_config, NULL);
break;
case TUNER_RTL2832_E4000: {
@@ -951,7 +989,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
i2c_set_adapdata(i2c_adap_internal, d);
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0],
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0],
i2c_adap_internal,
rtl28xxu_rtl2832_e4000_config, sd);
}
@@ -982,7 +1020,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_r820t_config, NULL);
break;
case TUNER_RTL2832_R828D:
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to 

Re: [PATCH] staging: media: omap24xx: fix up some checkpatch.pl issues

2014-04-09 Thread Greg Kroah-Hartman
On Wed, Apr 09, 2014 at 11:25:18PM +1000, Vitaly Osipov wrote:
 Fixes the following issues:
 
 tcm825x.c:
 
 ERROR: Macros with complex values should be enclosed in parenthesis
 WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then 
 dev_info(dev, ... then pr_info(...  to printk(KERN_INFO ...
 
 tcm825x.h:
 
 ERROR: Macros with complex values should be enclosed in parenthesis


Please only do one type of thing per patch.  So this should be a series
of 2 patches, one for the macro error, and one for the printk fixes.

Can you please redo these and resend them?

thanks,

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


Re: linux-next: Tree for Apr 9 (media/i2c/s5c73m3)

2014-04-09 Thread Sylwester Nawrocki
Hi,

On 09/04/14 18:01, Randy Dunlap wrote:
 On 04/09/2014 12:22 AM, Stephen Rothwell wrote:
  Hi all,
  
  Please do not add material intended for v3.16 to your linux-next included
  branches until after v3.15-rc1 is released.
  
  This tree still fails (more than usual) the powerpc allyesconfig build.
  
  Changes since 20140408:
  
 on i386:
 CONFIG_OF is not enabled.
 
 drivers/media/i2c/s5c73m3/s5c73m3-core.c: In function 
 's5c73m3_get_platform_data':
 drivers/media/i2c/s5c73m3/s5c73m3-core.c:1619:2: error: implicit declaration 
 of function 'v4l2_of_get_next_endpoint' 
 [-Werror=implicit-function-declaration]
 drivers/media/i2c/s5c73m3/s5c73m3-core.c:1619:10: warning: assignment makes 
 pointer from integer without a cast [enabled by default]

I have already prepared a patch for this issue:
https://patchwork.linuxtv.org/patch/23465

--
Thanks,
Sylwester
--
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: [REVIEW PATCH 10/11] vb2: set v4l2_buffer.bytesused to 0 for mp buffers

2014-04-09 Thread Sakari Ailus
Hi Hans,

Thanks for the set.

On Mon, Mar 10, 2014 at 10:20:57PM +0100, Hans Verkuil wrote:
 From: Hans Verkuil hans.verk...@cisco.com
 
 The bytesused field of struct v4l2_buffer is not used for multiplanar
 formats, so just zero it to prevent it from having some random value.
 
 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
  drivers/media/v4l2-core/videobuf2-core.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index f68a60f..54a4150 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -583,6 +583,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
 struct v4l2_buffer *b)
* for it. The caller has already verified memory and size.
*/
   b-length = vb-num_planes;
 + b-bytesused = 0;

I wonder if I'm missing something, but doesn't the value of the field come
from the v4l2_buf field of the vb2_buffer which is allocated using kzalloc()
in __vb2_queue_alloc(), and never changed afterwards?

   memcpy(b-m.planes, vb-v4l2_planes,
   b-length * sizeof(struct v4l2_plane));
   } else {

-- 
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: vb2: various small fixes/improvements

2014-04-09 Thread Sakari Ailus
On Mon, Mar 10, 2014 at 10:20:47PM +0100, Hans Verkuil wrote:
 This patch series contains a list of various vb2 fixes and improvements.
 
 These patches were originally part of this RFC patch series:
 
 http://www.spinics.net/lists/linux-media/msg73391.html
 
 They are now rebased and reordered a bit. It's little stuff for the
 most part, although the first patch touches on more drivers since it
 changes the return type of stop_streaming to void. The return value was
 always ignored by vb2 and you really cannot do anything sensible with it.
 In general resource allocations can return an error, but freeing up resources
 should not. That should always succeed.

For patches 1--10, with Pawel's comments addressed:

Acked-by: Sakari Ailus sakari.ai...@linux.intel.com

-- 
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: [PATCH] rtl28xxu: do not hard depend on staging SDR module

2014-04-09 Thread Luis R. Rodriguez
On Wed, Apr 9, 2014 at 9:14 AM, Antti Palosaari cr...@iki.fi wrote:
 +extern struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
 +   struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
 +   struct v4l2_subdev *sd);


Thanks for the patch! Joe has been going on a crusade to remove
externs as they are not needed, if we can avoid adding new ones
that'll prevent another followp cleanup patch.

  Luis
--
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: [RFC PATCH 0/2] managed token devres interfaces

2014-04-09 Thread Greg KH
On Wed, Apr 09, 2014 at 09:21:06AM -0600, Shuah Khan wrote:
 Media devices often have hardware resources that are shared
 across several functions. For instance, TV tuner cards often
 have MUXes, converters, radios, tuners, etc. that are shared
 across various functions. However, v4l2, alsa, DVB, usbfs, and
 all other drivers have no knowledge of what resources are
 shared. For example, users can't access DVB and alsa at the same
 time, or the DVB and V4L analog API at the same time, since many
 only have one converter that can be in either analog or digital
 mode. Accessing and/or changing mode of a converter while it is
 in use by another function results in video stream error.
 
 A shared devres that can be locked and unlocked by various drivers
 that control media functions on a single media device is needed to
 address the above problems.
 
 A token devres that can be looked up by a token for locking, try
 locking, unlocking will help avoid adding data structure
 dependencies between various media drivers. This token is a unique
 string that can be constructed from a common data structure such as
 struct device, bus_name, and hardware address.
 
 The devm_token_* interfaces manage access to token resource.
 
 Interfaces:
 devm_token_create()
 devm_token_destroy()
 devm_token_lock()
 devm_token_unlock()
 Usage:
 Create token:
 Call devm_token_create() with a token id which is a unique
 string.
 Lock token: Call devm_token_lock() to lock or try lock a token.
 Unlock token: Call devm_token_unlock().
 Destroy token: Call devm_token_destroy() to delete the token.
 
 A new devres_* interface to update the status of this token resource
 to busy when locked and free when unlocked is necessary to implement
 this new managed resource.
 
 devres_update() searches for the resource that matches supplied match
 criteria similar to devres_find(). When a match is found, it calls
 the update function caller passed in.
 
 This patch set adds a new devres_update) interface and token devres
 interfaces.
 
 Test Cases for token devres interfaces: (passed)
  - Create, lock, unlock, and destroy sequence.
  - Try lock while it is locked. Returns -EBUSY as expected.
  - Try lock after destroy. Returns -ENODEV as expected.
  - Unlock while it is unlocked. Returns 0 as expected. This is a no-op. 
  - Try unlock after destroy. Returns -ENODEV as expected.

Any chance you can add these test cases as part of the kernel code so
it lives here for any future changes?

 Special notes for Mauro Chehab:
  - Please evaluate if these token devres interfaces cover all media driver
use-cases. If not what is needed to cover them.
  - For use-case testing, I generated a string from em28xx device, as this
is common for all em28xx extensions: (hope this holds true when em28xx
uses snd-usb-audio
  - Construct string with (dev is struct em28xx *dev)
   format: tuner:%s-%s-%d
   with the following:
   dev_name(dev-udev-dev)
 dev-udev-bus-bus_name
 dev-tuner_addr
  - I added test code to em28xx_card_setup() to test the interfaces:
example token from this test code generated with the format above:

What would the driver changes look like to take advantage of these new
functions?

thanks,

greg k-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 04/17] smiapp: Make PLL (quirk) flags a function

2014-04-09 Thread Sakari Ailus
This is more flexible. Quirk flags may be affected by configuration.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-core.c  | 4 ++--
 drivers/media/i2c/smiapp/smiapp-quirk.c | 7 ++-
 drivers/media/i2c/smiapp/smiapp-quirk.h | 2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 23f2c4d..02041cc 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2617,8 +2617,8 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
pll-bus_type = SMIAPP_PLL_BUS_TYPE_CSI2;
pll-csi2.lanes = sensor-platform_data-lanes;
pll-ext_clk_freq_hz = sensor-platform_data-ext_clk;
-   if (sensor-minfo.quirk)
-   pll-flags = sensor-minfo.quirk-pll_flags;
+   pll-flags = smiapp_call_quirk(sensor, pll_flags);
+
/* Profile 0 sensors have no separate OP clock branch. */
if (sensor-minfo.smiapp_profile == SMIAPP_PROFILE_0)
pll-flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS;
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.c 
b/drivers/media/i2c/smiapp/smiapp-quirk.c
index c7f5194..20e62c1 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.c
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.c
@@ -266,12 +266,17 @@ static int jt8ev1_post_streamoff(struct smiapp_sensor 
*sensor)
return smiapp_write_8(sensor, 0x3328, 0x80);
 }
 
+static unsigned long jt8ev1_pll_flags(struct smiapp_sensor *sensor)
+{
+   return SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE;
+}
+
 const struct smiapp_quirk smiapp_jt8ev1_quirk = {
.limits = jt8ev1_limits,
.post_poweron = jt8ev1_post_poweron,
.pre_streamon = jt8ev1_pre_streamon,
.post_streamoff = jt8ev1_post_streamoff,
-   .pll_flags = SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE,
+   .pll_flags = jt8ev1_pll_flags,
 };
 
 static int tcm8500md_limits(struct smiapp_sensor *sensor)
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.h 
b/drivers/media/i2c/smiapp/smiapp-quirk.h
index bc9d28c..a6b3183 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.h
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.h
@@ -41,9 +41,9 @@ struct smiapp_quirk {
int (*post_poweron)(struct smiapp_sensor *sensor);
int (*pre_streamon)(struct smiapp_sensor *sensor);
int (*post_streamoff)(struct smiapp_sensor *sensor);
+   unsigned long (*pll_flags)(struct smiapp_sensor *sensor);
const struct smia_reg *regs;
unsigned long flags;
-   unsigned long pll_flags;
 };
 
 #define SMIAPP_QUIRK_FLAG_8BIT_READ_ONLY   (1  0)
-- 
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 12/17] smiapp-pll: Add quirk for op clk divisor == bits per pixel / 2

2014-04-09 Thread Sakari Ailus
For some sensors in some configurations the effective value of op clk div is
bits per pixel divided by two. The output clock is correctly calculated
whereas some of the rest of the clock tree uses higher clocks than
calculated. This also limits the bpp to even values if the number of lanes
is four.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.c | 10 ++
 drivers/media/i2c/smiapp-pll.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index be94921..9d06a33 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -207,6 +207,8 @@ static int __smiapp_pll_calculate(struct device *dev,
div_u64(pll-pll_op_clk_freq_hz, pll-op_sys_clk_div);
 
pll-op_pix_clk_div = pll-bits_per_pixel;
+   if (pll-flags  SMIAPP_PLL_FLAG_OP_PIX_DIV_HALF)
+   pll-op_pix_clk_div /= 2;
dev_dbg(dev, op_pix_clk_div: %u\n, pll-op_pix_clk_div);
 
pll-op_pix_clk_freq_hz =
@@ -416,6 +418,14 @@ int smiapp_pll_calculate(struct device *dev,
return -EINVAL;
}
 
+   /*
+* Half op pix divisor will give us double the rate compared
+* to the regular case. Thus divide the desired pll op clock
+* frequency by two.
+*/
+   if (pll-flags  SMIAPP_PLL_FLAG_OP_PIX_DIV_HALF)
+   pll-pll_op_clk_freq_hz /= 2;
+
/* Figure out limits for pre-pll divider based on extclk */
dev_dbg(dev, min / max pre_pll_clk_div: %u / %u\n,
limits-min_pre_pll_clk_div, limits-max_pre_pll_clk_div);
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index a25f550..02d11db 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -36,6 +36,8 @@
 #define SMIAPP_PLL_FLAG_NO_OP_CLOCKS   (1  1)
 /* the pre-pll div may be odd */
 #define SMIAPP_PLL_FLAG_ALLOW_ODD_PRE_PLL_CLK_DIV  (1  2)
+/* op pix div value is half of the bits-per-pixel value */
+#define SMIAPP_PLL_FLAG_OP_PIX_DIV_HALF(1  3)
 
 struct smiapp_pll {
/* input values */
-- 
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 0/17] smiapp and smiapp-pll quirk improvements, fixes

2014-04-09 Thread Sakari Ailus
Hi folks,

This patchset contains PLL quirk improvements to take quirks in some
implementations into account, as well as make the quirk mechanisms more
flexible. The driver core is mostly unaffected by these changes.

The PLL tree calculation itself is concerned less with the factual
frequencies but focuses on producing multipliers and dividers that are valid
for the hardware. Quirk flags are primarily used to convert input and output
parameters.

The limit values are also made 64 bits; 64-bit values are needed in more
generic case when floating point numbers are converted to fixed point.

There are some miscellaneous fixes as well.

-- 
Kind regards,
Sakari

--
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 03/17] smiapp: Make PLL flags unsigned long

2014-04-09 Thread Sakari Ailus
No reason to keep this u8, really.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index a4a6498..5ce2b61 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -46,7 +46,7 @@ struct smiapp_pll {
uint8_t bus_width;
} parallel;
};
-   uint8_t flags;
+   unsigned long flags;
uint8_t binning_horizontal;
uint8_t binning_vertical;
uint8_t scale_m;
-- 
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 16/17] smiapp: Ignore write accesses to quirk registers

2014-04-09 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-regs.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c 
b/drivers/media/i2c/smiapp/smiapp-regs.c
index 4fac32c..e88a59a 100644
--- a/drivers/media/i2c/smiapp/smiapp-regs.c
+++ b/drivers/media/i2c/smiapp/smiapp-regs.c
@@ -221,6 +221,13 @@ int smiapp_write(struct smiapp_sensor *sensor, u32 reg, 
u32 val)
 len != SMIA_REG_32BIT) || flags)
return -EINVAL;
 
+   if (smiapp_quirk_reg(sensor, reg, val)) {
+   dev_dbg(client-dev,
+   ignoring write access to quirk reg 0x%4.4x\n,
+   (u16)reg);
+   return 0;
+   }
+
msg.addr = client-addr;
msg.flags = 0; /* Write */
msg.len = 2 + len;
-- 
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 17/17] smiapp: Add register diversion quirk

2014-04-09 Thread Sakari Ailus
Add a quirk for diverting registers for on some sensors, even the standard
registers are not where they can be expected to be found. Add a quirk to
to help using such sensors.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-quirk.c |  8 
 drivers/media/i2c/smiapp/smiapp-quirk.h |  4 
 drivers/media/i2c/smiapp/smiapp-regs.c  | 14 +++---
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.c 
b/drivers/media/i2c/smiapp/smiapp-quirk.c
index 580132d..9d86217 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.c
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.c
@@ -107,6 +107,14 @@ bool smiapp_quirk_reg(struct smiapp_sensor *sensor,
return false;
 }
 
+u32 smiapp_quirk_reg_divert(struct smiapp_sensor *sensor, u32 reg, u32 *val)
+{
+   if (sensor-minfo.quirk  sensor-minfo.quirk-reg_divert)
+   return sensor-minfo.quirk-reg_divert(sensor, reg, val);
+   else
+   return reg;
+}
+
 static int jt8ew9_limits(struct smiapp_sensor *sensor)
 {
if (sensor-minfo.revision_number_major  0x03)
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.h 
b/drivers/media/i2c/smiapp/smiapp-quirk.h
index 15ef0af6..295931c 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.h
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.h
@@ -35,6 +35,8 @@ struct smiapp_sensor;
  * @post_poweron: Called always after the sensor has been fully powered on.
  * @pre_streamon: Called just before streaming is enabled.
  * @post_streamon: Called right after stopping streaming.
+ * @reg_divert: reg is diverted to point to the location of the actual
+ * register. For sensors that loosely conform to SMIA.
  */
 struct smiapp_quirk {
int (*limits)(struct smiapp_sensor *sensor);
@@ -42,6 +44,7 @@ struct smiapp_quirk {
int (*pre_streamon)(struct smiapp_sensor *sensor);
int (*post_streamoff)(struct smiapp_sensor *sensor);
unsigned long (*pll_flags)(struct smiapp_sensor *sensor);
+   u32 (*reg_divert)(struct smiapp_sensor *sensor, u32 reg, u32 *val);
const struct smia_reg *regs;
unsigned long flags;
 };
@@ -57,6 +60,7 @@ void smiapp_replace_limit(struct smiapp_sensor *sensor,
  u32 limit, u64 val);
 bool smiapp_quirk_reg(struct smiapp_sensor *sensor,
  u32 reg, u32 *val);
+u32 smiapp_quirk_reg_divert(struct smiapp_sensor *sensor, u32 reg, u32 *val);
 
 #define SMIAPP_MK_QUIRK_REG(_reg, _val) \
{   \
diff --git a/drivers/media/i2c/smiapp/smiapp-regs.c 
b/drivers/media/i2c/smiapp/smiapp-regs.c
index e88a59a..57ebd51 100644
--- a/drivers/media/i2c/smiapp/smiapp-regs.c
+++ b/drivers/media/i2c/smiapp/smiapp-regs.c
@@ -165,7 +165,7 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 
reg, u32 *val,
 bool only8)
 {
struct i2c_client *client = v4l2_get_subdevdata(sensor-src-sd);
-   unsigned int len = (u8)(reg  16);
+   u8 len = reg  16;
int rval;
 
if (len != SMIA_REG_8BIT  len != SMIA_REG_16BIT
@@ -175,6 +175,9 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 
reg, u32 *val,
if (smiapp_quirk_reg(sensor, reg, val))
goto found_quirk;
 
+   reg = smiapp_quirk_reg_divert(sensor, reg, val);
+   len = reg  16;
+
if (len == SMIA_REG_8BIT  !only8)
rval = smiapp_read(sensor, (u16)reg, len, val);
else
@@ -213,8 +216,8 @@ int smiapp_write(struct smiapp_sensor *sensor, u32 reg, u32 
val)
unsigned char data[6];
unsigned int retries;
unsigned int flags = reg  24;
-   unsigned int len = (u8)(reg  16);
-   u16 offset = reg;
+   u8 len = reg  16;
+   u16 offset;
int r;
 
if ((len != SMIA_REG_8BIT  len != SMIA_REG_16BIT 
@@ -228,6 +231,11 @@ int smiapp_write(struct smiapp_sensor *sensor, u32 reg, 
u32 val)
return 0;
}
 
+   reg = smiapp_quirk_reg_divert(sensor, reg, val);
+   offset = reg;
+   flags = reg  24;
+   len = reg  16;
+
msg.addr = client-addr;
msg.flags = 0; /* Write */
msg.len = 2 + len;
-- 
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 15/17] smiapp-pll: Add quirk flag for sensors that effectively use double pix clks

2014-04-09 Thread Sakari Ailus
Some sensors have effectively the double pixel (and other clocks) compared
to calculations.

The frequency of the bus is also affected similarly so take this into
account when calculating pll_op_clock frequency.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.c | 10 ++
 drivers/media/i2c/smiapp-pll.h |  6 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index a83597e..8c48bdc 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -335,6 +335,10 @@ static int __smiapp_pll_calculate(struct device *dev,
pll-pixel_rate_csi =
pll-op_pix_clk_freq_hz * lane_op_clock_ratio;
pll-pixel_rate_pixel_array = pll-vt_pix_clk_freq_hz;
+   if (pll-flags  SMIAPP_PLL_FLAG_PIX_CLOCK_DOUBLE) {
+   pll-pixel_rate_csi *= 2;
+   pll-pixel_rate_pixel_array *= 2;
+   }
 
rval = bounds_check(dev, pll-pll_ip_clk_freq_hz,
limits-min_pll_ip_freq_hz,
@@ -426,6 +430,12 @@ int smiapp_pll_calculate(struct device *dev,
 */
if (pll-flags  SMIAPP_PLL_FLAG_OP_PIX_DIV_HALF)
pll-pll_op_clk_freq_hz /= 2;
+   /*
+* If it'll be multiplied by two in the end divide it now to
+* avoid achieving double the desired clock.
+*/
+   if (pll-flags  SMIAPP_PLL_FLAG_PIX_CLOCK_DOUBLE)
+   pll-pll_op_clk_freq_hz /= 2;
 
/* Figure out limits for pre-pll divider based on extclk */
dev_dbg(dev, min / max pre_pll_clk_div: %u / %u\n,
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index c6ad809..9eaac54 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -38,6 +38,12 @@
 #define SMIAPP_PLL_FLAG_ALLOW_ODD_PRE_PLL_CLK_DIV  (1  2)
 /* op pix div value is half of the bits-per-pixel value */
 #define SMIAPP_PLL_FLAG_OP_PIX_DIV_HALF(1  3)
+/*
+ * The effective vt and op pix clocks are twice as high as the
+ * calculated value. The limits are still against the regular limit
+ * values.
+ */
+#define SMIAPP_PLL_FLAG_PIX_CLOCK_DOUBLE   (1  4)
 
 struct smiapp_pll {
/* input values */
-- 
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 07/17] smiapp-pll: The clock tree values are unsigned --- fix debug prints

2014-04-09 Thread Sakari Ailus
These values are unsigned, so use %u instead of %d.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.c | 94 +-
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index ab5d9a3..d14af5c 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -65,26 +65,26 @@ static int bounds_check(struct device *dev, uint32_t val,
 
 static void print_pll(struct device *dev, struct smiapp_pll *pll)
 {
-   dev_dbg(dev, pre_pll_clk_div\t%d\n,  pll-pre_pll_clk_div);
-   dev_dbg(dev, pll_multiplier \t%d\n,  pll-pll_multiplier);
+   dev_dbg(dev, pre_pll_clk_div\t%u\n,  pll-pre_pll_clk_div);
+   dev_dbg(dev, pll_multiplier \t%u\n,  pll-pll_multiplier);
if (!(pll-flags  SMIAPP_PLL_FLAG_NO_OP_CLOCKS)) {
-   dev_dbg(dev, op_sys_clk_div \t%d\n, pll-op_sys_clk_div);
-   dev_dbg(dev, op_pix_clk_div \t%d\n, pll-op_pix_clk_div);
+   dev_dbg(dev, op_sys_clk_div \t%u\n, pll-op_sys_clk_div);
+   dev_dbg(dev, op_pix_clk_div \t%u\n, pll-op_pix_clk_div);
}
-   dev_dbg(dev, vt_sys_clk_div \t%d\n,  pll-vt_sys_clk_div);
-   dev_dbg(dev, vt_pix_clk_div \t%d\n,  pll-vt_pix_clk_div);
+   dev_dbg(dev, vt_sys_clk_div \t%u\n,  pll-vt_sys_clk_div);
+   dev_dbg(dev, vt_pix_clk_div \t%u\n,  pll-vt_pix_clk_div);
 
-   dev_dbg(dev, ext_clk_freq_hz \t%d\n, pll-ext_clk_freq_hz);
-   dev_dbg(dev, pll_ip_clk_freq_hz \t%d\n, pll-pll_ip_clk_freq_hz);
-   dev_dbg(dev, pll_op_clk_freq_hz \t%d\n, pll-pll_op_clk_freq_hz);
+   dev_dbg(dev, ext_clk_freq_hz \t%u\n, pll-ext_clk_freq_hz);
+   dev_dbg(dev, pll_ip_clk_freq_hz \t%u\n, pll-pll_ip_clk_freq_hz);
+   dev_dbg(dev, pll_op_clk_freq_hz \t%u\n, pll-pll_op_clk_freq_hz);
if (!(pll-flags  SMIAPP_PLL_FLAG_NO_OP_CLOCKS)) {
-   dev_dbg(dev, op_sys_clk_freq_hz \t%d\n,
+   dev_dbg(dev, op_sys_clk_freq_hz \t%u\n,
pll-op_sys_clk_freq_hz);
-   dev_dbg(dev, op_pix_clk_freq_hz \t%d\n,
+   dev_dbg(dev, op_pix_clk_freq_hz \t%u\n,
pll-op_pix_clk_freq_hz);
}
-   dev_dbg(dev, vt_sys_clk_freq_hz \t%d\n, pll-vt_sys_clk_freq_hz);
-   dev_dbg(dev, vt_pix_clk_freq_hz \t%d\n, pll-vt_pix_clk_freq_hz);
+   dev_dbg(dev, vt_sys_clk_freq_hz \t%u\n, pll-vt_sys_clk_freq_hz);
+   dev_dbg(dev, vt_pix_clk_freq_hz \t%u\n, pll-vt_pix_clk_freq_hz);
 }
 
 /*
@@ -123,11 +123,11 @@ static int __smiapp_pll_calculate(struct device *dev,
 * Get pre_pll_clk_div so that our pll_op_clk_freq_hz won't be
 * too high.
 */
-   dev_dbg(dev, pre_pll_clk_div %d\n, pll-pre_pll_clk_div);
+   dev_dbg(dev, pre_pll_clk_div %u\n, pll-pre_pll_clk_div);
 
/* Don't go above max pll multiplier. */
more_mul_max = limits-max_pll_multiplier / mul;
-   dev_dbg(dev, more_mul_max: max_pll_multiplier check: %d\n,
+   dev_dbg(dev, more_mul_max: max_pll_multiplier check: %u\n,
more_mul_max);
/* Don't go above max pll op frequency. */
more_mul_max =
@@ -135,30 +135,30 @@ static int __smiapp_pll_calculate(struct device *dev,
  more_mul_max,
  limits-max_pll_op_freq_hz
  / (pll-ext_clk_freq_hz / pll-pre_pll_clk_div * mul));
-   dev_dbg(dev, more_mul_max: max_pll_op_freq_hz check: %d\n,
+   dev_dbg(dev, more_mul_max: max_pll_op_freq_hz check: %u\n,
more_mul_max);
/* Don't go above the division capability of op sys clock divider. */
more_mul_max = min(more_mul_max,
   limits-op.max_sys_clk_div * pll-pre_pll_clk_div
   / div);
-   dev_dbg(dev, more_mul_max: max_op_sys_clk_div check: %d\n,
+   dev_dbg(dev, more_mul_max: max_op_sys_clk_div check: %u\n,
more_mul_max);
/* Ensure we won't go above min_pll_multiplier. */
more_mul_max = min(more_mul_max,
   DIV_ROUND_UP(limits-max_pll_multiplier, mul));
-   dev_dbg(dev, more_mul_max: min_pll_multiplier check: %d\n,
+   dev_dbg(dev, more_mul_max: min_pll_multiplier check: %u\n,
more_mul_max);
 
/* Ensure we won't go below min_pll_op_freq_hz. */
more_mul_min = DIV_ROUND_UP(limits-min_pll_op_freq_hz,
pll-ext_clk_freq_hz / pll-pre_pll_clk_div
* mul);
-   dev_dbg(dev, more_mul_min: min_pll_op_freq_hz check: %d\n,
+   dev_dbg(dev, more_mul_min: min_pll_op_freq_hz check: %u\n,
more_mul_min);
/* Ensure we won't go below min_pll_multiplier. */
more_mul_min = max(more_mul_min,
   DIV_ROUND_UP(limits-min_pll_multiplier, mul));
-   dev_dbg(dev, more_mul_min: 

[PATCH 06/17] smiapp-pll: Correct clock debug prints

2014-04-09 Thread Sakari Ailus
The PLL flags were not used correctly.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index 2335529..ab5d9a3 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -67,7 +67,7 @@ static void print_pll(struct device *dev, struct smiapp_pll 
*pll)
 {
dev_dbg(dev, pre_pll_clk_div\t%d\n,  pll-pre_pll_clk_div);
dev_dbg(dev, pll_multiplier \t%d\n,  pll-pll_multiplier);
-   if (pll-flags != SMIAPP_PLL_FLAG_NO_OP_CLOCKS) {
+   if (!(pll-flags  SMIAPP_PLL_FLAG_NO_OP_CLOCKS)) {
dev_dbg(dev, op_sys_clk_div \t%d\n, pll-op_sys_clk_div);
dev_dbg(dev, op_pix_clk_div \t%d\n, pll-op_pix_clk_div);
}
@@ -77,7 +77,7 @@ static void print_pll(struct device *dev, struct smiapp_pll 
*pll)
dev_dbg(dev, ext_clk_freq_hz \t%d\n, pll-ext_clk_freq_hz);
dev_dbg(dev, pll_ip_clk_freq_hz \t%d\n, pll-pll_ip_clk_freq_hz);
dev_dbg(dev, pll_op_clk_freq_hz \t%d\n, pll-pll_op_clk_freq_hz);
-   if (pll-flags  SMIAPP_PLL_FLAG_NO_OP_CLOCKS) {
+   if (!(pll-flags  SMIAPP_PLL_FLAG_NO_OP_CLOCKS)) {
dev_dbg(dev, op_sys_clk_freq_hz \t%d\n,
pll-op_sys_clk_freq_hz);
dev_dbg(dev, op_pix_clk_freq_hz \t%d\n,
-- 
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 14/17] smiapp: Use actual pixel rate calculated by the PLL calculator

2014-04-09 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 6d940f0..284df17 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -297,7 +297,7 @@ static int smiapp_pll_update(struct smiapp_sensor *sensor)
if (rval  0)
return rval;
 
-   sensor-pixel_rate_parray-cur.val64 = pll-vt_pix_clk_freq_hz;
+   sensor-pixel_rate_parray-cur.val64 = pll-pixel_rate_pixel_array;
sensor-pixel_rate_csi-cur.val64 = pll-pixel_rate_csi;
 
return 0;
@@ -865,7 +865,7 @@ static int smiapp_update_mode(struct smiapp_sensor *sensor)
dev_dbg(client-dev, hblank\t\t%d\n, sensor-hblank-val);
 
dev_dbg(client-dev, real timeperframe\t100/%d\n,
-   sensor-pll.vt_pix_clk_freq_hz /
+   sensor-pll.pixel_rate_pixel_array /
((sensor-pixel_array-crop[SMIAPP_PA_PAD_SRC].width
  + sensor-hblank-val) *
 (sensor-pixel_array-crop[SMIAPP_PA_PAD_SRC].height
-- 
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 11/17] smiapp: Remove validation of op_pix_clk_div

2014-04-09 Thread Sakari Ailus
op_pix_clk_div is directly assigned and not calculated. There's no need to
verify it.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index 93a8214..be94921 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -354,11 +354,6 @@ static int __smiapp_pll_calculate(struct device *dev,
op_sys_clk_div);
if (!rval)
rval = bounds_check(
-   dev, pll-op_pix_clk_div,
-   limits-op.min_pix_clk_div, limits-op.max_pix_clk_div,
-   op_pix_clk_div);
-   if (!rval)
-   rval = bounds_check(
dev, pll-op_sys_clk_freq_hz,
limits-op.min_sys_clk_freq_hz,
limits-op.max_sys_clk_freq_hz,
-- 
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 02/17] smiapp: Make PLL flags separate from regular quirk flags

2014-04-09 Thread Sakari Ailus
It doesn't make sense to just copy the information to the PLL flags. Add a
new fields for the quirks to contain the PLL flags.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-core.c  | 5 ++---
 drivers/media/i2c/smiapp/smiapp-quirk.c | 2 +-
 drivers/media/i2c/smiapp/smiapp-quirk.h | 5 ++---
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 69c11ec..23f2c4d 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2617,12 +2617,11 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
pll-bus_type = SMIAPP_PLL_BUS_TYPE_CSI2;
pll-csi2.lanes = sensor-platform_data-lanes;
pll-ext_clk_freq_hz = sensor-platform_data-ext_clk;
+   if (sensor-minfo.quirk)
+   pll-flags = sensor-minfo.quirk-pll_flags;
/* Profile 0 sensors have no separate OP clock branch. */
if (sensor-minfo.smiapp_profile == SMIAPP_PROFILE_0)
pll-flags |= SMIAPP_PLL_FLAG_NO_OP_CLOCKS;
-   if (smiapp_needs_quirk(sensor,
-  SMIAPP_QUIRK_FLAG_OP_PIX_CLOCK_PER_LANE))
-   pll-flags |= SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE;
pll-scale_n = sensor-limits[SMIAPP_LIMIT_SCALER_N_MIN];
 
rval = smiapp_update_mode(sensor);
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.c 
b/drivers/media/i2c/smiapp/smiapp-quirk.c
index bb8c506..c7f5194 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.c
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.c
@@ -271,7 +271,7 @@ const struct smiapp_quirk smiapp_jt8ev1_quirk = {
.post_poweron = jt8ev1_post_poweron,
.pre_streamon = jt8ev1_pre_streamon,
.post_streamoff = jt8ev1_post_streamoff,
-   .flags = SMIAPP_QUIRK_FLAG_OP_PIX_CLOCK_PER_LANE,
+   .pll_flags = SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE,
 };
 
 static int tcm8500md_limits(struct smiapp_sensor *sensor)
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.h 
b/drivers/media/i2c/smiapp/smiapp-quirk.h
index 504a6d8..bc9d28c 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.h
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.h
@@ -43,11 +43,10 @@ struct smiapp_quirk {
int (*post_streamoff)(struct smiapp_sensor *sensor);
const struct smia_reg *regs;
unsigned long flags;
+   unsigned long pll_flags;
 };
 
-/* op pix clock is for all lanes in total normally */
-#define SMIAPP_QUIRK_FLAG_OP_PIX_CLOCK_PER_LANE(1  0)
-#define SMIAPP_QUIRK_FLAG_8BIT_READ_ONLY   (1  1)
+#define SMIAPP_QUIRK_FLAG_8BIT_READ_ONLY   (1  0)
 
 struct smiapp_reg_8 {
u16 reg;
-- 
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 05/17] smiapp: Use %u for printing u32 value

2014-04-09 Thread Sakari Ailus
Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 02041cc..3af8df8 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -606,7 +606,7 @@ static int smiapp_get_limits(struct smiapp_sensor *sensor, 
int const *limit,
if (rval)
return rval;
sensor-limits[limit[i]] = val;
-   dev_dbg(client-dev, 0x%8.8x \%s\ = %d, 0x%x\n,
+   dev_dbg(client-dev, 0x%8.8x \%s\ = %u, 0x%x\n,
smiapp_reg_limits[limit[i]].addr,
smiapp_reg_limits[limit[i]].what, val, val);
}
-- 
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 08/17] smiapp: Limits can be 64 bits

2014-04-09 Thread Sakari Ailus
Limits may exceed the value range of 32 bit unsigned integers. Thus use 64
bits instead.

Use typed min/max/clamp macros. Debug printing changes as well.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-core.c  | 30 --
 drivers/media/i2c/smiapp/smiapp-quirk.c |  4 ++--
 drivers/media/i2c/smiapp/smiapp-quirk.h |  2 +-
 drivers/media/i2c/smiapp/smiapp.h   |  2 +-
 4 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 3af8df8..6d940f0 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -502,7 +502,8 @@ static int smiapp_init_controls(struct smiapp_sensor 
*sensor)
V4L2_CID_ANALOGUE_GAIN,
sensor-limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MIN],
sensor-limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MAX],
-   max(sensor-limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_STEP], 1U),
+   max_t(uint32_t,
+ sensor-limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_STEP], 1U),
sensor-limits[SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MIN]);
 
/* Exposure limits will be updated soon, use just something here. */
@@ -679,7 +680,7 @@ static int smiapp_get_limits_binning(struct smiapp_sensor 
*sensor)
 
for (i = 0; i  ARRAY_SIZE(limits); i++) {
dev_dbg(client-dev,
-   replace limit 0x%8.8x \%s\ = %d, 0x%x\n,
+   replace limit 0x%8.8x \%s\ = %llu, 0x%llx\n,
smiapp_reg_limits[limits[i]].addr,
smiapp_reg_limits[limits[i]].what,
sensor-limits[limits_replace[i]],
@@ -1689,13 +1690,13 @@ static int smiapp_set_format(struct v4l2_subdev *subdev,
fmt-format.height = ~1;
 
fmt-format.width =
-   clamp(fmt-format.width,
- sensor-limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE],
- sensor-limits[SMIAPP_LIMIT_MAX_X_OUTPUT_SIZE]);
+   clamp_t(uint32_t, fmt-format.width,
+   sensor-limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE],
+   sensor-limits[SMIAPP_LIMIT_MAX_X_OUTPUT_SIZE]);
fmt-format.height =
-   clamp(fmt-format.height,
- sensor-limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE],
- sensor-limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]);
+   clamp_t(uint32_t, fmt-format.height,
+   sensor-limits[SMIAPP_LIMIT_MIN_Y_OUTPUT_SIZE],
+   sensor-limits[SMIAPP_LIMIT_MAX_Y_OUTPUT_SIZE]);
 
smiapp_get_crop_compose(subdev, fh, crops, NULL, fmt-which);
 
@@ -1834,12 +1835,13 @@ static void smiapp_set_compose_scaler(struct 
v4l2_subdev *subdev,
* sensor-limits[SMIAPP_LIMIT_SCALER_N_MIN]
/ sensor-limits[SMIAPP_LIMIT_MIN_X_OUTPUT_SIZE];
 
-   a = clamp(a, sensor-limits[SMIAPP_LIMIT_SCALER_M_MIN],
- sensor-limits[SMIAPP_LIMIT_SCALER_M_MAX]);
-   b = clamp(b, sensor-limits[SMIAPP_LIMIT_SCALER_M_MIN],
- sensor-limits[SMIAPP_LIMIT_SCALER_M_MAX]);
-   max_m = clamp(max_m, sensor-limits[SMIAPP_LIMIT_SCALER_M_MIN],
- sensor-limits[SMIAPP_LIMIT_SCALER_M_MAX]);
+   a = clamp_t(uint32_t, a, sensor-limits[SMIAPP_LIMIT_SCALER_M_MIN],
+   sensor-limits[SMIAPP_LIMIT_SCALER_M_MAX]);
+   b = clamp_t(uint32_t, b, sensor-limits[SMIAPP_LIMIT_SCALER_M_MIN],
+   sensor-limits[SMIAPP_LIMIT_SCALER_M_MAX]);
+   max_m = clamp_t(uint32_t, max_m,
+   sensor-limits[SMIAPP_LIMIT_SCALER_M_MIN],
+   sensor-limits[SMIAPP_LIMIT_SCALER_M_MAX]);
 
dev_dbg(client-dev, scaling: a %d b %d max_m %d\n, a, b, max_m);
 
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.c 
b/drivers/media/i2c/smiapp/smiapp-quirk.c
index 20e62c1..580132d 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.c
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.c
@@ -51,11 +51,11 @@ static int smiapp_write_8s(struct smiapp_sensor *sensor,
 }
 
 void smiapp_replace_limit(struct smiapp_sensor *sensor,
- u32 limit, u32 val)
+ u32 limit, u64 val)
 {
struct i2c_client *client = v4l2_get_subdevdata(sensor-src-sd);
 
-   dev_dbg(client-dev, quirk: 0x%8.8x \%s\ = %d, 0x%x\n,
+   dev_dbg(client-dev, quirk: 0x%8.8x \%s\ = %llu, 0x%llx\n,
smiapp_reg_limits[limit].addr,
smiapp_reg_limits[limit].what, val, val);
sensor-limits[limit] = val;
diff --git a/drivers/media/i2c/smiapp/smiapp-quirk.h 
b/drivers/media/i2c/smiapp/smiapp-quirk.h
index a6b3183..15ef0af6 100644
--- a/drivers/media/i2c/smiapp/smiapp-quirk.h
+++ b/drivers/media/i2c/smiapp/smiapp-quirk.h
@@ -54,7 +54,7 @@ struct smiapp_reg_8 {
 };
 
 void 

[PATCH 13/17] smiapp-pll: Add pixel rate in pixel array as output parameters

2014-04-09 Thread Sakari Ailus
The actual pixel array pixel rate may be something else than vt_pix_clk_freq
on some implementations. Add a new field which contains the corrected value.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.c | 1 +
 drivers/media/i2c/smiapp-pll.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index 9d06a33..a83597e 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -334,6 +334,7 @@ static int __smiapp_pll_calculate(struct device *dev,
 
pll-pixel_rate_csi =
pll-op_pix_clk_freq_hz * lane_op_clock_ratio;
+   pll-pixel_rate_pixel_array = pll-vt_pix_clk_freq_hz;
 
rval = bounds_check(dev, pll-pll_ip_clk_freq_hz,
limits-min_pll_ip_freq_hz,
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index 02d11db..c6ad809 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -75,6 +75,7 @@ struct smiapp_pll {
uint32_t vt_pix_clk_freq_hz;
 
uint32_t pixel_rate_csi;
+   uint32_t pixel_rate_pixel_array;
 };
 
 struct smiapp_pll_branch_limits {
-- 
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 10/17] smiapp-pll: Add support for odd pre-pll divisors

2014-04-09 Thread Sakari Ailus
Some sensors support odd pre-pll divisor.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.c | 39 ++-
 drivers/media/i2c/smiapp-pll.h |  2 ++
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index 8c196c6..93a8214 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -34,14 +34,18 @@ static inline uint64_t div_u64_round_up(uint64_t dividend, 
uint32_t divisor)
 }
 
 /* Return an even number or one. */
-static inline uint32_t clk_div_even(uint32_t a)
+static inline uint32_t clk_div_even(uint32_t a, bool allow_odd)
 {
+   if (allow_odd)
+   return a;
return max_t(uint32_t, 1, a  ~1);
 }
 
 /* Return an even number or one. */
-static inline uint32_t clk_div_even_up(uint32_t a)
+static inline uint32_t clk_div_even_up(uint32_t a, bool allow_odd)
 {
+   if (allow_odd)
+   return a;
if (a == 1)
return 1;
return (a + 1)  ~1;
@@ -268,13 +272,13 @@ static int __smiapp_pll_calculate(struct device *dev,
min_sys_div = max(min_sys_div,
  DIV_ROUND_UP(min_vt_div,
   limits-vt.max_pix_clk_div));
-   dev_dbg(dev, min_sys_div: max_vt_pix_clk_div: %u\n, min_sys_div);
+   dev_dbg(dev, min_sys_div: max_vt_pix_clk_div: %d\n, min_sys_div);
min_sys_div = max_t(uint32_t, min_sys_div,
pll-pll_op_clk_freq_hz
/ limits-vt.max_sys_clk_freq_hz);
-   dev_dbg(dev, min_sys_div: max_pll_op_clk_freq_hz: %u\n, min_sys_div);
-   min_sys_div = clk_div_even_up(min_sys_div);
-   dev_dbg(dev, min_sys_div: one or even: %u\n, min_sys_div);
+   dev_dbg(dev, min_sys_div: max_pll_op_clk_freq_hz: %d\n, min_sys_div);
+   min_sys_div = clk_div_even_up(min_sys_div, 0);
+   dev_dbg(dev, min_sys_div: one or even: %d\n, min_sys_div);
 
max_sys_div = limits-vt.max_sys_clk_div;
dev_dbg(dev, max_sys_div: %u\n, max_sys_div);
@@ -422,14 +426,19 @@ int smiapp_pll_calculate(struct device *dev,
limits-min_pre_pll_clk_div, limits-max_pre_pll_clk_div);
max_pre_pll_clk_div =
min_t(uint16_t, limits-max_pre_pll_clk_div,
- clk_div_even(pll-ext_clk_freq_hz /
-  limits-min_pll_ip_freq_hz));
+ clk_div_even(
+ pll-ext_clk_freq_hz /
+ limits-min_pll_ip_freq_hz,
+ pll-flags
+  SMIAPP_PLL_FLAG_ALLOW_ODD_PRE_PLL_CLK_DIV));
min_pre_pll_clk_div =
max_t(uint16_t, limits-min_pre_pll_clk_div,
  clk_div_even_up(
  DIV_ROUND_UP(pll-ext_clk_freq_hz,
-  limits-max_pll_ip_freq_hz)));
-   dev_dbg(dev, pre-pll check: min / max pre_pll_clk_div: %u / %u\n,
+  limits-max_pll_ip_freq_hz),
+ pll-flags
+  SMIAPP_PLL_FLAG_ALLOW_ODD_PRE_PLL_CLK_DIV));
+   dev_dbg(dev, pre-pll check: min / max pre_pll_clk_div: %d / %d\n,
min_pre_pll_clk_div, max_pre_pll_clk_div);
 
i = gcd(pll-pll_op_clk_freq_hz, pll-ext_clk_freq_hz);
@@ -441,13 +450,17 @@ int smiapp_pll_calculate(struct device *dev,
max_t(uint16_t, min_pre_pll_clk_div,
  clk_div_even_up(
  DIV_ROUND_UP(mul * pll-ext_clk_freq_hz,
-  limits-max_pll_op_freq_hz)));
-   dev_dbg(dev, pll_op check: min / max pre_pll_clk_div: %u / %u\n,
+  limits-max_pll_op_freq_hz),
+ pll-flags
+  SMIAPP_PLL_FLAG_ALLOW_ODD_PRE_PLL_CLK_DIV));
+   dev_dbg(dev, pll_op check: min / max pre_pll_clk_div: %d / %d\n,
min_pre_pll_clk_div, max_pre_pll_clk_div);
 
for (pll-pre_pll_clk_div = min_pre_pll_clk_div;
 pll-pre_pll_clk_div = max_pre_pll_clk_div;
-pll-pre_pll_clk_div += 2 - (pll-pre_pll_clk_div  1)) {
+pll-pre_pll_clk_div +=
+pll-flags  SMIAPP_PLL_FLAG_ALLOW_ODD_PRE_PLL_CLK_DIV
+? 1 : (2 - (pll-pre_pll_clk_div  1))) {
rval = __smiapp_pll_calculate(dev, limits, pll, mul, div,
  lane_op_clock_ratio);
if (rval)
diff --git a/drivers/media/i2c/smiapp-pll.h b/drivers/media/i2c/smiapp-pll.h
index bb5ae28..a25f550 100644
--- a/drivers/media/i2c/smiapp-pll.h
+++ b/drivers/media/i2c/smiapp-pll.h
@@ -34,6 +34,8 @@
 /* op pix clock is for all lanes in total normally */
 #define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE 

[PATCH 01/17] smiapp: Use I2C adapter ID and address in the sub-device name

2014-04-09 Thread Sakari Ailus
The sub-device names should be unique. Should two identical sensors be
present in the same media device they would be indistinguishable. The names
will change e.g. from vs6555 pixel array to vs6555 1-0010 pixel array.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp/smiapp-core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 8741cae..69c11ec 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2543,8 +2543,9 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
}
 
snprintf(this-sd.name,
-sizeof(this-sd.name), %s %s,
-sensor-minfo.name, _this-name);
+sizeof(this-sd.name), %s %d-%4.4x %s,
+sensor-minfo.name, i2c_adapter_id(client-adapter),
+client-addr, _this-name);
 
this-sink_fmt.width =
sensor-limits[SMIAPP_LIMIT_X_ADDR_MAX] + 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


[PATCH 09/17] smiapp-pll: Use 64-bit types limits

2014-04-09 Thread Sakari Ailus
Limits may exceed the value range of 32-bit unsigned integers. Thus use 64
bits for all of them.

Signed-off-by: Sakari Ailus sakari.ai...@linux.intel.com
---
 drivers/media/i2c/smiapp-pll.c | 69 +++---
 drivers/media/i2c/smiapp-pll.h | 20 ++--
 2 files changed, 48 insertions(+), 41 deletions(-)

diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c
index d14af5c..8c196c6 100644
--- a/drivers/media/i2c/smiapp-pll.c
+++ b/drivers/media/i2c/smiapp-pll.c
@@ -28,6 +28,11 @@
 
 #include smiapp-pll.h
 
+static inline uint64_t div_u64_round_up(uint64_t dividend, uint32_t divisor)
+{
+   return div_u64(dividend + divisor - 1, divisor);
+}
+
 /* Return an even number or one. */
 static inline uint32_t clk_div_even(uint32_t a)
 {
@@ -52,8 +57,8 @@ static inline uint32_t is_one_or_even(uint32_t a)
return 1;
 }
 
-static int bounds_check(struct device *dev, uint32_t val,
-   uint32_t min, uint32_t max, char *str)
+static int bounds_check(struct device *dev, uint64_t val,
+   uint64_t min, uint64_t max, char *str)
 {
if (val = min  val = max)
return 0;
@@ -75,15 +80,15 @@ static void print_pll(struct device *dev, struct smiapp_pll 
*pll)
dev_dbg(dev, vt_pix_clk_div \t%u\n,  pll-vt_pix_clk_div);
 
dev_dbg(dev, ext_clk_freq_hz \t%u\n, pll-ext_clk_freq_hz);
-   dev_dbg(dev, pll_ip_clk_freq_hz \t%u\n, pll-pll_ip_clk_freq_hz);
-   dev_dbg(dev, pll_op_clk_freq_hz \t%u\n, pll-pll_op_clk_freq_hz);
+   dev_dbg(dev, pll_ip_clk_freq_hz \t%llu\n, pll-pll_ip_clk_freq_hz);
+   dev_dbg(dev, pll_op_clk_freq_hz \t%llu\n, pll-pll_op_clk_freq_hz);
if (!(pll-flags  SMIAPP_PLL_FLAG_NO_OP_CLOCKS)) {
-   dev_dbg(dev, op_sys_clk_freq_hz \t%u\n,
+   dev_dbg(dev, op_sys_clk_freq_hz \t%llu\n,
pll-op_sys_clk_freq_hz);
dev_dbg(dev, op_pix_clk_freq_hz \t%u\n,
pll-op_pix_clk_freq_hz);
}
-   dev_dbg(dev, vt_sys_clk_freq_hz \t%u\n, pll-vt_sys_clk_freq_hz);
+   dev_dbg(dev, vt_sys_clk_freq_hz \t%llu\n, pll-vt_sys_clk_freq_hz);
dev_dbg(dev, vt_pix_clk_freq_hz \t%u\n, pll-vt_pix_clk_freq_hz);
 }
 
@@ -131,10 +136,11 @@ static int __smiapp_pll_calculate(struct device *dev,
more_mul_max);
/* Don't go above max pll op frequency. */
more_mul_max =
-   min_t(uint32_t,
+   min_t(uint64_t,
  more_mul_max,
- limits-max_pll_op_freq_hz
- / (pll-ext_clk_freq_hz / pll-pre_pll_clk_div * mul));
+ div_u64(limits-max_pll_op_freq_hz,
+ (pll-ext_clk_freq_hz /
+  pll-pre_pll_clk_div * mul)));
dev_dbg(dev, more_mul_max: max_pll_op_freq_hz check: %u\n,
more_mul_max);
/* Don't go above the division capability of op sys clock divider. */
@@ -150,9 +156,9 @@ static int __smiapp_pll_calculate(struct device *dev,
more_mul_max);
 
/* Ensure we won't go below min_pll_op_freq_hz. */
-   more_mul_min = DIV_ROUND_UP(limits-min_pll_op_freq_hz,
-   pll-ext_clk_freq_hz / pll-pre_pll_clk_div
-   * mul);
+   more_mul_min = div_u64_round_up(
+   limits-min_pll_op_freq_hz,
+   pll-ext_clk_freq_hz / pll-pre_pll_clk_div * mul);
dev_dbg(dev, more_mul_min: min_pll_op_freq_hz check: %u\n,
more_mul_min);
/* Ensure we won't go below min_pll_multiplier. */
@@ -194,13 +200,13 @@ static int __smiapp_pll_calculate(struct device *dev,
 
/* Derive pll_op_clk_freq_hz. */
pll-op_sys_clk_freq_hz =
-   pll-pll_op_clk_freq_hz / pll-op_sys_clk_div;
+   div_u64(pll-pll_op_clk_freq_hz, pll-op_sys_clk_div);
 
pll-op_pix_clk_div = pll-bits_per_pixel;
dev_dbg(dev, op_pix_clk_div: %u\n, pll-op_pix_clk_div);
 
pll-op_pix_clk_freq_hz =
-   pll-op_sys_clk_freq_hz / pll-op_pix_clk_div;
+   div_u64(pll-op_sys_clk_freq_hz, pll-op_pix_clk_div);
 
/*
 * Some sensors perform analogue binning and some do this
@@ -235,9 +241,9 @@ static int __smiapp_pll_calculate(struct device *dev,
 
/* Find smallest and biggest allowed vt divisor. */
dev_dbg(dev, min_vt_div: %u\n, min_vt_div);
-   min_vt_div = max(min_vt_div,
-DIV_ROUND_UP(pll-pll_op_clk_freq_hz,
- limits-vt.max_pix_clk_freq_hz));
+   min_vt_div = max_t(uint32_t, min_vt_div,
+  div_u64_round_up(pll-pll_op_clk_freq_hz,
+   limits-vt.max_pix_clk_freq_hz));
dev_dbg(dev, min_vt_div: max_vt_pix_clk_freq_hz: %u\n,
min_vt_div);
min_vt_div = 

[PATCHv2 2/2] rtl28xxu: silence error log about disabled rtl2832_sdr module

2014-04-09 Thread Antti Palosaari
It printed a little bit too heavy looking error log DVB: Unable to
find symbol rtl2832_sdr_attach() when staging module was disabled.
Silence that error by introducing own version of dvb_attach() macro
without the error logging.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 27 +++
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index af43183..dc521ea 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -55,6 +55,25 @@ static inline struct dvb_frontend *rtl2832_sdr_attach(struct 
dvb_frontend *fe,
 }
 #endif
 
+#ifdef CONFIG_MEDIA_ATTACH
+#define dvb_attach_sdr(FUNCTION, ARGS...) ({ \
+   void *__r = NULL; \
+   typeof(FUNCTION) __a = symbol_request(FUNCTION); \
+   if (__a) { \
+   __r = (void *) __a(ARGS); \
+   if (__r == NULL) \
+   symbol_put(FUNCTION); \
+   } \
+   __r; \
+})
+
+#else
+#define dvb_attach_sdr(FUNCTION, ARGS...) ({ \
+   FUNCTION(ARGS); \
+})
+
+#endif
+
 static int rtl28xxu_disable_rc;
 module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644);
 MODULE_PARM_DESC(disable_rc, disable RTL2832U remote controller);
@@ -927,7 +946,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_fc0012_config, NULL);
break;
case TUNER_RTL2832_FC0013:
@@ -939,7 +958,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_fc0013_config, NULL);
break;
case TUNER_RTL2832_E4000: {
@@ -970,7 +989,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
i2c_set_adapdata(i2c_adap_internal, d);
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0],
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0],
i2c_adap_internal,
rtl28xxu_rtl2832_e4000_config, sd);
}
@@ -1001,7 +1020,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_r820t_config, NULL);
break;
case TUNER_RTL2832_R828D:
-- 
1.9.0

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


[PATCHv2 1/2] rtl28xxu: do not hard depend on staging SDR module

2014-04-09 Thread Antti Palosaari
RTL2832 SDR extension module is currently on staging. SDR module
headers were included from staging causing direct dependency staging
directory. As a solution, add needed headers to main driver.
Motivation of that change comes from Luis / driver backports project.

Reported-by: Luis R. Rodriguez mcg...@do-not-panic.com
Cc: backpo...@vger.kernel.org
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/Makefile   |  1 -
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 21 -
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/Makefile 
b/drivers/media/usb/dvb-usb-v2/Makefile
index 7407b83..bc38f03 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -41,4 +41,3 @@ ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
 ccflags-y += -I$(srctree)/drivers/media/tuners
 ccflags-y += -I$(srctree)/drivers/media/common
-ccflags-y += -I$(srctree)/drivers/staging/media/rtl2832u_sdr
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index c83c16c..af43183 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -24,7 +24,6 @@
 
 #include rtl2830.h
 #include rtl2832.h
-#include rtl2832_sdr.h
 
 #include qt1010.h
 #include mt2060.h
@@ -36,6 +35,26 @@
 #include tua9001.h
 #include r820t.h
 
+/*
+ * RTL2832_SDR module is in staging. That logic is added in order to avoid any
+ * hard dependency to drivers/staging/ directory as we want compile mainline
+ * driver even whole staging directory is missing.
+ */
+#include media/v4l2-subdev.h
+
+#if IS_ENABLED(CONFIG_DVB_RTL2832_SDR)
+extern struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
+   struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
+   struct v4l2_subdev *sd);
+#else
+static inline struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
+   struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
+   struct v4l2_subdev *sd)
+{
+   return NULL;
+}
+#endif
+
 static int rtl28xxu_disable_rc;
 module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644);
 MODULE_PARM_DESC(disable_rc, disable RTL2832U remote controller);
-- 
1.9.0

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


[PATCHv2 0/2] rtl2832_sdr module attach related fixes

2014-04-09 Thread Antti Palosaari
V2: I split patch to two.

Pull request for kernel 3.15 will follow right after that mail.

regards,
Antti

Antti Palosaari (2):
  rtl28xxu: do not hard depend on staging SDR module
  rtl28xxu: silence error log about disabled rtl2832_sdr module

 drivers/media/usb/dvb-usb-v2/Makefile   |  1 -
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 48 +
 2 files changed, 43 insertions(+), 6 deletions(-)

-- 
1.9.0

--
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: [PATCHv2 1/2] rtl28xxu: do not hard depend on staging SDR module

2014-04-09 Thread Luis R. Rodriguez
On Wed, Apr 9, 2014 at 2:32 PM, Antti Palosaari cr...@iki.fi wrote:
 +extern struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
 +   struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
 +   struct v4l2_subdev *sd);

extern

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


[PATCHv3 0/2] rtl2832_sdr module attach related fixes

2014-04-09 Thread Antti Palosaari
v2: I split patch to two.
v3: remove unneeded extern keyword from rtl2832_sdr_attach() declaration

Pull request for kernel 3.15 will follow right after that mail. Or tomorrow. 
Or...

regards,
Antti

Antti Palosaari (2):
  rtl28xxu: do not hard depend on staging SDR module
  rtl28xxu: silence error log about disabled rtl2832_sdr module

 drivers/media/usb/dvb-usb-v2/Makefile   |  1 -
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 48 +
 2 files changed, 43 insertions(+), 6 deletions(-)

-- 
1.9.0

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


[PATCHv3 2/2] rtl28xxu: silence error log about disabled rtl2832_sdr module

2014-04-09 Thread Antti Palosaari
It printed a little bit too heavy looking error log DVB: Unable to
find symbol rtl2832_sdr_attach() when staging module was disabled.
Silence that error by introducing own version of dvb_attach() macro
without the error logging.

Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 27 +++
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 8d7c5f2..8bab912 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -55,6 +55,25 @@ static inline struct dvb_frontend *rtl2832_sdr_attach(struct 
dvb_frontend *fe,
 }
 #endif
 
+#ifdef CONFIG_MEDIA_ATTACH
+#define dvb_attach_sdr(FUNCTION, ARGS...) ({ \
+   void *__r = NULL; \
+   typeof(FUNCTION) __a = symbol_request(FUNCTION); \
+   if (__a) { \
+   __r = (void *) __a(ARGS); \
+   if (__r == NULL) \
+   symbol_put(FUNCTION); \
+   } \
+   __r; \
+})
+
+#else
+#define dvb_attach_sdr(FUNCTION, ARGS...) ({ \
+   FUNCTION(ARGS); \
+})
+
+#endif
+
 static int rtl28xxu_disable_rc;
 module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644);
 MODULE_PARM_DESC(disable_rc, disable RTL2832U remote controller);
@@ -927,7 +946,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_fc0012_config, NULL);
break;
case TUNER_RTL2832_FC0013:
@@ -939,7 +958,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_fc0013_config, NULL);
break;
case TUNER_RTL2832_E4000: {
@@ -970,7 +989,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
i2c_set_adapdata(i2c_adap_internal, d);
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0],
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0],
i2c_adap_internal,
rtl28xxu_rtl2832_e4000_config, sd);
}
@@ -1001,7 +1020,7 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter 
*adap)
adap-fe[0]-ops.tuner_ops.get_rf_strength;
 
/* attach SDR */
-   dvb_attach(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
+   dvb_attach_sdr(rtl2832_sdr_attach, adap-fe[0], d-i2c_adap,
rtl28xxu_rtl2832_r820t_config, NULL);
break;
case TUNER_RTL2832_R828D:
-- 
1.9.0

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


[PATCHv3 1/2] rtl28xxu: do not hard depend on staging SDR module

2014-04-09 Thread Antti Palosaari
RTL2832 SDR extension module is currently on staging. SDR module
headers were included from staging causing direct dependency staging
directory. As a solution, add needed headers to main driver.
Motivation of that change comes from Luis / driver backports project.

Reported-by: Luis R. Rodriguez mcg...@do-not-panic.com
Cc: backpo...@vger.kernel.org
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/Makefile   |  1 -
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 21 -
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/Makefile 
b/drivers/media/usb/dvb-usb-v2/Makefile
index 7407b83..bc38f03 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -41,4 +41,3 @@ ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
 ccflags-y += -I$(srctree)/drivers/media/tuners
 ccflags-y += -I$(srctree)/drivers/media/common
-ccflags-y += -I$(srctree)/drivers/staging/media/rtl2832u_sdr
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index c83c16c..8d7c5f2 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -24,7 +24,6 @@
 
 #include rtl2830.h
 #include rtl2832.h
-#include rtl2832_sdr.h
 
 #include qt1010.h
 #include mt2060.h
@@ -36,6 +35,26 @@
 #include tua9001.h
 #include r820t.h
 
+/*
+ * RTL2832_SDR module is in staging. That logic is added in order to avoid any
+ * hard dependency to drivers/staging/ directory as we want compile mainline
+ * driver even whole staging directory is missing.
+ */
+#include media/v4l2-subdev.h
+
+#if IS_ENABLED(CONFIG_DVB_RTL2832_SDR)
+struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
+   struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
+   struct v4l2_subdev *sd);
+#else
+static inline struct dvb_frontend *rtl2832_sdr_attach(struct dvb_frontend *fe,
+   struct i2c_adapter *i2c, const struct rtl2832_config *cfg,
+   struct v4l2_subdev *sd)
+{
+   return NULL;
+}
+#endif
+
 static int rtl28xxu_disable_rc;
 module_param_named(disable_rc, rtl28xxu_disable_rc, int, 0644);
 MODULE_PARM_DESC(disable_rc, disable RTL2832U remote controller);
-- 
1.9.0

--
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 2/7] libdvbv5: fix asprintf compile warning in dvbv5-scan

2014-04-09 Thread André Roth
Signed-off-by: André Roth neol...@gmail.com
---
 utils/dvb/dvbv5-scan.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/utils/dvb/dvbv5-scan.c b/utils/dvb/dvbv5-scan.c
index 501b332..7eb3bf5 100644
--- a/utils/dvb/dvbv5-scan.c
+++ b/utils/dvb/dvbv5-scan.c
@@ -407,6 +407,7 @@ int main(int argc, char **argv)
 {
struct arguments args;
int err, lnb = -1,idx = -1;
+   int r;
const struct argp argp = {
.options = options,
.parser = parse_opt,
@@ -459,8 +460,12 @@ int main(int argc, char **argv)
return -1;
}
 
-   asprintf(args.demux_dev,
+   r = asprintf(args.demux_dev,
 /dev/dvb/adapter%i/demux%i, args.adapter_dmx, args.demux);
+   if (r  0) {
+   fprintf(stderr, asprintf error\n );
+   return -1;
+   }
 
if (verbose)
fprintf(stderr, using demux '%s'\n, args.demux_dev);
-- 
1.7.10.4

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


[PATCH 1/7] libdvbv5: reunite atsc_table_header and dvb_table_header

2014-04-09 Thread André Roth
this solves the ambiguity when parsing the dvb/atsc header
in dvb-scan.c

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/atsc_eit.h|2 +-
 lib/include/libdvbv5/atsc_header.h |   39 ++
 lib/include/libdvbv5/header.h  |5 ++--
 lib/include/libdvbv5/mgt.h |2 +-
 lib/include/libdvbv5/vct.h |2 +-
 lib/libdvbv5/Makefile.am   |1 -
 lib/libdvbv5/descriptors/atsc_eit.c|2 +-
 lib/libdvbv5/descriptors/atsc_header.c |   47 
 lib/libdvbv5/descriptors/header.c  |3 +-
 lib/libdvbv5/descriptors/mgt.c |2 +-
 lib/libdvbv5/descriptors/vct.c |2 +-
 11 files changed, 17 insertions(+), 90 deletions(-)
 delete mode 100644 lib/libdvbv5/descriptors/atsc_header.c

diff --git a/lib/include/libdvbv5/atsc_eit.h b/lib/include/libdvbv5/atsc_eit.h
index c527b1d..8b093de 100644
--- a/lib/include/libdvbv5/atsc_eit.h
+++ b/lib/include/libdvbv5/atsc_eit.h
@@ -64,7 +64,7 @@ union atsc_table_eit_desc_length {
 } __attribute__((packed));
 
 struct atsc_table_eit {
-   struct atsc_table_header header;
+   ATSC_HEADER();
uint8_t events;
struct atsc_table_eit_event *event;
 } __attribute__((packed));
diff --git a/lib/include/libdvbv5/atsc_header.h 
b/lib/include/libdvbv5/atsc_header.h
index 9685b37..12e7379 100644
--- a/lib/include/libdvbv5/atsc_header.h
+++ b/lib/include/libdvbv5/atsc_header.h
@@ -24,40 +24,17 @@
 #include stdint.h
 #include unistd.h /* ssize_t */
 
+#include libdvbv5/header.h
+
 #define ATSC_BASE_PID  0x1FFB
 
-struct atsc_table_header {
-   uint8_t  table_id;
-   union {
-   uint16_t bitfield;
-   struct {
-   uint16_t section_length:12;
-   uint16_t one:2;
-   uint16_t priv:1;
-   uint16_t syntax:1;
-   } __attribute__((packed));
-   } __attribute__((packed));
-   uint16_t id;
-   uint8_t  current_next:1;
-   uint8_t  version:5;
-   uint8_t  one2:2;
-
-   uint8_t  section_id;
-   uint8_t  last_section;
-   uint8_t  protocol_version;
-} __attribute__((packed));
-
-struct dvb_v5_fe_parms;
-
-#ifdef __cplusplus
-extern C {
-#endif
+#define ATSC_HEADER() \
+   struct dvb_table_header header; \
+   uint8_t  protocol_version; \
 
-int  atsc_table_header_init (struct atsc_table_header *t);
-void atsc_table_header_print(struct dvb_v5_fe_parms *parms, const struct 
atsc_table_header *t);
+#define ATSC_TABLE_HEADER_PRINT(_parms, _table) \
+   dvb_table_header_print(_parms, _table-header); \
+   dvb_log(| protocol_version %d, _table-protocol_version); \
 
-#ifdef __cplusplus
-}
-#endif
 
 #endif
diff --git a/lib/include/libdvbv5/header.h b/lib/include/libdvbv5/header.h
index 67b7694..dc85f46 100644
--- a/lib/include/libdvbv5/header.h
+++ b/lib/include/libdvbv5/header.h
@@ -50,10 +50,9 @@ struct dvb_table_header {
union {
uint16_t bitfield;
struct {
-   uint16_t section_length:10;
-   uint8_t  zero:2;
+   uint16_t section_length:12;
uint8_t  one:2;
-   uint8_t  zero2:1;
+   uint8_t  zero:1;
uint8_t  syntax:1;
} __attribute__((packed));
} __attribute__((packed));
diff --git a/lib/include/libdvbv5/mgt.h b/lib/include/libdvbv5/mgt.h
index 4ea905d..cb8d63a 100644
--- a/lib/include/libdvbv5/mgt.h
+++ b/lib/include/libdvbv5/mgt.h
@@ -53,7 +53,7 @@ struct atsc_table_mgt_table {
 } __attribute__((packed));
 
 struct atsc_table_mgt {
-   struct atsc_table_header header;
+   ATSC_HEADER();
 uint16_t tables;
 struct atsc_table_mgt_table *table;
struct dvb_desc *descriptor;
diff --git a/lib/include/libdvbv5/vct.h b/lib/include/libdvbv5/vct.h
index 6d41ac5..83bad06 100644
--- a/lib/include/libdvbv5/vct.h
+++ b/lib/include/libdvbv5/vct.h
@@ -85,7 +85,7 @@ struct atsc_table_vct_channel {
 } __attribute__((packed));
 
 struct atsc_table_vct {
-   struct atsc_table_header header;
+   ATSC_HEADER();
 
uint8_t num_channels_in_section;
 
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index 667a1af..df67544 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -69,7 +69,6 @@ libdvbv5_la_SOURCES = \
dvb-scan.c  \
descriptors.c   \
descriptors/header.c\
-   descriptors/atsc_header.c   \
descriptors/pat.c   \
descriptors/pmt.c   \
descriptors/nit.c   \
diff --git a/lib/libdvbv5/descriptors/atsc_eit.c 
b/lib/libdvbv5/descriptors/atsc_eit.c
index 9e1397d..286748c 100644
--- a/lib/libdvbv5/descriptors/atsc_eit.c
+++ b/lib/libdvbv5/descriptors/atsc_eit.c
@@ -132,7 +132,7 @@ void 

[PATCH 7/7] libdvbv5: rename descriptor functions

2014-04-09 Thread André Roth
prefix the descriptor functions with dvb_desc
for a nice API and code completion support

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/descriptors.h  |6 +++---
 lib/libdvbv5/descriptors.c  |6 +++---
 lib/libdvbv5/descriptors/atsc_eit.c |6 +++---
 lib/libdvbv5/descriptors/cat.c  |6 +++---
 lib/libdvbv5/descriptors/eit.c  |6 +++---
 lib/libdvbv5/descriptors/mgt.c  |8 
 lib/libdvbv5/descriptors/nit.c  |   12 ++--
 lib/libdvbv5/descriptors/pmt.c  |   12 ++--
 lib/libdvbv5/descriptors/sdt.c  |6 +++---
 lib/libdvbv5/descriptors/vct.c  |   10 +-
 10 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/lib/include/libdvbv5/descriptors.h 
b/lib/include/libdvbv5/descriptors.h
index d08ab3e..8b38977 100644
--- a/lib/include/libdvbv5/descriptors.h
+++ b/lib/include/libdvbv5/descriptors.h
@@ -82,9 +82,9 @@ uint32_t bcd(uint32_t bcd);
 
 void hexdump(struct dvb_v5_fe_parms *parms, const char *prefix, const unsigned 
char *buf, int len);
 
-int dvb_parse_descriptors(struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
uint16_t section_length, struct dvb_desc **head_desc);
-void dvb_free_descriptors(struct dvb_desc **list);
-void dvb_print_descriptors(struct dvb_v5_fe_parms *parms, struct dvb_desc 
*desc);
+int  dvb_desc_parse(struct dvb_v5_fe_parms *parms, const uint8_t *buf, 
uint16_t section_length, struct dvb_desc **head_desc);
+void dvb_desc_free (struct dvb_desc **list);
+void dvb_desc_print(struct dvb_v5_fe_parms *parms, struct dvb_desc *desc);
 
 #ifdef __cplusplus
 }
diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index 539f824..c2b0293 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -98,7 +98,7 @@ const struct dvb_table_init dvb_table_initializers[] = {
 char *default_charset = iso-8859-1;
 char *output_charset = utf-8;
 
-int dvb_parse_descriptors(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
+int dvb_desc_parse(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
   uint16_t buflen, struct dvb_desc **head_desc)
 {
const uint8_t *ptr = buf, *endbuf = buf + buflen;
@@ -172,7 +172,7 @@ int dvb_parse_descriptors(struct dvb_v5_fe_parms *parms, 
const uint8_t *buf,
return 0;
 }
 
-void dvb_print_descriptors(struct dvb_v5_fe_parms *parms, struct dvb_desc 
*desc)
+void dvb_desc_print(struct dvb_v5_fe_parms *parms, struct dvb_desc *desc)
 {
while (desc) {
dvb_desc_print_func print = dvb_descriptors[desc-type].print;
@@ -184,7 +184,7 @@ void dvb_print_descriptors(struct dvb_v5_fe_parms *parms, 
struct dvb_desc *desc)
}
 }
 
-void dvb_free_descriptors(struct dvb_desc **list)
+void dvb_desc_free(struct dvb_desc **list)
 {
struct dvb_desc *desc = *list;
while (desc) {
diff --git a/lib/libdvbv5/descriptors/atsc_eit.c 
b/lib/libdvbv5/descriptors/atsc_eit.c
index 985b055..38f3810 100644
--- a/lib/libdvbv5/descriptors/atsc_eit.c
+++ b/lib/libdvbv5/descriptors/atsc_eit.c
@@ -113,7 +113,7 @@ ssize_t atsc_table_eit_init(struct dvb_v5_fe_parms *parms, 
const uint8_t *buf,
   endbuf - p, size);
return -5;
}
-   dvb_parse_descriptors(parms, p, size, event-descriptor);
+   dvb_desc_parse(parms, p, size, event-descriptor);
 
p += size;
}
@@ -129,7 +129,7 @@ void atsc_table_eit_free(struct atsc_table_eit *eit)
while (event) {
struct atsc_table_eit_event *tmp = event;
 
-   dvb_free_descriptors((struct dvb_desc **) event-descriptor);
+   dvb_desc_free((struct dvb_desc **) event-descriptor);
event = event-next;
free(tmp);
}
@@ -154,7 +154,7 @@ void atsc_table_eit_print(struct dvb_v5_fe_parms *parms, 
struct atsc_table_eit *
dvb_loginfo(|   Duration  %dh %dm %ds, 
event-duration / 3600, (event-duration % 3600) / 60, event-duration % 60);
dvb_loginfo(|   ETM   %d, event-etm);
dvb_loginfo(|   title length  %d, 
event-title_length);
-   dvb_print_descriptors(parms, event-descriptor);
+   dvb_desc_print(parms, event-descriptor);
event = event-next;
events++;
}
diff --git a/lib/libdvbv5/descriptors/cat.c b/lib/libdvbv5/descriptors/cat.c
index a8fb00b..5acc88e 100644
--- a/lib/libdvbv5/descriptors/cat.c
+++ b/lib/libdvbv5/descriptors/cat.c
@@ -65,7 +65,7 @@ ssize_t dvb_table_cat_init(struct dvb_v5_fe_parms *parms, 
const uint8_t *buf,
/* parse the descriptors */
if (endbuf  p) {
uint16_t desc_length = endbuf - p;
-   if (dvb_parse_descriptors(parms, p, desc_length,
+   if (dvb_desc_parse(parms, p, desc_length,
  head_desc) != 0) {
 

[PATCH 6/7] libdvbv5: cleanup printing of tables and descriptors

2014-04-09 Thread André Roth
- use log info for table and descpritor printing
- cleanup 'out of memory' logs
- fix error condition in desc_ts_info

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/atsc_header.h |2 +-
 lib/libdvbv5/descriptors.c |4 +-
 lib/libdvbv5/descriptors/atsc_eit.c|   18 
 lib/libdvbv5/descriptors/cat.c |2 +-
 .../descriptors/desc_atsc_service_location.c   |   12 +++---
 lib/libdvbv5/descriptors/desc_ca.c |6 +--
 lib/libdvbv5/descriptors/desc_ca_identifier.c  |2 +-
 lib/libdvbv5/descriptors/desc_cable_delivery.c |   12 +++---
 lib/libdvbv5/descriptors/desc_event_extended.c |2 +-
 lib/libdvbv5/descriptors/desc_event_short.c|6 +--
 lib/libdvbv5/descriptors/desc_extension.c  |4 +-
 lib/libdvbv5/descriptors/desc_frequency_list.c |4 +-
 lib/libdvbv5/descriptors/desc_hierarchy.c  |8 ++--
 lib/libdvbv5/descriptors/desc_isdbt_delivery.c |8 ++--
 lib/libdvbv5/descriptors/desc_language.c   |2 +-
 lib/libdvbv5/descriptors/desc_logical_channel.c|8 ++--
 lib/libdvbv5/descriptors/desc_network_name.c   |2 +-
 lib/libdvbv5/descriptors/desc_partial_reception.c  |4 +-
 lib/libdvbv5/descriptors/desc_sat.c|   14 +++---
 lib/libdvbv5/descriptors/desc_service.c|6 +--
 lib/libdvbv5/descriptors/desc_service_list.c   |4 +-
 lib/libdvbv5/descriptors/desc_service_location.c   |8 ++--
 lib/libdvbv5/descriptors/desc_t2_delivery.c|   28 ++--
 .../descriptors/desc_terrestrial_delivery.c|   26 +--
 lib/libdvbv5/descriptors/desc_ts_info.c|   16 ---
 lib/libdvbv5/descriptors/eit.c |   26 +--
 lib/libdvbv5/descriptors/header.c  |   22 +-
 lib/libdvbv5/descriptors/mgt.c |   22 +-
 lib/libdvbv5/descriptors/mpeg_es.c |   30 ++---
 lib/libdvbv5/descriptors/mpeg_pes.c|2 +-
 lib/libdvbv5/descriptors/mpeg_ts.c |   38 -
 lib/libdvbv5/descriptors/nit.c |   17 
 lib/libdvbv5/descriptors/pat.c |2 +-
 lib/libdvbv5/descriptors/sdt.c |   22 +-
 lib/libdvbv5/descriptors/vct.c |   45 ++--
 lib/libdvbv5/dvb-scan.c|4 +-
 36 files changed, 222 insertions(+), 216 deletions(-)

diff --git a/lib/include/libdvbv5/atsc_header.h 
b/lib/include/libdvbv5/atsc_header.h
index 12e7379..96bfc11 100644
--- a/lib/include/libdvbv5/atsc_header.h
+++ b/lib/include/libdvbv5/atsc_header.h
@@ -34,7 +34,7 @@
 
 #define ATSC_TABLE_HEADER_PRINT(_parms, _table) \
dvb_table_header_print(_parms, _table-header); \
-   dvb_log(| protocol_version %d, _table-protocol_version); \
+   dvb_loginfo(| protocol_version %d, _table-protocol_version); \
 
 
 #endif
diff --git a/lib/libdvbv5/descriptors.c b/lib/libdvbv5/descriptors.c
index 54ce933..539f824 100644
--- a/lib/libdvbv5/descriptors.c
+++ b/lib/libdvbv5/descriptors.c
@@ -178,7 +178,7 @@ void dvb_print_descriptors(struct dvb_v5_fe_parms *parms, 
struct dvb_desc *desc)
dvb_desc_print_func print = dvb_descriptors[desc-type].print;
if (!print)
print = dvb_desc_default_print;
-   dvb_log(|0x%02x: %s, desc-type, 
dvb_descriptors[desc-type].name);
+   dvb_loginfo(|0x%02x: %s, desc-type, 
dvb_descriptors[desc-type].name);
print(parms, desc);
desc = desc-next;
}
@@ -1374,6 +1374,6 @@ void hexdump(struct dvb_v5_fe_parms *parms, const char 
*prefix, const unsigned c
for (i = strlen(hex); i  49; i++)
strncat(spaces,  , sizeof(spaces));
ascii[j] = '\0';
-   dvb_log(%s%s %s %s, prefix, hex, spaces, ascii);
+   dvb_loginfo(%s%s %s %s, prefix, hex, spaces, ascii);
}
 }
diff --git a/lib/libdvbv5/descriptors/atsc_eit.c 
b/lib/libdvbv5/descriptors/atsc_eit.c
index 2b446bb..985b055 100644
--- a/lib/libdvbv5/descriptors/atsc_eit.c
+++ b/lib/libdvbv5/descriptors/atsc_eit.c
@@ -138,7 +138,7 @@ void atsc_table_eit_free(struct atsc_table_eit *eit)
 
 void atsc_table_eit_print(struct dvb_v5_fe_parms *parms, struct atsc_table_eit 
*eit)
 {
-   dvb_log(EIT);
+   dvb_loginfo(EIT);
ATSC_TABLE_HEADER_PRINT(parms, eit);
const struct atsc_table_eit_event *event = eit-event;
uint16_t events = 0;
@@ -147,18 +147,18 @@ void atsc_table_eit_print(struct dvb_v5_fe_parms *parms, 
struct atsc_table_eit *
char start[255];
 
strftime(start, sizeof(start), %F %T, event-start);
-   dvb_log(|-  event %7d, event-event_id);
-   dvb_log(|   

[PATCH 4/7] libdvbv5: make dvb_table_filter_free public

2014-04-09 Thread André Roth
make dvb_table_filter_free public so it can be used by
applications.
fix potential double free.

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/dvb-scan.h |2 ++
 lib/libdvbv5/dvb-scan.c |   10 ++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/include/libdvbv5/dvb-scan.h b/lib/include/libdvbv5/dvb-scan.h
index 206d409..f0af9d7 100644
--- a/lib/include/libdvbv5/dvb-scan.h
+++ b/lib/include/libdvbv5/dvb-scan.h
@@ -74,6 +74,8 @@ struct dvb_table_filter {
void *priv;
 };
 
+void dvb_table_filter_free(struct dvb_table_filter *sect);
+
 int dvb_read_section(struct dvb_v5_fe_parms *parms, int dmx_fd, unsigned char 
tid, uint16_t pid, void **table,
unsigned timeout);
 
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index e55..d8b3953 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -158,10 +158,12 @@ static int dvb_parse_section_alloc(struct dvb_v5_fe_parms 
*parms,
return 0;
 }
 
-static void dvb_parse_section_free(struct dvb_table_filter *sect)
+void dvb_table_filter_free(struct dvb_table_filter *sect)
 {
-   if (sect-priv)
+   if (sect-priv) {
free(sect-priv);
+   sect-priv = NULL;
+   }
 }
 
 static int dvb_parse_section(struct dvb_v5_fe_parms *parms,
@@ -280,7 +282,7 @@ int dvb_read_sections(struct dvb_v5_fe_parms *parms, int 
dmx_fd,
if (!buf) {
dvb_perror(Out of memory);
dvb_dmx_stop(dmx_fd);
-   dvb_parse_section_free(sect);
+   dvb_table_filter_free(sect);
return -1;
}
 
@@ -327,7 +329,7 @@ int dvb_read_sections(struct dvb_v5_fe_parms *parms, int 
dmx_fd,
} while (!ret);
free(buf);
dvb_dmx_stop(dmx_fd);
-   dvb_parse_section_free(sect);
+   dvb_table_filter_free(sect);
 
if (ret  0)
ret = 0;
-- 
1.7.10.4

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


[PATCH 3/7] libdvbv5: make crc32 public

2014-04-09 Thread André Roth
applications reading dvb files might want to
check crc, therefore provide the crc32 function
in the header files.

Signed-off-by: André Roth neol...@gmail.com
---
 lib/{ = include}/libdvbv5/crc32.h |0
 lib/libdvbv5/Makefile.am   |1 +
 lib/libdvbv5/crc32.c   |2 +-
 lib/libdvbv5/dvb-scan.c|2 +-
 4 files changed, 3 insertions(+), 2 deletions(-)
 rename lib/{ = include}/libdvbv5/crc32.h (100%)

diff --git a/lib/libdvbv5/crc32.h b/lib/include/libdvbv5/crc32.h
similarity index 100%
rename from lib/libdvbv5/crc32.h
rename to lib/include/libdvbv5/crc32.h
diff --git a/lib/libdvbv5/Makefile.am b/lib/libdvbv5/Makefile.am
index df67544..ce3f806 100644
--- a/lib/libdvbv5/Makefile.am
+++ b/lib/libdvbv5/Makefile.am
@@ -6,6 +6,7 @@ otherinclude_HEADERS = \
../include/libdvbv5/dvb-demux.h \
../include/libdvbv5/dvb-v5-std.h \
../include/libdvbv5/dvb-file.h \
+   ../include/libdvbv5/crc32.h \
../include/libdvbv5/dvb-frontend.h \
../include/libdvbv5/dvb-fe.h \
../include/libdvbv5/dvb-sat.h \
diff --git a/lib/libdvbv5/crc32.c b/lib/libdvbv5/crc32.c
index f14dbe1..69d0be3 100644
--- a/lib/libdvbv5/crc32.c
+++ b/lib/libdvbv5/crc32.c
@@ -19,7 +19,7 @@
  *
  */
 
-#include crc32.h
+#include libdvbv5/crc32.h
 
 static uint32_t crctab[256] = {
   0x, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
diff --git a/lib/libdvbv5/dvb-scan.c b/lib/libdvbv5/dvb-scan.c
index b0636b9..e55 100644
--- a/lib/libdvbv5/dvb-scan.c
+++ b/lib/libdvbv5/dvb-scan.c
@@ -42,7 +42,7 @@
 #include libdvbv5/dvb-frontend.h
 #include libdvbv5/descriptors.h
 #include parse_string.h
-#include crc32.h
+#include libdvbv5/crc32.h
 #include libdvbv5/dvb-fe.h
 #include libdvbv5/dvb-file.h
 #include libdvbv5/dvb-scan.h
-- 
1.7.10.4

--
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 5/7] libdvbv5: cleanup table parsers

2014-04-09 Thread André Roth
- make the code look similar
- check for correct table ID
- ignore null packets with ID 0x1fff
- return table length, or:
- return error code on error
- update / fix Copyrights

Signed-off-by: André Roth neol...@gmail.com
---
 lib/include/libdvbv5/atsc_eit.h |1 -
 lib/include/libdvbv5/descriptors.h  |1 +
 lib/include/libdvbv5/eit.h  |3 +-
 lib/include/libdvbv5/mgt.h  |1 -
 lib/include/libdvbv5/nit.h  |2 +-
 lib/include/libdvbv5/pat.h  |4 +-
 lib/include/libdvbv5/sdt.h  |5 +-
 lib/include/libdvbv5/vct.h  |1 -
 lib/libdvbv5/descriptors.c  |9 +++-
 lib/libdvbv5/descriptors/atsc_eit.c |   35 +++--
 lib/libdvbv5/descriptors/cat.c  |   53 +--
 lib/libdvbv5/descriptors/eit.c  |   90 +
 lib/libdvbv5/descriptors/mgt.c  |   43 +---
 lib/libdvbv5/descriptors/nit.c  |   71 ++
 lib/libdvbv5/descriptors/pat.c  |   73 ---
 lib/libdvbv5/descriptors/pmt.c  |   95 ++-
 lib/libdvbv5/descriptors/sdt.c  |   68 ++---
 lib/libdvbv5/descriptors/vct.c  |   35 +
 18 files changed, 374 insertions(+), 216 deletions(-)

diff --git a/lib/include/libdvbv5/atsc_eit.h b/lib/include/libdvbv5/atsc_eit.h
index 8b093de..93d9304 100644
--- a/lib/include/libdvbv5/atsc_eit.h
+++ b/lib/include/libdvbv5/atsc_eit.h
@@ -26,7 +26,6 @@
 #include time.h
 
 #include libdvbv5/atsc_header.h
-#include libdvbv5/descriptors.h
 
 #define ATSC_TABLE_EIT0xCB
 
diff --git a/lib/include/libdvbv5/descriptors.h 
b/lib/include/libdvbv5/descriptors.h
index e81a05d..d08ab3e 100644
--- a/lib/include/libdvbv5/descriptors.h
+++ b/lib/include/libdvbv5/descriptors.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2011-2012 - Mauro Carvalho Chehab
+ * Copyright (c) 2012-2014 - Andre Roth neol...@gmail.com
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/lib/include/libdvbv5/eit.h b/lib/include/libdvbv5/eit.h
index fb5ce33..c959537 100644
--- a/lib/include/libdvbv5/eit.h
+++ b/lib/include/libdvbv5/eit.h
@@ -27,7 +27,6 @@
 #include time.h
 
 #include libdvbv5/header.h
-#include libdvbv5/descriptors.h
 
 #define DVB_TABLE_EIT0x4E
 #define DVB_TABLE_EIT_OTHER  0x4F
@@ -47,7 +46,7 @@ struct dvb_table_eit_event {
union {
uint16_t bitfield2;
struct {
-   uint16_t section_length:12;
+   uint16_t desc_length:12;
uint16_t free_CA_mode:1;
uint16_t running_status:3;
} __attribute__((packed));
diff --git a/lib/include/libdvbv5/mgt.h b/lib/include/libdvbv5/mgt.h
index cb8d63a..d67ad33 100644
--- a/lib/include/libdvbv5/mgt.h
+++ b/lib/include/libdvbv5/mgt.h
@@ -25,7 +25,6 @@
 #include unistd.h /* ssize_t */
 
 #include libdvbv5/atsc_header.h
-#include libdvbv5/descriptors.h
 
 #define ATSC_TABLE_MGT 0xC7
 
diff --git a/lib/include/libdvbv5/nit.h b/lib/include/libdvbv5/nit.h
index 7477bd6..fdea7a7 100644
--- a/lib/include/libdvbv5/nit.h
+++ b/lib/include/libdvbv5/nit.h
@@ -46,7 +46,7 @@ struct dvb_table_nit_transport {
union {
uint16_t bitfield;
struct {
-   uint16_t section_length:12;
+   uint16_t desc_length:12;
uint16_t reserved:4;
} __attribute__((packed));
} __attribute__((packed));
diff --git a/lib/include/libdvbv5/pat.h b/lib/include/libdvbv5/pat.h
index cd99d3e..eb4aeef 100644
--- a/lib/include/libdvbv5/pat.h
+++ b/lib/include/libdvbv5/pat.h
@@ -27,8 +27,8 @@
 
 #include libdvbv5/header.h
 
-#define DVB_TABLE_PAT  0
-#define DVB_TABLE_PAT_PID  0
+#define DVB_TABLE_PAT  0x00
+#define DVB_TABLE_PAT_PID  0x
 
 struct dvb_table_pat_program {
uint16_t service_id;
diff --git a/lib/include/libdvbv5/sdt.h b/lib/include/libdvbv5/sdt.h
index f1503ea..9684fbc 100644
--- a/lib/include/libdvbv5/sdt.h
+++ b/lib/include/libdvbv5/sdt.h
@@ -26,11 +26,10 @@
 #include unistd.h /* ssize_t */
 
 #include libdvbv5/header.h
-#include libdvbv5/descriptors.h
 
 #define DVB_TABLE_SDT  0x42
 #define DVB_TABLE_SDT2 0x46
-#define DVB_TABLE_SDT_PID  0x11
+#define DVB_TABLE_SDT_PID  0x0011
 
 struct dvb_table_sdt_service {
uint16_t service_id;
@@ -40,7 +39,7 @@ struct dvb_table_sdt_service {
union {
uint16_t bitfield;
struct {
-   uint16_t section_length:12;
+   uint16_t desc_length:12;
uint16_t free_CA_mode:1;
uint16_t running_status:3;
} __attribute__((packed));
diff --git a/lib/include/libdvbv5/vct.h b/lib/include/libdvbv5/vct.h
index 83bad06..10ac301 100644

Re: [RFC PATCH 0/2] managed token devres interfaces

2014-04-09 Thread Shuah Khan

On 04/09/2014 01:17 PM, Greg KH wrote:

On Wed, Apr 09, 2014 at 09:21:06AM -0600, Shuah Khan wrote:




Test Cases for token devres interfaces: (passed)
  - Create, lock, unlock, and destroy sequence.
  - Try lock while it is locked. Returns -EBUSY as expected.
  - Try lock after destroy. Returns -ENODEV as expected.
  - Unlock while it is unlocked. Returns 0 as expected. This is a no-op.
  - Try unlock after destroy. Returns -ENODEV as expected.


Any chance you can add these test cases as part of the kernel code so
it lives here for any future changes?


Yes. I am planning to add these test cases to the kernel to serve as 
regression tests when these interfaces change. I have to add these in a 
driver framework, i.e I might need to create dummy driver perhaps. I 
haven't given it much thought on how, but I do plan to add tests.





Special notes for Mauro Chehab:
  - Please evaluate if these token devres interfaces cover all media driver
use-cases. If not what is needed to cover them.
  - For use-case testing, I generated a string from em28xx device, as this
is common for all em28xx extensions: (hope this holds true when em28xx
uses snd-usb-audio
  - Construct string with (dev is struct em28xx *dev)
format: tuner:%s-%s-%d
with the following:
dev_name(dev-udev-dev)
 dev-udev-bus-bus_name
 dev-tuner_addr
  - I added test code to em28xx_card_setup() to test the interfaces:
example token from this test code generated with the format above:


What would the driver changes look like to take advantage of these new
functions?



I am working on changes to em28xx driver to create and lock/unlock tuner 
token when it starts analog/digital video streaming. I should have a 
patch ready in a day or two.


thanks,
-- Shuah


--
Shuah Khan
Senior Linux Kernel Developer - Open Source Group
Samsung Research America(Silicon Valley)
shuah...@samsung.com | (970) 672-0658
--
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 2/2] dma-buf: update exp_name when using dma_buf_export()

2014-04-09 Thread Javier Martinez Canillas
commit c0b00a5 (dma-buf: update debugfs output) modified the
default exporter name to be the KBUILD_MODNAME pre-processor
macro instead of __FILE__ but the documentation was not updated.

Also the Supporting existing mmap interfaces in exporters section
title seems wrong since talks about the interface used by importers.

Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
---
 Documentation/dma-buf-sharing.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/dma-buf-sharing.txt 
b/Documentation/dma-buf-sharing.txt
index 505e711..7d61cef 100644
--- a/Documentation/dma-buf-sharing.txt
+++ b/Documentation/dma-buf-sharing.txt
@@ -66,7 +66,7 @@ The dma_buf buffer sharing API usage contains the following 
steps:
 
Exporting modules which do not wish to provide any specific name may use the
helper define 'dma_buf_export()', with the same arguments as above, but
-   without the last argument; a __FILE__ pre-processor directive will be
+   without the last argument; a KBUILD_MODNAME pre-processor directive will be
inserted in place of 'exp_name' instead.
 
 2. Userspace gets a handle to pass around to potential buffer-users
@@ -352,7 +352,7 @@ Being able to mmap an export dma-buf buffer object has 2 
main use-cases:
 
No special interfaces, userspace simply calls mmap on the dma-buf fd.
 
-2. Supporting existing mmap interfaces in exporters
+2. Supporting existing mmap interfaces in importers
 
Similar to the motivation for kernel cpu access it is again important that
the userspace code of a given importing subsystem can use the same 
interfaces
-- 
1.9.0

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


[PATCH 1/2] dma-buf: fix trivial typo error

2014-04-09 Thread Javier Martinez Canillas
Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
---
 drivers/base/dma-buf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
index ea77701..840c7fa 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -491,7 +491,7 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
  * dma-buf buffer.
  *
  * This function adjusts the passed in vma so that it points at the file of the
- * dma_buf operation. It alsog adjusts the starting pgoff and does bounds
+ * dma_buf operation. It also adjusts the starting pgoff and does bounds
  * checking on the size of the vma. Then it calls the exporters mmap function 
to
  * set up the mapping.
  *
-- 
1.9.0

--
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] staging: rtl2832_sdr: fixup checkpatch/style issues

2014-04-09 Thread Anthony DeStefano
rtl2832_sdr.c: fixup checkpatch issues about long lines

Signed-off-by: Anthony DeStefano a...@fastmail.fm
---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index 104ee8a..0e6c6fa 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -935,7 +935,9 @@ static int rtl2832_sdr_set_tuner_freq(struct 
rtl2832_sdr_state *s)
/*
 * bandwidth (Hz)
 */
-   bandwidth_auto = v4l2_ctrl_find(s-hdl, 
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);
+   bandwidth_auto = v4l2_ctrl_find(s-hdl,
+   V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);
+
bandwidth = v4l2_ctrl_find(s-hdl, V4L2_CID_RF_TUNER_BANDWIDTH);
if (v4l2_ctrl_g_ctrl(bandwidth_auto)) {
c-bandwidth_hz = s-f_adc;
@@ -1332,9 +1334,11 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
/* Round towards the closest legal value */
s32 val = s-f_adc + s-bandwidth-step / 2;
u32 offset;
-   val = clamp(val, s-bandwidth-minimum, 
s-bandwidth-maximum);
+   val = clamp(val, s-bandwidth-minimum,
+   s-bandwidth-maximum);
offset = val - s-bandwidth-minimum;
-   offset = s-bandwidth-step * (offset / 
s-bandwidth-step);
+   offset = s-bandwidth-step *
+   (offset / s-bandwidth-step);
s-bandwidth-val = s-bandwidth-minimum + offset;
}
 
@@ -1423,15 +1427,20 @@ struct dvb_frontend *rtl2832_sdr_attach(struct 
dvb_frontend *fe,
break;
case RTL2832_TUNER_R820T:
v4l2_ctrl_handler_init(s-hdl, 2);
-   s-bandwidth_auto = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
-   s-bandwidth = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_RF_TUNER_BANDWIDTH, 0, 800, 10, 0);
+   s-bandwidth_auto = v4l2_ctrl_new_std(s-hdl, ops,
+   V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
+   s-bandwidth = v4l2_ctrl_new_std(s-hdl, ops,
+   V4L2_CID_RF_TUNER_BANDWIDTH, 0, 800, 10, 0);
v4l2_ctrl_auto_cluster(2, s-bandwidth_auto, 0, false);
break;
case RTL2832_TUNER_FC0012:
case RTL2832_TUNER_FC0013:
v4l2_ctrl_handler_init(s-hdl, 2);
-   s-bandwidth_auto = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
-   s-bandwidth = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_RF_TUNER_BANDWIDTH, 600, 800, 100, 600);
+   s-bandwidth_auto = v4l2_ctrl_new_std(s-hdl, ops,
+   V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
+   s-bandwidth = v4l2_ctrl_new_std(s-hdl, ops,
+   V4L2_CID_RF_TUNER_BANDWIDTH, 600, 800, 100,
+   600);
v4l2_ctrl_auto_cluster(2, s-bandwidth_auto, 0, false);
break;
default:
-- 
1.9.0

--
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: [REVIEWv2 PATCH 04/13] vb2: use correct prefix

2014-04-09 Thread Pawel Osciak
On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 Many dprintk's in vb2 use a hardcoded prefix with the function name. In
 many cases that is now outdated. To keep things consistent the dprintk
 macro has been changed to print the function name in addition to the vb2:
 prefix. Superfluous prefixes elsewhere in the code have been removed.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Pawel Osciak pa...@osciak.com

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 133 
 +++
  1 file changed, 65 insertions(+), 68 deletions(-)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index b2582cb..1421075 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -27,10 +27,10 @@
  static int debug;
  module_param(debug, int, 0644);

 -#define dprintk(level, fmt, arg...)\
 -   do {\
 -   if (debug = level) \
 -   printk(KERN_DEBUG vb2:  fmt, ## arg); \
 +#define dprintk(level, fmt, arg...)  
 \
 +   do {  
 \
 +   if (debug = level)   
 \
 +   pr_debug(vb2: %s:  fmt, __func__, ## arg); \
 } while (0)

  #ifdef CONFIG_VIDEO_ADV_DEBUG
 @@ -371,7 +371,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned 
 int buffers)
 if (q-bufs[buffer] == NULL)
 continue;
 if (q-bufs[buffer]-state == VB2_BUF_STATE_PREPARING) {
 -   dprintk(1, reqbufs: preparing buffers, cannot 
 free\n);
 +   dprintk(1, preparing buffers, cannot free\n);
 return -EAGAIN;
 }
 }
 @@ -656,12 +656,12 @@ int vb2_querybuf(struct vb2_queue *q, struct 
 v4l2_buffer *b)
 int ret;

 if (b-type != q-type) {
 -   dprintk(1, querybuf: wrong buffer type\n);
 +   dprintk(1, wrong buffer type\n);
 return -EINVAL;
 }

 if (b-index = q-num_buffers) {
 -   dprintk(1, querybuf: buffer index out of range\n);
 +   dprintk(1, buffer index out of range\n);
 return -EINVAL;
 }
 vb = q-bufs[b-index];
 @@ -721,12 +721,12 @@ static int __verify_memory_type(struct vb2_queue *q,
  {
 if (memory != V4L2_MEMORY_MMAP  memory != V4L2_MEMORY_USERPTR 
 memory != V4L2_MEMORY_DMABUF) {
 -   dprintk(1, reqbufs: unsupported memory type\n);
 +   dprintk(1, unsupported memory type\n);
 return -EINVAL;
 }

 if (type != q-type) {
 -   dprintk(1, reqbufs: requested type is incorrect\n);
 +   dprintk(1, requested type is incorrect\n);
 return -EINVAL;
 }

 @@ -735,17 +735,17 @@ static int __verify_memory_type(struct vb2_queue *q,
  * are available.
  */
 if (memory == V4L2_MEMORY_MMAP  __verify_mmap_ops(q)) {
 -   dprintk(1, reqbufs: MMAP for current setup unsupported\n);
 +   dprintk(1, MMAP for current setup unsupported\n);
 return -EINVAL;
 }

 if (memory == V4L2_MEMORY_USERPTR  __verify_userptr_ops(q)) {
 -   dprintk(1, reqbufs: USERPTR for current setup 
 unsupported\n);
 +   dprintk(1, USERPTR for current setup unsupported\n);
 return -EINVAL;
 }

 if (memory == V4L2_MEMORY_DMABUF  __verify_dmabuf_ops(q)) {
 -   dprintk(1, reqbufs: DMABUF for current setup unsupported\n);
 +   dprintk(1, DMABUF for current setup unsupported\n);
 return -EINVAL;
 }

 @@ -755,7 +755,7 @@ static int __verify_memory_type(struct vb2_queue *q,
  * do the memory and type validation.
  */
 if (q-fileio) {
 -   dprintk(1, reqbufs: file io in progress\n);
 +   dprintk(1, file io in progress\n);
 return -EBUSY;
 }
 return 0;
 @@ -790,7 +790,7 @@ static int __reqbufs(struct vb2_queue *q, struct 
 v4l2_requestbuffers *req)
 int ret;

 if (q-streaming) {
 -   dprintk(1, reqbufs: streaming active\n);
 +   dprintk(1, streaming active\n);
 return -EBUSY;
 }

 @@ -800,7 +800,7 @@ static int __reqbufs(struct vb2_queue *q, struct 
 v4l2_requestbuffers *req)
  * are not in use and can be freed.
  */
 if (q-memory == V4L2_MEMORY_MMAP  __buffers_in_use(q)) {
 -   dprintk(1, 

Re: [REVIEWv2 PATCH 02/13] vb2: fix handling of data_offset and v4l2_plane.reserved[]

2014-04-09 Thread Pawel Osciak
Looks good to me, just a small nit below.


On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 The videobuf2-core did not zero the 'planes' array in __qbuf_userptr()
 and __qbuf_dmabuf(). That's now memset to 0. Without this the reserved
 array in struct v4l2_plane would be non-zero, causing v4l2-compliance
 errors.

 More serious is the fact that data_offset was not handled correctly:

 - for capture devices it was never zeroed, which meant that it was
   uninitialized. Unless the driver sets it it was a completely random
   number. With the memset above this is now fixed.

 - __qbuf_dmabuf had a completely incorrect length check that included
   data_offset.

 - in __fill_vb2_buffer in the DMABUF case the data_offset field was
   unconditionally copied from v4l2_buffer to v4l2_plane when this
   should only happen in the output case.

 - in the single-planar case data_offset was never correctly set to 0.
   The single-planar API doesn't support data_offset, so setting it
   to 0 is the right thing to do. This too is now solved by the memset.

 All these issues were found with v4l2-compliance.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Pawel Osciak pa...@osciak.com

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 13 -
  1 file changed, 4 insertions(+), 9 deletions(-)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index f9059bb..596998e 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -1169,8 +1169,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
 b-m.planes[plane].m.fd;
 v4l2_planes[plane].length =
 b-m.planes[plane].length;
 -   v4l2_planes[plane].data_offset =
 -   b-m.planes[plane].data_offset;
 }
 }
 } else {
 @@ -1180,10 +1178,8 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
  * In videobuf we use our internal V4l2_planes struct for
  * single-planar buffers as well, for simplicity.
  */
 -   if (V4L2_TYPE_IS_OUTPUT(b-type)) {
 +   if (V4L2_TYPE_IS_OUTPUT(b-type))
 v4l2_planes[0].bytesused = b-bytesused;
 -   v4l2_planes[0].data_offset = 0;
 -   }

 if (b-memory == V4L2_MEMORY_USERPTR) {
 v4l2_planes[0].m.userptr = b-m.userptr;
 @@ -1193,9 +1189,7 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, 
 const struct v4l2_buffer *b
 if (b-memory == V4L2_MEMORY_DMABUF) {
 v4l2_planes[0].m.fd = b-m.fd;
 v4l2_planes[0].length = b-length;
 -   v4l2_planes[0].data_offset = 0;
 }
 -
 }

 /* Zero flags that the vb2 core handles */
 @@ -1238,6 +1232,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const 
 struct v4l2_buffer *b)
 int write = !V4L2_TYPE_IS_OUTPUT(q-type);
 bool reacquired = vb-planes[0].mem_priv == NULL;

 +   memset(planes, 0, sizeof(planes[0]) * vb-num_planes);

memset(planes, 0, sizeof(planes));

 /* Copy relevant information provided by the userspace */
 __fill_vb2_buffer(vb, b, planes);

 @@ -1357,6 +1352,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const 
 struct v4l2_buffer *b)
 int write = !V4L2_TYPE_IS_OUTPUT(q-type);
 bool reacquired = vb-planes[0].mem_priv == NULL;

 +   memset(planes, 0, sizeof(planes[0]) * vb-num_planes);

memset(planes, 0, sizeof(planes));

 /* Copy relevant information provided by the userspace */
 __fill_vb2_buffer(vb, b, planes);

 @@ -1374,8 +1370,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const 
 struct v4l2_buffer *b)
 if (planes[plane].length == 0)
 planes[plane].length = dbuf-size;

 -   if (planes[plane].length  planes[plane].data_offset +
 -   q-plane_sizes[plane]) {
 +   if (planes[plane].length  q-plane_sizes[plane]) {
 dprintk(1, qbuf: invalid dmabuf length for plane 
 %d\n,
 plane);
 ret = -EINVAL;
 --
 1.9.1




-- 
Best regards,
Pawel Osciak
--
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: [REVIEWv2 PATCH 06/13] vb2: set timestamp when using write()

2014-04-09 Thread Pawel Osciak
I see. Ack, but please add a comment about this in the code.

On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 When using write() to write data to an output video node the vb2 core
 should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody
 else is able to provide this information with the write() operation.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Pawel Osciak pa...@osciak.com

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

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 2e448a7..b7de6be 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -22,6 +22,7 @@
  #include media/v4l2-dev.h
  #include media/v4l2-fh.h
  #include media/v4l2-event.h
 +#include media/v4l2-common.h
  #include media/videobuf2-core.h

  static int debug;
 @@ -2751,6 +2752,9 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
 char __user *data, size_
  {
 struct vb2_fileio_data *fileio;
 struct vb2_fileio_buf *buf;
 +   bool set_timestamp = !read 
 +   (q-timestamp_flags  V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
 +   V4L2_BUF_FLAG_TIMESTAMP_COPY;

Please add an explicit comment why we are doing this here in the code.

 int ret, index;

 dprintk(3, mode %s, offset %ld, count %zd, %sblocking\n,
 @@ -2852,6 +2856,8 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, 
 char __user *data, size_
 fileio-b.memory = q-memory;
 fileio-b.index = index;
 fileio-b.bytesused = buf-pos;
 +   if (set_timestamp)
 +   v4l2_get_timestamp(fileio-b.timestamp);
 ret = vb2_internal_qbuf(q, fileio-b);
 dprintk(5, vb2_dbuf result: %d\n, ret);
 if (ret)
 --
 1.9.1




-- 
Best regards,
Pawel Osciak
--
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: [REVIEWv2 PATCH 07/13] vb2: reject output buffers with V4L2_FIELD_ALTERNATE

2014-04-09 Thread Pawel Osciak
On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 This is not allowed by the spec and does in fact not make any sense.
 Return -EINVAL if this is the case.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Pawel Osciak pa...@osciak.com

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

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index b7de6be..c662ad9 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -1511,6 +1511,19 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
 struct v4l2_buffer *b)
 dprintk(1, plane parameters verification failed: %d\n, ret);
 return ret;
 }
 +   if (b-field == V4L2_FIELD_ALTERNATE  V4L2_TYPE_IS_OUTPUT(q-type)) 
 {
 +   /*
 +* If the format's field is ALTERNATE, then the buffer's field
 +* should be either TOP or BOTTOM, not ALTERNATE since that
 +* makes no sense. The driver has to know whether the
 +* buffer represents a top or a bottom field in order to
 +* program any DMA correctly. Using ALTERNATE is wrong, since
 +* that just says that it is either a top or a bottom field,
 +* but not which of the two it is.
 +*/
 +   dprintk(1, the field is incorrectly set to ALTERNATE for an 
 output buffer\n);
 +   return -EINVAL;
 +   }

 vb-state = VB2_BUF_STATE_PREPARING;
 vb-v4l2_buf.timestamp.tv_sec = 0;
 --
 1.9.1




-- 
Best regards,
Pawel Osciak
--
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: [REVIEWv2 PATCH 04/13] vb2: use correct prefix

2014-04-09 Thread Pawel Osciak
On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 Many dprintk's in vb2 use a hardcoded prefix with the function name. In
 many cases that is now outdated. To keep things consistent the dprintk
 macro has been changed to print the function name in addition to the vb2:
 prefix. Superfluous prefixes elsewhere in the code have been removed.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com
 ---
  drivers/media/v4l2-core/videobuf2-core.c | 133 
 +++
  1 file changed, 65 insertions(+), 68 deletions(-)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index b2582cb..1421075 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -27,10 +27,10 @@
  static int debug;
  module_param(debug, int, 0644);

 -#define dprintk(level, fmt, arg...)\
 -   do {\
 -   if (debug = level) \
 -   printk(KERN_DEBUG vb2:  fmt, ## arg); \
 +#define dprintk(level, fmt, arg...)  
 \
 +   do {  
 \
 +   if (debug = level)   
 \
 +   pr_debug(vb2: %s:  fmt, __func__, ## arg); \
 } while (0)

  #ifdef CONFIG_VIDEO_ADV_DEBUG
 @@ -371,7 +371,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned 
 int buffers)
 if (q-bufs[buffer] == NULL)
 continue;
 if (q-bufs[buffer]-state == VB2_BUF_STATE_PREPARING) {
 -   dprintk(1, reqbufs: preparing buffers, cannot 
 free\n);
 +   dprintk(1, preparing buffers, cannot free\n);
 return -EAGAIN;
 }
 }
 @@ -656,12 +656,12 @@ int vb2_querybuf(struct vb2_queue *q, struct 
 v4l2_buffer *b)
 int ret;

 if (b-type != q-type) {
 -   dprintk(1, querybuf: wrong buffer type\n);
 +   dprintk(1, wrong buffer type\n);
 return -EINVAL;
 }

 if (b-index = q-num_buffers) {
 -   dprintk(1, querybuf: buffer index out of range\n);
 +   dprintk(1, buffer index out of range\n);
 return -EINVAL;
 }
 vb = q-bufs[b-index];
 @@ -721,12 +721,12 @@ static int __verify_memory_type(struct vb2_queue *q,
  {
 if (memory != V4L2_MEMORY_MMAP  memory != V4L2_MEMORY_USERPTR 
 memory != V4L2_MEMORY_DMABUF) {
 -   dprintk(1, reqbufs: unsupported memory type\n);
 +   dprintk(1, unsupported memory type\n);
 return -EINVAL;
 }

 if (type != q-type) {
 -   dprintk(1, reqbufs: requested type is incorrect\n);
 +   dprintk(1, requested type is incorrect\n);
 return -EINVAL;
 }

 @@ -735,17 +735,17 @@ static int __verify_memory_type(struct vb2_queue *q,
  * are available.
  */
 if (memory == V4L2_MEMORY_MMAP  __verify_mmap_ops(q)) {
 -   dprintk(1, reqbufs: MMAP for current setup unsupported\n);
 +   dprintk(1, MMAP for current setup unsupported\n);
 return -EINVAL;
 }

 if (memory == V4L2_MEMORY_USERPTR  __verify_userptr_ops(q)) {
 -   dprintk(1, reqbufs: USERPTR for current setup 
 unsupported\n);
 +   dprintk(1, USERPTR for current setup unsupported\n);
 return -EINVAL;
 }

 if (memory == V4L2_MEMORY_DMABUF  __verify_dmabuf_ops(q)) {
 -   dprintk(1, reqbufs: DMABUF for current setup unsupported\n);
 +   dprintk(1, DMABUF for current setup unsupported\n);
 return -EINVAL;
 }

 @@ -755,7 +755,7 @@ static int __verify_memory_type(struct vb2_queue *q,
  * do the memory and type validation.
  */
 if (q-fileio) {
 -   dprintk(1, reqbufs: file io in progress\n);
 +   dprintk(1, file io in progress\n);
 return -EBUSY;
 }
 return 0;
 @@ -790,7 +790,7 @@ static int __reqbufs(struct vb2_queue *q, struct 
 v4l2_requestbuffers *req)
 int ret;

 if (q-streaming) {
 -   dprintk(1, reqbufs: streaming active\n);
 +   dprintk(1, streaming active\n);
 return -EBUSY;
 }

 @@ -800,7 +800,7 @@ static int __reqbufs(struct vb2_queue *q, struct 
 v4l2_requestbuffers *req)
  * are not in use and can be freed.
  */
 if (q-memory == V4L2_MEMORY_MMAP  __buffers_in_use(q)) {
 -   dprintk(1, reqbufs: memory in use, cannot free\n);
 +   

Re: [REVIEWv2 PATCH 09/13] vb2: add vb2_fileio_is_active and check it more often

2014-04-09 Thread Pawel Osciak
On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 Added a vb2_fileio_is_active inline function that returns true if fileio
 is in progress. Check for this too in mmap() (you don't want apps mmap()ing
 buffers used by fileio) and expbuf() (same reason).

 In addition drivers should be able to check for this in queue_setup() to
 return an error if an attempt is made to read() or write() with
 V4L2_FIELD_ALTERNATE being configured. This is illegal (there is no way
 to pass the TOP/BOTTOM information around using file I/O).

 However, in order to be able to check for this the init_fileio function
 needs to set q-fileio early on, before the buffers are allocated. So switch
 to using internal functions (__reqbufs, vb2_internal_qbuf and
 vb2_internal_streamon) to skip the fileio check. Well, that's why the internal
 functions were created...

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Pawel Osciak pa...@osciak.com

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 39 
 
  include/media/videobuf2-core.h   | 17 ++
  2 files changed, 41 insertions(+), 15 deletions(-)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 89147d2..08152dd 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -755,7 +755,7 @@ static int __verify_memory_type(struct vb2_queue *q,
  * create_bufs is called with count == 0, but count == 0 should still
  * do the memory and type validation.
  */
 -   if (q-fileio) {
 +   if (vb2_fileio_is_active(q)) {
 dprintk(1, file io in progress\n);
 return -EBUSY;
 }
 @@ -1617,7 +1617,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct 
 v4l2_buffer *b)
 struct vb2_buffer *vb;
 int ret;

 -   if (q-fileio) {
 +   if (vb2_fileio_is_active(q)) {
 dprintk(1, file io in progress\n);
 return -EBUSY;
 }
 @@ -1786,7 +1786,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, 
 struct v4l2_buffer *b)
   */
  int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
  {
 -   if (q-fileio) {
 +   if (vb2_fileio_is_active(q)) {
 dprintk(1, file io in progress\n);
 return -EBUSY;
 }
 @@ -2006,7 +2006,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, 
 struct v4l2_buffer *b, bool n
   */
  int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking)
  {
 -   if (q-fileio) {
 +   if (vb2_fileio_is_active(q)) {
 dprintk(1, file io in progress\n);
 return -EBUSY;
 }
 @@ -2136,7 +2136,7 @@ static int vb2_internal_streamon(struct vb2_queue *q, 
 enum v4l2_buf_type type)
   */
  int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
  {
 -   if (q-fileio) {
 +   if (vb2_fileio_is_active(q)) {
 dprintk(1, file io in progress\n);
 return -EBUSY;
 }
 @@ -2183,7 +2183,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, 
 enum v4l2_buf_type type)
   */
  int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
  {
 -   if (q-fileio) {
 +   if (vb2_fileio_is_active(q)) {
 dprintk(1, file io in progress\n);
 return -EBUSY;
 }
 @@ -2268,6 +2268,11 @@ int vb2_expbuf(struct vb2_queue *q, struct 
 v4l2_exportbuffer *eb)
 return -EINVAL;
 }

 +   if (vb2_fileio_is_active(q)) {
 +   dprintk(1, expbuf: file io in progress\n);
 +   return -EBUSY;
 +   }
 +
 vb_plane = vb-planes[eb-plane];

 dbuf = call_memop(vb, get_dmabuf, vb_plane-mem_priv, eb-flags  
 O_ACCMODE);
 @@ -2344,6 +2349,10 @@ int vb2_mmap(struct vb2_queue *q, struct 
 vm_area_struct *vma)
 return -EINVAL;
 }
 }
 +   if (vb2_fileio_is_active(q)) {
 +   dprintk(1, mmap: file io in progress\n);
 +   return -EBUSY;
 +   }

 /*
  * Find the plane corresponding to the offset passed by userspace.
 @@ -2455,7 +2464,7 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file 
 *file, poll_table *wait)
 /*
  * Start file I/O emulator only if streaming API has not been used 
 yet.
  */
 -   if (q-num_buffers == 0  q-fileio == NULL) {
 +   if (q-num_buffers == 0  !vb2_fileio_is_active(q)) {
 if (!V4L2_TYPE_IS_OUTPUT(q-type)  (q-io_modes  VB2_READ) 
 
 (req_events  (POLLIN | POLLRDNORM))) {
 if (__vb2_init_fileio(q, 1))
 @@ -2660,7 +2669,8 @@ static int __vb2_init_fileio(struct vb2_queue *q, int 
 read)
 fileio-req.count = count;
 fileio-req.memory = V4L2_MEMORY_MMAP;
 fileio-req.type = 

Re: [REVIEWv2 PATCH 10/13] vb2: set v4l2_buffer.bytesused to 0 for mp buffers

2014-04-09 Thread Pawel Osciak
On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 The bytesused field of struct v4l2_buffer is not used for multiplanar
 formats, so just zero it to prevent it from having some random value.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Pawel Osciak pa...@osciak.com

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 1 +
  1 file changed, 1 insertion(+)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 08152dd..ef7ef82 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -582,6 +582,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
 struct v4l2_buffer *b)
  * for it. The caller has already verified memory and size.
  */
 b-length = vb-num_planes;
 +   b-bytesused = 0;
 memcpy(b-m.planes, vb-v4l2_planes,
 b-length * sizeof(struct v4l2_plane));
 } else {
 --
 1.9.1




-- 
Best regards,
Pawel Osciak
--
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: [REVIEWv2 PATCH 10/13] vb2: set v4l2_buffer.bytesused to 0 for mp buffers

2014-04-09 Thread Pawel Osciak
Ah, alas, Sakari is right. This should not be needed, since we memcpy
vb-v4l2_buf to this, also overwriting bytesused.

On Thu, Apr 10, 2014 at 10:08 AM, Pawel Osciak pa...@osciak.com wrote:
 On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 The bytesused field of struct v4l2_buffer is not used for multiplanar
 formats, so just zero it to prevent it from having some random value.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

 Acked-by: Pawel Osciak pa...@osciak.com

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 1 +
  1 file changed, 1 insertion(+)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index 08152dd..ef7ef82 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -582,6 +582,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
 struct v4l2_buffer *b)
  * for it. The caller has already verified memory and size.
  */
 b-length = vb-num_planes;
 +   b-bytesused = 0;
 memcpy(b-m.planes, vb-v4l2_planes,
 b-length * sizeof(struct v4l2_plane));
 } else {
 --
 1.9.1




 --
 Best regards,
 Pawel Osciak



-- 
Best regards,
Pawel Osciak
--
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: [REVIEWv2 PATCH 12/13] vb2: start messages with a lower-case for consistency.

2014-04-09 Thread Pawel Osciak
On Mon, Apr 7, 2014 at 10:11 PM, Hans Verkuil hverk...@xs4all.nl wrote:
 From: Hans Verkuil hans.verk...@cisco.com

 The kernel debug messages produced by vb2 started either with a
 lower or an upper case character. Switched all to use lower-case
 which seemed to be what was used in the majority of the messages.

 Signed-off-by: Hans Verkuil hans.verk...@cisco.com

Acked-by: Pawel Osciak pa...@osciak.com

 ---
  drivers/media/v4l2-core/videobuf2-core.c | 58 
 
  1 file changed, 29 insertions(+), 29 deletions(-)

 diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
 b/drivers/media/v4l2-core/videobuf2-core.c
 index d33c69b..e79d70c 100644
 --- a/drivers/media/v4l2-core/videobuf2-core.c
 +++ b/drivers/media/v4l2-core/videobuf2-core.c
 @@ -151,7 +151,7 @@ static void __vb2_buf_mem_free(struct vb2_buffer *vb)
 for (plane = 0; plane  vb-num_planes; ++plane) {
 call_memop(vb, put, vb-planes[plane].mem_priv);
 vb-planes[plane].mem_priv = NULL;
 -   dprintk(3, Freed plane %d of buffer %d\n, plane,
 +   dprintk(3, freed plane %d of buffer %d\n, plane,
 vb-v4l2_buf.index);
 }
  }
 @@ -246,7 +246,7 @@ static void __setup_offsets(struct vb2_queue *q, unsigned 
 int n)
 for (plane = 0; plane  vb-num_planes; ++plane) {
 vb-v4l2_planes[plane].m.mem_offset = off;

 -   dprintk(3, Buffer %d, plane %d offset 0x%08lx\n,
 +   dprintk(3, buffer %d, plane %d offset 0x%08lx\n,
 buffer, plane, off);

 off += vb-v4l2_planes[plane].length;
 @@ -273,7 +273,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum 
 v4l2_memory memory,
 /* Allocate videobuf buffer structures */
 vb = kzalloc(q-buf_struct_size, GFP_KERNEL);
 if (!vb) {
 -   dprintk(1, Memory alloc for buffer struct failed\n);
 +   dprintk(1, memory alloc for buffer struct failed\n);
 break;
 }

 @@ -292,7 +292,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum 
 v4l2_memory memory,
 if (memory == V4L2_MEMORY_MMAP) {
 ret = __vb2_buf_mem_alloc(vb);
 if (ret) {
 -   dprintk(1, Failed allocating memory for 
 +   dprintk(1, failed allocating memory for 
 buffer %d\n, buffer);
 kfree(vb);
 break;
 @@ -304,7 +304,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum 
 v4l2_memory memory,
  */
 ret = call_vb_qop(vb, buf_init, vb);
 if (ret) {
 -   dprintk(1, Buffer %d %p initialization
 +   dprintk(1, buffer %d %p initialization
  failed\n, buffer, vb);
 fail_vb_qop(vb, buf_init);
 __vb2_buf_mem_free(vb);
 @@ -320,7 +320,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum 
 v4l2_memory memory,
 if (memory == V4L2_MEMORY_MMAP)
 __setup_offsets(q, buffer);

 -   dprintk(1, Allocated %d buffers, %d plane(s) each\n,
 +   dprintk(1, allocated %d buffers, %d plane(s) each\n,
 buffer, num_planes);

 return buffer;
 @@ -477,13 +477,13 @@ static int __verify_planes_array(struct vb2_buffer *vb, 
 const struct v4l2_buffer

 /* Is memory for copying plane information present? */
 if (NULL == b-m.planes) {
 -   dprintk(1, Multi-planar buffer passed but 
 +   dprintk(1, multi-planar buffer passed but 
planes array not provided\n);
 return -EINVAL;
 }

 if (b-length  vb-num_planes || b-length  VIDEO_MAX_PLANES) {
 -   dprintk(1, Incorrect planes array length, 
 +   dprintk(1, incorrect planes array length, 
expected %d, got %d\n, vb-num_planes, 
 b-length);
 return -EINVAL;
 }
 @@ -847,7 +847,7 @@ static int __reqbufs(struct vb2_queue *q, struct 
 v4l2_requestbuffers *req)
 /* Finally, allocate buffers and video memory */
 allocated_buffers = __vb2_queue_alloc(q, req-memory, num_buffers, 
 num_planes);
 if (allocated_buffers == 0) {
 -   dprintk(1, Memory allocation failed\n);
 +   dprintk(1, memory allocation failed\n);
 return -ENOMEM;
 }

 @@ -960,7 +960,7 @@ static int __create_bufs(struct vb2_queue *q, struct 
 v4l2_create_buffers *create
 allocated_buffers = __vb2_queue_alloc(q, create-memory, 

Re: [PATCH] staging: rtl2832_sdr: fixup checkpatch/style issues

2014-04-09 Thread Greg Kroah-Hartman
On Wed, Apr 09, 2014 at 08:07:28PM -0400, Anthony DeStefano wrote:
 rtl2832_sdr.c: fixup checkpatch issues about long lines
 
 Signed-off-by: Anthony DeStefano a...@fastmail.fm
 ---
  drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 23 ---
  1 file changed, 16 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
 b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
 index 104ee8a..0e6c6fa 100644
 --- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
 +++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
 @@ -935,7 +935,9 @@ static int rtl2832_sdr_set_tuner_freq(struct 
 rtl2832_sdr_state *s)
   /*
* bandwidth (Hz)
*/
 - bandwidth_auto = v4l2_ctrl_find(s-hdl, 
 V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);
 + bandwidth_auto = v4l2_ctrl_find(s-hdl,
 + V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);

Please line stuff up under the (, so for this line it would be:

bandwidth_auto = v4l2_ctrl_find(s-hdl,
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);

Please fix the rest of these all up.

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


[PATCHv2] staging: rtl2832_sdr: fixup checkpatch/style issues

2014-04-09 Thread Anthony DeStefano
rtl2832_sdr.c: fixup checkpatch issues about long lines

Aligned stuff under the ( for this version.

Signed-off-by: Anthony DeStefano a...@fastmail.fm
---
 drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c | 26 +---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c 
b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
index 104ee8a..a9ec75d 100644
--- a/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
+++ b/drivers/staging/media/rtl2832u_sdr/rtl2832_sdr.c
@@ -935,7 +935,8 @@ static int rtl2832_sdr_set_tuner_freq(struct 
rtl2832_sdr_state *s)
/*
 * bandwidth (Hz)
 */
-   bandwidth_auto = v4l2_ctrl_find(s-hdl, 
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);
+   bandwidth_auto = v4l2_ctrl_find(s-hdl,
+   V4L2_CID_RF_TUNER_BANDWIDTH_AUTO);
bandwidth = v4l2_ctrl_find(s-hdl, V4L2_CID_RF_TUNER_BANDWIDTH);
if (v4l2_ctrl_g_ctrl(bandwidth_auto)) {
c-bandwidth_hz = s-f_adc;
@@ -1332,9 +1333,11 @@ static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
/* Round towards the closest legal value */
s32 val = s-f_adc + s-bandwidth-step / 2;
u32 offset;
-   val = clamp(val, s-bandwidth-minimum, 
s-bandwidth-maximum);
+   val = clamp(val, s-bandwidth-minimum,
+   s-bandwidth-maximum);
offset = val - s-bandwidth-minimum;
-   offset = s-bandwidth-step * (offset / 
s-bandwidth-step);
+   offset = s-bandwidth-step *
+   (offset / s-bandwidth-step);
s-bandwidth-val = s-bandwidth-minimum + offset;
}
 
@@ -1423,15 +1426,24 @@ struct dvb_frontend *rtl2832_sdr_attach(struct 
dvb_frontend *fe,
break;
case RTL2832_TUNER_R820T:
v4l2_ctrl_handler_init(s-hdl, 2);
-   s-bandwidth_auto = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
-   s-bandwidth = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_RF_TUNER_BANDWIDTH, 0, 800, 10, 0);
+   s-bandwidth_auto = v4l2_ctrl_new_std(s-hdl, ops,
+ 
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO,
+ 0, 1, 1, 1);
+   s-bandwidth = v4l2_ctrl_new_std(s-hdl, ops,
+V4L2_CID_RF_TUNER_BANDWIDTH,
+0, 800, 10, 0);
v4l2_ctrl_auto_cluster(2, s-bandwidth_auto, 0, false);
break;
case RTL2832_TUNER_FC0012:
case RTL2832_TUNER_FC0013:
v4l2_ctrl_handler_init(s-hdl, 2);
-   s-bandwidth_auto = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
-   s-bandwidth = v4l2_ctrl_new_std(s-hdl, ops, 
V4L2_CID_RF_TUNER_BANDWIDTH, 600, 800, 100, 600);
+   s-bandwidth_auto = v4l2_ctrl_new_std(s-hdl, ops,
+ 
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO,
+ 0, 1, 1, 1);
+   s-bandwidth = v4l2_ctrl_new_std(s-hdl, ops,
+V4L2_CID_RF_TUNER_BANDWIDTH,
+600, 800, 100,
+600);
v4l2_ctrl_auto_cluster(2, s-bandwidth_auto, 0, false);
break;
default:
-- 
1.9.0

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

2014-04-09 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:   Thu Apr 10 04:00:19 CEST 2014
git branch: test
git hash:   a83b93a7480441a47856dc9104bea970e84cda87
gcc version:i686-linux-gcc (GCC) 4.8.2
sparse version: v0.5.0-11-g38d1124
host hardware:  x86_64
host os:3.13-7.slh.1-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: OK
linux-2.6.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12-i686: OK
linux-3.13-i686: OK
linux-3.14-i686: OK
linux-2.6.31.14-x86_64: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12-x86_64: OK
linux-3.13-x86_64: OK
linux-3.14-x86_64: OK
apps: OK
spec-git: OK
sparse version: v0.5.0-11-g38d1124
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Thursday.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