cron job: media_tree daily build: WARNINGS

2015-03-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:   Tue Mar 10 04:00:24 CET 2015
git branch: test
git hash:   3d945be05ac1e806af075e9315bc1b3409adae2b
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-44-g40791b9
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:3.19.0-1.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.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: WARNINGS
linux-3.9.2-i686: WARNINGS
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
linux-3.19-i686: OK
linux-4.0-rc1-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: WARNINGS
linux-3.9.2-x86_64: WARNINGS
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH] Add framescaling support to stk1160

2015-03-09 Thread Ezequiel Garcia
Dale,

Don't forget to Cc the media mailing list. See below.

On Tue, Feb 24, 2015 at 2:33 PM, Dale Hamel  wrote:
> From: Michael Stegemann 
>
> Implements frame scaling support for stk1160 to support format changes 
> instead of a static frame size.
>
> This is effectively a dumb sampling, and could perhaps benefit from being an 
> averaging instead.
>
> This was a requested "TO DO" for this driver, and allows support for 
> userspace programs like Hyperion and Boblight.
>
> Submitted on behalf of the original author, Michael Stegemann 
> 
>
> Signed-off-by: Michael Stegemann 
> Signed-off-by: Dale Hamel 
> ---
>  drivers/media/usb/stk1160/stk1160-core.c  |   1 +
>  drivers/media/usb/stk1160/stk1160-reg.h   |  26 +++
>  drivers/media/usb/stk1160/stk1160-v4l.c   | 112 
> +++---
>  drivers/media/usb/stk1160/stk1160-video.c |  17 -
>  drivers/media/usb/stk1160/stk1160.h   |   1 +
>  5 files changed, 130 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/media/usb/stk1160/stk1160-core.c 
> b/drivers/media/usb/stk1160/stk1160-core.c
> index 03504dc..1881770 100644
> --- a/drivers/media/usb/stk1160/stk1160-core.c
> +++ b/drivers/media/usb/stk1160/stk1160-core.c
> @@ -418,6 +418,7 @@ static void stk1160_disconnect(struct usb_interface 
> *interface)
> stk1160_ac97_unregister(dev);
>
> stk1160_clear_queue(dev);
> +   vb2_queue_release(&dev->vb_vidq);
>

Is this fixing a real bug? Wasn't aware of any leaks in this driver,
but who knows...

> video_unregister_device(&dev->vdev);
> v4l2_device_disconnect(&dev->v4l2_dev);
> diff --git a/drivers/media/usb/stk1160/stk1160-reg.h 
> b/drivers/media/usb/stk1160/stk1160-reg.h
> index 3e49da6..b1fa11d 100644
> --- a/drivers/media/usb/stk1160/stk1160-reg.h
> +++ b/drivers/media/usb/stk1160/stk1160-reg.h
> @@ -33,6 +33,32 @@
>   */
>  #define STK1160_DCTRL  0x100
>
> +/*
> + * Decimation Control Register:
> + * Byte 104:
> + * Horizontal Decimation Line Unit Count
> + * Byte 105:
> + * Vertical   Decimation Line Unit Count
> + * Byte 106:
> + * Bit 0 - Horizontal Decimation Control
> + *  0 Horizontal decimation is disabled.
> + *  1 Horizontal decimation is enabled.
> + * Bit 1 - Decimates Half or More Column
> + *   0 Decimates less than half from original column,
> + * -> send count unit (0x105) before each unit skipped.
> + *   1 Decimates half or more from original column,
> + * -> skip count unit (0x105) before each unit sent.
> + * Bit 2 - Vertical Decimation Control
> + *  see Bit 0, only vertical
> + * Bit 3 - Vertical Greater or Equal to Half
> + *  see Bit 1, only vertical
> + * Bit 4 - Decimation Unit
> + * 0 Decimation will work with 2 rows or columns per unit.
> + * 1 Decimation will work with 4 rows or columns per unit.
> + */
> +#define STK1160_DMCTRL 0x104
> +

Great, thanks for documenting this fully.

> +
>  /* Capture Frame Start Position */
>  #define STK116_CFSPO   0x110
>  #define STK116_CFSPO_STX_L 0x110
> diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c 
> b/drivers/media/usb/stk1160/stk1160-v4l.c
> index 65a326c..94dafeb 100644
> --- a/drivers/media/usb/stk1160/stk1160-v4l.c
> +++ b/drivers/media/usb/stk1160/stk1160-v4l.c
> @@ -106,6 +106,76 @@ static void stk1160_set_std(struct stk1160 *dev)
>
>  }
>
> +static void stk1160_try_fmt(struct stk1160 *dev, struct v4l2_format *f, bool 
> try)
> +{
> +   int base_width, base_height;
> +
> +   if (dev->norm & V4L2_STD_525_60){
> +   base_width = 720;
> +   base_height = 480;
> +   } else {
> +   base_width = 720;
> +   base_height = 576;
> +   }
> +
> +   if (f->fmt.pix.width <= (base_width / 3)
> +   || f->fmt.pix.height <= (base_height / 3)){
> +   f->fmt.pix.width = base_width / 3;
> +   f->fmt.pix.height = base_height / 3;
> +   if (!try){
> +   dev->decimate = 3;
> +   }
> +   } else if ((f->fmt.pix.width >= base_width >> 1
> +&& f->fmt.pix.width < base_width)
> +||((f->fmt.pix.height >= base_height >> 1
> +&& f->fmt.pix.height < base_height))){
> +   f->fmt.pix.width = base_width >> 1;
> +   f->fmt.pix.height = base_height >> 1;
> +   if (!try){
> +   dev->decimate = 2;
> +   }
> +   } else {
> +   f->fmt.pix.width = base_width;
> +   f->fmt.pix.height = base_height;
> +   if (!try){
> +   dev->decimate = 0;
> +   }
> +   }

These if/else if/else block looks really ugly.

> +}
> +
> +static void stk1160_set_fmt(struct stk1160 *dev)
> +{
> +   if (dev->norm & V4L2_STD_525_60){
> +   dev->width = 720;
> +   dev->height = 480;
> +   } else {
> + 

Re: [PATCH 1/1] Fix DVBsky rc-keymap

2015-03-09 Thread Nibble Max
Hello,

Mapping VOLUME and CHANNEL keys to the general ones will break some tv 
softwares remote control functions.

Best Regards,
Max

On 2015-03-10 06:05:02, Dirk Nehring  wrote:
>Signed-off-by: Dirk Nehring 
>---
> drivers/media/rc/keymaps/rc-dvbsky.c | 12 ++--
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/media/rc/keymaps/rc-dvbsky.c 
>b/drivers/media/rc/keymaps/rc-dvbsky.c
>index c5115a1..b942b16 100644
>--- a/drivers/media/rc/keymaps/rc-dvbsky.c
>+++ b/drivers/media/rc/keymaps/rc-dvbsky.c
>@@ -33,16 +33,16 @@ static struct rc_map_table rc5_dvbsky[] = {
>   { 0x000b, KEY_STOP },
>   { 0x000c, KEY_EXIT },
>   { 0x000e, KEY_CAMERA }, /*Snap shot*/
>-  { 0x000f, KEY_SUBTITLE }, /*PIP*/
>-  { 0x0010, KEY_VOLUMEUP },
>-  { 0x0011, KEY_VOLUMEDOWN },
>+  { 0x000f, KEY_TV2 }, /*PIP*/
>+  { 0x0010, KEY_RIGHT },
>+  { 0x0011, KEY_LEFT },
>   { 0x0012, KEY_FAVORITES },
>-  { 0x0013, KEY_LIST }, /*Info*/
>+  { 0x0013, KEY_INFO },
>   { 0x0016, KEY_PAUSE },
>   { 0x0017, KEY_PLAY },
>   { 0x001f, KEY_RECORD },
>-  { 0x0020, KEY_CHANNELDOWN },
>-  { 0x0021, KEY_CHANNELUP },
>+  { 0x0020, KEY_UP },
>+  { 0x0021, KEY_DOWN },
>   { 0x0025, KEY_POWER2 },
>   { 0x0026, KEY_REWIND },
>   { 0x0027, KEY_FASTFORWARD },
>-- 
>2.1.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: [PATCH v4] media: i2c: add support for omnivision's ov2659 sensor

2015-03-09 Thread Sakari Ailus
Hi Prabhakar,

On Sun, Mar 08, 2015 at 11:33:27AM +, Lad Prabhakar wrote:
> From: Benoit Parrot 
> 
> this patch adds support for omnivision's ov2659
> sensor, the driver supports following features:
> 1: Asynchronous probing
> 2: DT support
> 3: Media controller support
> 
> Signed-off-by: Benoit Parrot 
> Signed-off-by: Lad, Prabhakar 

Now that DT support is included, could you document it as well? There's a
single proprerty to document.

-- 
Cheers,

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 v4] media: i2c: add support for omnivision's ov2659 sensor

2015-03-09 Thread Sakari Ailus
Hi Prabhakar,

On Sun, Mar 08, 2015 at 11:33:27AM +, Lad Prabhakar wrote:
...
> +static struct ov2659_platform_data *
> +ov2659_get_pdata(struct i2c_client *client)
> +{
> + struct ov2659_platform_data *pdata;
> + struct device_node *endpoint;
> + int ret;
> +
> + if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) {
> + dev_err(&client->dev, "ov2659_get_pdata: DT Node found\n");
> + return client->dev.platform_data;
> + }
> +
> + endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
> + if (!endpoint)
> + return NULL;
> +
> + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + goto done;
> +
> + ret = of_property_read_u32(endpoint, "link-frequencies",
> +&pdata->link_frequency);

This is actually documented as being a 64-bit array.

The smiapp wasn't even reading it from the endpoint node. Oh well...

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


hyvää päivää

2015-03-09 Thread Loan Engine


hyvää päivää

Hanki laina tänään Loan Engine, jonka korko on 3%. Täytä
muodostavat alle jos kiinnostaa:

Sukupuoli:
maa:
Määrä tarvitaan:
Kesto:
Mission:

On monia syitä, miksi lainan voi auttaa

tervehdys

Ana Paula


--
This message has been scanned by IPC ASGW and is believed to be clean.


--
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/3] Add link-frequencies to struct v4l2_of_endpoint

2015-03-09 Thread Sakari Ailus
Hi,

While I was adding a link_frequencies array field to struct
v4l2_of_endpoint, I also realised that the smiapp driver was not reading the
link-frequencies property from the endpoint, but the i2c device node
instead. This is what the second patch addresses.

The third patch does add support for reading the link-frequencies property
to struct v4l2_of_endpoint. There were a few options to consider. I'm not
entirely happy with the solution, but it still appears the best option to
me, all being:

1. Let drivers parse the link-frequencies property. There are three samples
from three different developers (myself, Laurent and Prabhakar) and two of
them seemed to have issues.

2. Reading the contents of the link-frequencies property in
v4l2_of_parse_endpoint() addresses the above issue. It currently has no
cleanup function to release memory reserved for the variable-size
link_frequencies array.

2a. Use a constant size array for link-frequencies. This limits the number
of link-frequencies and wastes memory elsewhere.

2b. Use devm_*() functions to allocate the memory. v4l2_of_parse_endpoint()
would require a device pointer argument in order to read variable size
content from the endpoint. One major issue in this approach is that the
configuration struct is typically short-lived as drivers allocate it in
stack in their DT node parsing function.

2c. Add a function to release resources reserved by
v4l2_of_parse_endpoint(). This is what the third patch does.

Comments are welcome.

-- 
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 3/3] v4l: of: Add link-frequencies array to struct v4l2_of_endpoint

2015-03-09 Thread Sakari Ailus
Parse and read the link-frequencies property in v4l2_of_parse_endpoint().
The property is an u64 array of undefined length, thus the memory allocation
may fail, leading

- v4l2_of_parse_endpoint() to return an error in such a case (as well as
  when failing to parse the property) and
- to requiring releasing the memory reserved for the array
  (v4l2_of_release_endpoint()).

If a driver does not need to access properties that require memory
allocation (such as link-frequencies), it may choose to call
v4l2_of_release_endpoint() right after calling v4l2_of_parse_endpoint().

Signed-off-by: Sakari Ailus 
---
 drivers/media/i2c/adv7604.c|1 +
 drivers/media/i2c/s5c73m3/s5c73m3-core.c   |1 +
 drivers/media/i2c/s5k5baf.c|1 +
 drivers/media/i2c/smiapp/smiapp-core.c |   32 
 drivers/media/i2c/tvp514x.c|1 +
 drivers/media/i2c/tvp7002.c|1 +
 drivers/media/platform/am437x/am437x-vpfe.c|1 +
 drivers/media/platform/exynos4-is/media-dev.c  |1 +
 drivers/media/platform/exynos4-is/mipi-csis.c  |1 +
 drivers/media/platform/soc_camera/atmel-isi.c  |1 +
 drivers/media/platform/soc_camera/pxa_camera.c |1 +
 drivers/media/platform/soc_camera/rcar_vin.c   |1 +
 drivers/media/v4l2-core/v4l2-of.c  |   47 +++-
 include/media/v4l2-of.h|9 +
 14 files changed, 81 insertions(+), 18 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index aaab9c9..9c6c2a5 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2624,6 +2624,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
return -EINVAL;
 
v4l2_of_parse_endpoint(endpoint, &bus_cfg);
+   v4l2_of_release_endpoint(&bus_cfg);
of_node_put(endpoint);
 
flags = bus_cfg.bus.parallel.flags;
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c 
b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index ee0f57e..f248a47 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1624,6 +1624,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 
*state)
}
 
v4l2_of_parse_endpoint(node_ep, &ep);
+   v4l2_of_release_endpoint(&ep);
of_node_put(node_ep);
 
if (ep.bus_type != V4L2_MBUS_CSI2) {
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index a3d7d03..222cd62 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1867,6 +1867,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf 
*state, struct device *dev)
}
 
v4l2_of_parse_endpoint(node_ep, &ep);
+   v4l2_of_release_endpoint(&ep);
of_node_put(node_ep);
state->bus_type = ep.bus_type;
 
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index ecae76b..2b3cd9e 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2977,7 +2977,7 @@ static struct smiapp_platform_data 
*smiapp_get_pdata(struct device *dev)
struct smiapp_platform_data *pdata;
struct v4l2_of_endpoint bus_cfg;
struct device_node *ep;
-   uint32_t asize;
+   int i;
int rval;
 
if (!dev->of_node)
@@ -2987,12 +2987,14 @@ static struct smiapp_platform_data 
*smiapp_get_pdata(struct device *dev)
if (!ep)
return NULL;
 
+   rval = v4l2_of_parse_endpoint(ep, &bus_cfg);
+   if (rval < 0)
+   goto out_err;
+
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
goto out_err;
 
-   v4l2_of_parse_endpoint(ep, &bus_cfg);
-
switch (bus_cfg.bus_type) {
case V4L2_MBUS_CSI2:
pdata->csi_signalling_mode = SMIAPP_CSI_SIGNALLING_MODE_CSI2;
@@ -3022,34 +3024,30 @@ static struct smiapp_platform_data 
*smiapp_get_pdata(struct device *dev)
dev_dbg(dev, "reset %d, nvm %d, clk %d, csi %d\n", pdata->xshutdown,
pdata->nvm_size, pdata->ext_clk, pdata->csi_signalling_mode);
 
-   rval = of_get_property(ep, "link-frequencies", &asize) ? 0 : -ENOENT;
-   if (rval) {
-   dev_warn(dev, "can't get link-frequencies array size\n");
+   if (!bus_cfg.nr_of_link_frequencies) {
+   dev_warn(dev, "no link frequencies defined\n");
goto out_err;
}
 
-   pdata->op_sys_clock = devm_kzalloc(dev, asize, GFP_KERNEL);
+   pdata->op_sys_clock = devm_kmalloc_array(
+   dev, bus_cfg.nr_of_link_frequencies + 1 /* guardian */,
+   sizeof(*bus_cfg.link_frequencies), GFP_KERNEL);
if (!pdata->op_sys_clock) {
rval = -ENOMEM;
goto out_err;
}
 
-   asize /= sizeof(*pdata->op_sys_clock);
-   rval = of_property_read_u64_array(
-

[PATCH 2/3] smiapp: Read link-frequencies property from the endpoint node

2015-03-09 Thread Sakari Ailus
The documentation stated that the link-frequencies property belongs to the
endpoint node, not to the device's of_node. Fix this.

There are no DT board descriptions using the driver yet, so a fix in the
driver is sufficient.

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

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 565a00c..ecae76b 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -3022,8 +3022,7 @@ static struct smiapp_platform_data 
*smiapp_get_pdata(struct device *dev)
dev_dbg(dev, "reset %d, nvm %d, clk %d, csi %d\n", pdata->xshutdown,
pdata->nvm_size, pdata->ext_clk, pdata->csi_signalling_mode);
 
-   rval = of_get_property(
-   dev->of_node, "link-frequencies", &asize) ? 0 : -ENOENT;
+   rval = of_get_property(ep, "link-frequencies", &asize) ? 0 : -ENOENT;
if (rval) {
dev_warn(dev, "can't get link-frequencies array size\n");
goto out_err;
@@ -3037,7 +3036,7 @@ static struct smiapp_platform_data 
*smiapp_get_pdata(struct device *dev)
 
asize /= sizeof(*pdata->op_sys_clock);
rval = of_property_read_u64_array(
-   dev->of_node, "link-frequencies", pdata->op_sys_clock, asize);
+   ep, "link-frequencies", pdata->op_sys_clock, asize);
if (rval) {
dev_warn(dev, "can't get link-frequencies\n");
goto out_err;
-- 
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/3] smiapp: Clean up smiapp_get_pdata()

2015-03-09 Thread Sakari Ailus
Don't set rval when it's not used (the function returns a pointer to struct
smiapp_platform_data).

Signed-off-by: Sakari Ailus 
---
 drivers/media/i2c/smiapp/smiapp-core.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index b1f566b..565a00c 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2988,10 +2988,8 @@ static struct smiapp_platform_data 
*smiapp_get_pdata(struct device *dev)
return NULL;
 
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
-   if (!pdata) {
-   rval = -ENOMEM;
+   if (!pdata)
goto out_err;
-   }
 
v4l2_of_parse_endpoint(ep, &bus_cfg);
 
@@ -3001,7 +2999,6 @@ static struct smiapp_platform_data 
*smiapp_get_pdata(struct device *dev)
break;
/* FIXME: add CCP2 support. */
default:
-   rval = -EINVAL;
goto out_err;
}
 
-- 
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


Re: [PATCH/RFC v12 04/19] dt-binding: leds: Add common LED DT bindings macros

2015-03-09 Thread Bryan Wu
On Wed, Mar 4, 2015 at 11:56 PM, Jacek Anaszewski
 wrote:
> On 03/04/2015 05:14 PM, Jacek Anaszewski wrote:
>>
>> Add macros for defining boost mode and trigger type properties
>> of flash LED devices.
>>
>> Signed-off-by: Jacek Anaszewski 
>> Acked-by: Kyungmin Park 
>> Cc: Bryan Wu 
>> Cc: Richard Purdie 
>> ---
>>   include/dt-bindings/leds/max77693.h |   21 +
>>   1 file changed, 21 insertions(+)
>>   create mode 100644 include/dt-bindings/leds/max77693.h
>
>
> This should be obviously include/dt-bindings/leds/common.h.
> It will affect also max77693-led bindings documentation patch.
> I'll send the update after receiving review remarks related to the
> remaining part of the mentioned patches.
>

OK, please update them then I will merge this patch.

Thanks,
-Bryan

>
>>
>> diff --git a/include/dt-bindings/leds/max77693.h
>> b/include/dt-bindings/leds/max77693.h
>> new file mode 100644
>> index 000..79fcef7
>> --- /dev/null
>> +++ b/include/dt-bindings/leds/max77693.h
>> @@ -0,0 +1,21 @@
>> +/*
>> + * This header provides macros for the common LEDs device tree bindings.
>> + *
>> + * Copyright (C) 2015, Samsung Electronics Co., Ltd.
>> + *
>> + * Author: Jacek Anaszewski 
>> + */
>> +
>> +#ifndef __DT_BINDINGS_LEDS_H__
>> +#define __DT_BINDINGS_LEDS_H
>> +
>> +/* External trigger type */
>> +#define LEDS_TRIG_TYPE_EDGE0
>> +#define LEDS_TRIG_TYPE_LEVEL   1
>> +
>> +/* Boost modes */
>> +#define LEDS_BOOST_OFF 0
>> +#define LEDS_BOOST_ADAPTIVE1
>> +#define LEDS_BOOST_FIXED   2
>> +
>> +#endif /* __DT_BINDINGS_LEDS_H */
>>
>
>
> --
> Best 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/RFC v12 03/19] Documentation: leds: Add description of LED Flash class extension

2015-03-09 Thread Bryan Wu
On Wed, Mar 4, 2015 at 8:14 AM, Jacek Anaszewski
 wrote:
> The documentation being added contains overall description of the
> LED Flash Class and the related sysfs attributes.
>

Thanks, merged!
-Bryan


> Signed-off-by: Jacek Anaszewski 
> Acked-by: Kyungmin Park 
> Cc: Bryan Wu 
> Cc: Richard Purdie 
> ---
>  Documentation/leds/leds-class-flash.txt |   22 ++
>  1 file changed, 22 insertions(+)
>  create mode 100644 Documentation/leds/leds-class-flash.txt
>
> diff --git a/Documentation/leds/leds-class-flash.txt 
> b/Documentation/leds/leds-class-flash.txt
> new file mode 100644
> index 000..19bb673
> --- /dev/null
> +++ b/Documentation/leds/leds-class-flash.txt
> @@ -0,0 +1,22 @@
> +
> +Flash LED handling under Linux
> +==
> +
> +Some LED devices provide two modes - torch and flash. In the LED subsystem
> +those modes are supported by LED class (see 
> Documentation/leds/leds-class.txt)
> +and LED Flash class respectively. The torch mode related features are enabled
> +by default and the flash ones only if a driver declares it by setting
> +LED_DEV_CAP_FLASH flag.
> +
> +In order to enable the support for flash LEDs CONFIG_LEDS_CLASS_FLASH symbol
> +must be defined in the kernel config. A LED Flash class driver must be
> +registered in the LED subsystem with led_classdev_flash_register function.
> +
> +Following sysfs attributes are exposed for controlling flash LED devices:
> +(see Documentation/ABI/testing/sysfs-class-led-flash)
> +   - flash_brightness
> +   - max_flash_brightness
> +   - flash_timeout
> +   - max_flash_timeout
> +   - flash_strobe
> +   - flash_fault
> --
> 1.7.9.5
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC v12 02/19] leds: flash: document sysfs interface

2015-03-09 Thread Bryan Wu
On Wed, Mar 4, 2015 at 8:14 AM, Jacek Anaszewski
 wrote:
> Add a documentation of LED Flash class specific sysfs attributes.
>

Thanks, merged!
-Bryan

> Signed-off-by: Jacek Anaszewski 
> Acked-by: Kyungmin Park 
> Cc: Bryan Wu 
> Cc: Richard Purdie 
> ---
>  Documentation/ABI/testing/sysfs-class-led-flash |   80 
> +++
>  1 file changed, 80 insertions(+)
>  create mode 100644 Documentation/ABI/testing/sysfs-class-led-flash
>
> diff --git a/Documentation/ABI/testing/sysfs-class-led-flash 
> b/Documentation/ABI/testing/sysfs-class-led-flash
> new file mode 100644
> index 000..220a027
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-class-led-flash
> @@ -0,0 +1,80 @@
> +What:  /sys/class/leds//flash_brightness
> +Date:  March 2015
> +KernelVersion: 4.0
> +Contact:   Jacek Anaszewski 
> +Description:   read/write
> +   Set the brightness of this LED in the flash strobe mode, in
> +   microamperes. The file is created only for the flash LED 
> devices
> +   that support setting flash brightness.
> +
> +   The value is between 0 and
> +   /sys/class/leds//max_flash_brightness.
> +
> +What:  /sys/class/leds//max_flash_brightness
> +Date:  March 2015
> +KernelVersion: 4.0
> +Contact:   Jacek Anaszewski 
> +Description:   read only
> +   Maximum brightness level for this LED in the flash strobe 
> mode,
> +   in microamperes.
> +
> +What:  /sys/class/leds//flash_timeout
> +Date:  March 2015
> +KernelVersion: 4.0
> +Contact:   Jacek Anaszewski 
> +Description:   read/write
> +   Hardware timeout for flash, in microseconds. The flash strobe
> +   is stopped after this period of time has passed from the start
> +   of the strobe. The file is created only for the flash LED
> +   devices that support setting flash timeout.
> +
> +What:  /sys/class/leds//max_flash_timeout
> +Date:  March 2015
> +KernelVersion: 4.0
> +Contact:   Jacek Anaszewski 
> +Description:   read only
> +   Maximum flash timeout for this LED, in microseconds.
> +
> +What:  /sys/class/leds//flash_strobe
> +Date:  March 2015
> +KernelVersion: 4.0
> +Contact:   Jacek Anaszewski 
> +Description:   read/write
> +   Flash strobe state. When written with 1 it triggers flash 
> strobe
> +   and when written with 0 it turns the flash off.
> +
> +   On read 1 means that flash is currently strobing and 0 means
> +   that flash is off.
> +
> +What:  /sys/class/leds//flash_fault
> +Date:  March 2015
> +KernelVersion: 4.0
> +Contact:   Jacek Anaszewski 
> +Description:   read only
> +   Space separated list of flash faults that may have occurred.
> +   Flash faults are re-read after strobing the flash. Possible
> +   flash faults:
> +
> +   * led-over-voltage - flash controller voltage to the flash LED
> +   has exceeded the limit specific to the flash 
> controller
> +   * flash-timeout-exceeded - the flash strobe was still on when
> +   the timeout set by the user has expired; not all flash
> +   controllers may set this in all such conditions
> +   * controller-over-temperature - the flash controller has
> +   overheated
> +   * controller-short-circuit - the short circuit protection
> +   of the flash controller has been triggered
> +   * led-power-supply-over-current - current in the LED power
> +   supply has exceeded the limit specific to the flash
> +   controller
> +   * indicator-led-fault - the flash controller has detected
> +   a short or open circuit condition on the indicator LED
> +   * led-under-voltage - flash controller voltage to the flash
> +   LED has been below the minimum limit specific to
> +   the flash
> +   * controller-under-voltage - the input voltage of the flash
> +   controller is below the limit under which strobing the
> +   flash at full current will not be possible;
> +   the condition persists until this flag is no longer 
> set
> +   * led-over-temperature - the temperature of the LED has 
> exceeded
> +   its allowed upper limit
> --
> 1.7.9.5
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFC v12 01/19] leds: flash: Remove synchronized flash strobe feature

2015-03-09 Thread Bryan Wu
On Wed, Mar 4, 2015 at 8:14 AM, Jacek Anaszewski
 wrote:
> Synchronized flash strobe feature has been considered not fitting
> for LED subsystem sysfs interface and thus is being removed.
>

OK, I will merge this.

-Bryan


> Signed-off-by: Jacek Anaszewski 
> Acked-by: Kyungmin Park 
> Cc: Bryan Wu 
> Cc: Richard Purdie 
> ---
>  drivers/leds/led-class-flash.c  |   82 
> ---
>  include/linux/led-class-flash.h |   14 ---
>  include/linux/leds.h|1 -
>  3 files changed, 97 deletions(-)
>
> diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c
> index 4a19fd4..3b25734 100644
> --- a/drivers/leds/led-class-flash.c
> +++ b/drivers/leds/led-class-flash.c
> @@ -216,75 +216,6 @@ static ssize_t flash_fault_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RO(flash_fault);
>
> -static ssize_t available_sync_leds_show(struct device *dev,
> -   struct device_attribute *attr, char *buf)
> -{
> -   struct led_classdev *led_cdev = dev_get_drvdata(dev);
> -   struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
> -   char *pbuf = buf;
> -   int i, buf_len;
> -
> -   buf_len = sprintf(pbuf, "[0: none] ");
> -   pbuf += buf_len;
> -
> -   for (i = 0; i < fled_cdev->num_sync_leds; ++i) {
> -   buf_len = sprintf(pbuf, "[%d: %s] ", i + 1,
> - fled_cdev->sync_leds[i]->led_cdev.name);
> -   pbuf += buf_len;
> -   }
> -
> -   return sprintf(buf, "%s\n", buf);
> -}
> -static DEVICE_ATTR_RO(available_sync_leds);
> -
> -static ssize_t flash_sync_strobe_store(struct device *dev,
> -   struct device_attribute *attr, const char *buf, size_t size)
> -{
> -   struct led_classdev *led_cdev = dev_get_drvdata(dev);
> -   struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
> -   unsigned long led_id;
> -   ssize_t ret;
> -
> -   mutex_lock(&led_cdev->led_access);
> -
> -   if (led_sysfs_is_disabled(led_cdev)) {
> -   ret = -EBUSY;
> -   goto unlock;
> -   }
> -
> -   ret = kstrtoul(buf, 10, &led_id);
> -   if (ret)
> -   goto unlock;
> -
> -   if (led_id > fled_cdev->num_sync_leds) {
> -   ret = -ERANGE;
> -   goto unlock;
> -   }
> -
> -   fled_cdev->sync_led_id = led_id;
> -
> -   ret = size;
> -unlock:
> -   mutex_unlock(&led_cdev->led_access);
> -   return ret;
> -}
> -
> -static ssize_t flash_sync_strobe_show(struct device *dev,
> -   struct device_attribute *attr, char *buf)
> -{
> -   struct led_classdev *led_cdev = dev_get_drvdata(dev);
> -   struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
> -   int sled_id = fled_cdev->sync_led_id;
> -   char *sync_led_name = "none";
> -
> -   if (fled_cdev->sync_led_id > 0)
> -   sync_led_name = (char *)
> -   fled_cdev->sync_leds[sled_id - 1]->led_cdev.name;
> -
> -   return sprintf(buf, "[%d: %s]\n", sled_id, sync_led_name);
> -}
> -static DEVICE_ATTR_RW(flash_sync_strobe);
> -
>  static struct attribute *led_flash_strobe_attrs[] = {
> &dev_attr_flash_strobe.attr,
> NULL,
> @@ -307,12 +238,6 @@ static struct attribute *led_flash_fault_attrs[] = {
> NULL,
>  };
>
> -static struct attribute *led_flash_sync_strobe_attrs[] = {
> -   &dev_attr_available_sync_leds.attr,
> -   &dev_attr_flash_sync_strobe.attr,
> -   NULL,
> -};
> -
>  static const struct attribute_group led_flash_strobe_group = {
> .attrs = led_flash_strobe_attrs,
>  };
> @@ -329,10 +254,6 @@ static const struct attribute_group 
> led_flash_fault_group = {
> .attrs = led_flash_fault_attrs,
>  };
>
> -static const struct attribute_group led_flash_sync_strobe_group = {
> -   .attrs = led_flash_sync_strobe_attrs,
> -};
> -
>  static void led_flash_resume(struct led_classdev *led_cdev)
>  {
> struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
> @@ -361,9 +282,6 @@ static void led_flash_init_sysfs_groups(struct 
> led_classdev_flash *fled_cdev)
> if (ops->fault_get)
> flash_groups[num_sysfs_groups++] = &led_flash_fault_group;
>
> -   if (led_cdev->flags & LED_DEV_CAP_SYNC_STROBE)
> -   flash_groups[num_sysfs_groups++] = 
> &led_flash_sync_strobe_group;
> -
> led_cdev->groups = flash_groups;
>  }
>
> diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h
> index 3b5b964..21ec91e 100644
> --- a/include/linux/led-class-flash.h
> +++ b/include/linux/led-class-flash.h
> @@ -81,20 +81,6 @@ struct led_classdev_flash {
>
> /* LED Flash class sysfs groups */
> const struct attribute_group 
> *sysfs_groups[LED_FLASH_MAX_SYSFS_GROUPS];
> -
> -   /* LEDs available for flash strobe synchronization */
> -   struct led_classdev_flash **sync_leds;
> -
> -   /*

[PATCH 1/1] Fix DVBsky rc-keymap

2015-03-09 Thread Dirk Nehring
Signed-off-by: Dirk Nehring 
---
 drivers/media/rc/keymaps/rc-dvbsky.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/rc/keymaps/rc-dvbsky.c 
b/drivers/media/rc/keymaps/rc-dvbsky.c
index c5115a1..b942b16 100644
--- a/drivers/media/rc/keymaps/rc-dvbsky.c
+++ b/drivers/media/rc/keymaps/rc-dvbsky.c
@@ -33,16 +33,16 @@ static struct rc_map_table rc5_dvbsky[] = {
{ 0x000b, KEY_STOP },
{ 0x000c, KEY_EXIT },
{ 0x000e, KEY_CAMERA }, /*Snap shot*/
-   { 0x000f, KEY_SUBTITLE }, /*PIP*/
-   { 0x0010, KEY_VOLUMEUP },
-   { 0x0011, KEY_VOLUMEDOWN },
+   { 0x000f, KEY_TV2 }, /*PIP*/
+   { 0x0010, KEY_RIGHT },
+   { 0x0011, KEY_LEFT },
{ 0x0012, KEY_FAVORITES },
-   { 0x0013, KEY_LIST }, /*Info*/
+   { 0x0013, KEY_INFO },
{ 0x0016, KEY_PAUSE },
{ 0x0017, KEY_PLAY },
{ 0x001f, KEY_RECORD },
-   { 0x0020, KEY_CHANNELDOWN },
-   { 0x0021, KEY_CHANNELUP },
+   { 0x0020, KEY_UP },
+   { 0x0021, KEY_DOWN },
{ 0x0025, KEY_POWER2 },
{ 0x0026, KEY_REWIND },
{ 0x0027, KEY_FASTFORWARD },
-- 
2.1.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/2] media: sh_vou: use devres api

2015-03-09 Thread Lad Prabhakar
From: "Lad, Prabhakar" 

use devres API while allocating resources so that these
resources are released automatically on driver detach.

Signed-off-by: Lad, Prabhakar 
---
 drivers/media/platform/sh_vou.c | 51 +
 1 file changed, 11 insertions(+), 40 deletions(-)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index dde1ccc..1c52cd1 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -1297,7 +1297,7 @@ static int sh_vou_probe(struct platform_device *pdev)
struct i2c_adapter *i2c_adap;
struct video_device *vdev;
struct sh_vou_device *vou_dev;
-   struct resource *reg_res, *region;
+   struct resource *reg_res;
struct v4l2_subdev *subdev;
int irq, ret;
 
@@ -1309,7 +1309,7 @@ static int sh_vou_probe(struct platform_device *pdev)
return -ENODEV;
}
 
-   vou_dev = kzalloc(sizeof(*vou_dev), GFP_KERNEL);
+   vou_dev = devm_kzalloc(&pdev->dev, sizeof(*vou_dev), GFP_KERNEL);
if (!vou_dev)
return -ENOMEM;
 
@@ -1337,28 +1337,18 @@ static int sh_vou_probe(struct platform_device *pdev)
pix->sizeimage  = VOU_MAX_IMAGE_WIDTH * 2 * 480;
pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
 
-   region = request_mem_region(reg_res->start, resource_size(reg_res),
-   pdev->name);
-   if (!region) {
-   dev_err(&pdev->dev, "VOU region already claimed\n");
-   ret = -EBUSY;
-   goto ereqmemreg;
-   }
-
-   vou_dev->base = ioremap(reg_res->start, resource_size(reg_res));
-   if (!vou_dev->base) {
-   ret = -ENOMEM;
-   goto emap;
-   }
+   vou_dev->base = devm_ioremap_resource(&pdev->dev, reg_res);
+   if (IS_ERR(vou_dev->base))
+   return PTR_ERR(vou_dev->base);
 
-   ret = request_irq(irq, sh_vou_isr, 0, "vou", vou_dev);
-   if (ret < 0)
-   goto ereqirq;
+   ret = devm_request_irq(&pdev->dev, irq, sh_vou_isr, 0, "vou", vou_dev);
+   if (ret)
+   return ret;
 
ret = v4l2_device_register(&pdev->dev, &vou_dev->v4l2_dev);
if (ret < 0) {
dev_err(&pdev->dev, "Error registering v4l2 device\n");
-   goto ev4l2devreg;
+   return ret;
}
 
vdev = &vou_dev->vdev;
@@ -1382,7 +1372,7 @@ static int sh_vou_probe(struct platform_device *pdev)
 
ret = sh_vou_hw_init(vou_dev);
if (ret < 0)
-   goto ereset;
+   goto ei2cnd;
 
subdev = v4l2_i2c_new_subdev_board(&vou_dev->v4l2_dev, i2c_adap,
vou_pdata->board_info, NULL);
@@ -1393,50 +1383,31 @@ static int sh_vou_probe(struct platform_device *pdev)
 
ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
if (ret < 0)
-   goto evregdev;
+   goto ei2cnd;
 
return 0;
 
-evregdev:
 ei2cnd:
-ereset:
i2c_put_adapter(i2c_adap);
 ei2cgadap:
pm_runtime_disable(&pdev->dev);
v4l2_device_unregister(&vou_dev->v4l2_dev);
-ev4l2devreg:
-   free_irq(irq, vou_dev);
-ereqirq:
-   iounmap(vou_dev->base);
-emap:
-   release_mem_region(reg_res->start, resource_size(reg_res));
-ereqmemreg:
-   kfree(vou_dev);
return ret;
 }
 
 static int sh_vou_remove(struct platform_device *pdev)
 {
-   int irq = platform_get_irq(pdev, 0);
struct v4l2_device *v4l2_dev = platform_get_drvdata(pdev);
struct sh_vou_device *vou_dev = container_of(v4l2_dev,
struct sh_vou_device, v4l2_dev);
struct v4l2_subdev *sd = list_entry(v4l2_dev->subdevs.next,
struct v4l2_subdev, list);
struct i2c_client *client = v4l2_get_subdevdata(sd);
-   struct resource *reg_res;
 
-   if (irq > 0)
-   free_irq(irq, vou_dev);
pm_runtime_disable(&pdev->dev);
video_unregister_device(&vou_dev->vdev);
i2c_put_adapter(client->adapter);
v4l2_device_unregister(&vou_dev->v4l2_dev);
-   iounmap(vou_dev->base);
-   reg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (reg_res)
-   release_mem_region(reg_res->start, resource_size(reg_res));
-   kfree(vou_dev);
return 0;
 }
 
-- 
2.1.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 0/2] media: sh_vou: trivial cleanups

2015-03-09 Thread Lad Prabhakar
From: "Lad, Prabhakar" 

Hi,

This series is trivial cleanup for sh_vou driver.

Cheers,
--Prabhakar Lad

Lad, Prabhakar (2):
  media: sh_vou: embed video_device
  media: sh_vou: use devres api

 drivers/media/platform/sh_vou.c | 72 ++---
 1 file changed, 17 insertions(+), 55 deletions(-)

-- 
2.1.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] media: sh_vou: embed video_device

2015-03-09 Thread Lad Prabhakar
From: "Lad, Prabhakar" 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Lad, Prabhakar 
---
 drivers/media/platform/sh_vou.c | 21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/sh_vou.c b/drivers/media/platform/sh_vou.c
index 6d1959d..dde1ccc 100644
--- a/drivers/media/platform/sh_vou.c
+++ b/drivers/media/platform/sh_vou.c
@@ -62,7 +62,7 @@ enum sh_vou_status {
 
 struct sh_vou_device {
struct v4l2_device v4l2_dev;
-   struct video_device *vdev;
+   struct video_device vdev;
atomic_t use_count;
struct sh_vou_pdata *pdata;
spinlock_t lock;
@@ -890,7 +890,7 @@ static int sh_vou_s_std(struct file *file, void *priv, 
v4l2_std_id std_id)
 
dev_dbg(vou_dev->v4l2_dev.dev, "%s(): 0x%llx\n", __func__, std_id);
 
-   if (std_id & ~vou_dev->vdev->tvnorms)
+   if (std_id & ~vou_dev->vdev.tvnorms)
return -EINVAL;
 
ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video,
@@ -1193,7 +1193,7 @@ static int sh_vou_open(struct file *file)
   V4L2_BUF_TYPE_VIDEO_OUTPUT,
   V4L2_FIELD_NONE,
   sizeof(struct videobuf_buffer),
-  vou_dev->vdev, &vou_dev->fop_lock);
+  &vou_dev->vdev, &vou_dev->fop_lock);
mutex_unlock(&vou_dev->fop_lock);
 
file->private_data = vou_file;
@@ -1361,21 +1361,14 @@ static int sh_vou_probe(struct platform_device *pdev)
goto ev4l2devreg;
}
 
-   /* Allocate memory for video device */
-   vdev = video_device_alloc();
-   if (vdev == NULL) {
-   ret = -ENOMEM;
-   goto evdevalloc;
-   }
-
+   vdev = &vou_dev->vdev;
*vdev = sh_vou_video_template;
if (vou_pdata->bus_fmt == SH_VOU_BUS_8BIT)
vdev->tvnorms |= V4L2_STD_PAL;
vdev->v4l2_dev = &vou_dev->v4l2_dev;
-   vdev->release = video_device_release;
+   vdev->release = video_device_release_empty;
vdev->lock = &vou_dev->fop_lock;
 
-   vou_dev->vdev = vdev;
video_set_drvdata(vdev, vou_dev);
 
pm_runtime_enable(&pdev->dev);
@@ -1409,9 +1402,7 @@ ei2cnd:
 ereset:
i2c_put_adapter(i2c_adap);
 ei2cgadap:
-   video_device_release(vdev);
pm_runtime_disable(&pdev->dev);
-evdevalloc:
v4l2_device_unregister(&vou_dev->v4l2_dev);
 ev4l2devreg:
free_irq(irq, vou_dev);
@@ -1438,7 +1429,7 @@ static int sh_vou_remove(struct platform_device *pdev)
if (irq > 0)
free_irq(irq, vou_dev);
pm_runtime_disable(&pdev->dev);
-   video_unregister_device(vou_dev->vdev);
+   video_unregister_device(&vou_dev->vdev);
i2c_put_adapter(client->adapter);
v4l2_device_unregister(&vou_dev->v4l2_dev);
iounmap(vou_dev->base);
-- 
2.1.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: [PATCH v4 2/2] V4L: add CCF support to the v4l2_clk API

2015-03-09 Thread Guennadi Liakhovetski
Hi Mauro,

On Mon, 2 Mar 2015, Mauro Carvalho Chehab wrote:

> Em Sun, 1 Feb 2015 12:12:33 +0100 (CET)
> Guennadi Liakhovetski  escreveu:
> 
> > V4L2 clocks, e.g. used by camera sensors for their master clock, do not
> > have to be supplied by a different V4L2 driver, they can also be
> > supplied by an independent source. In this case the standart kernel
> > clock API should be used to handle such clocks. This patch adds support
> > for such cases.
> > 
> > Signed-off-by: Guennadi Liakhovetski 
> > Acked-by: Laurent Pinchart 
> > ---
> > 
> > v4: sizeof(*clk) :)
> > 
> >  drivers/media/v4l2-core/v4l2-clk.c | 48 
> > +++---
> >  include/media/v4l2-clk.h   |  2 ++
> >  2 files changed, 47 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-clk.c 
> > b/drivers/media/v4l2-core/v4l2-clk.c
> > index 3ff0b00..9f8cb20 100644
> > --- a/drivers/media/v4l2-core/v4l2-clk.c
> > +++ b/drivers/media/v4l2-core/v4l2-clk.c
> > @@ -9,6 +9,7 @@
> >   */
> >  
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -37,6 +38,21 @@ static struct v4l2_clk *v4l2_clk_find(const char *dev_id)
> >  struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id)
> >  {
> > struct v4l2_clk *clk;
> > +   struct clk *ccf_clk = clk_get(dev, id);
> > +
> > +   if (PTR_ERR(ccf_clk) == -EPROBE_DEFER)
> > +   return ERR_PTR(-EPROBE_DEFER);
> 
> Why not do just:
>   return ccf_clk;

I would prefer that shorter form too, but the function returns "struct 
v4l2_clk *" and ccf_clk is "struct clk *"

Thanks
Guennadi
--
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/18] marvell-ccic: add DMABUF support for all three DMA modes

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Add VB2_DMABUF and VIDIOC_EXPBUF support. Also add VB2_USERPTR support
for the vmalloc DMA mode which was missing for no good reason.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 51b7291..a1312a5 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1255,14 +1255,14 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
vq->drv_priv = cam;
vq->lock = &cam->s_mutex;
vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+   vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
+   vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
INIT_LIST_HEAD(&cam->buffers);
switch (cam->buffer_mode) {
case B_DMA_contig:
 #ifdef MCAM_MODE_DMA_CONTIG
vq->ops = &mcam_vb2_ops;
vq->mem_ops = &vb2_dma_contig_memops;
-   vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-   vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
cam->dma_setup = mcam_ctlr_dma_contig;
cam->frame_complete = mcam_dma_contig_done;
cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev);
@@ -1274,8 +1274,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 #ifdef MCAM_MODE_DMA_SG
vq->ops = &mcam_vb2_sg_ops;
vq->mem_ops = &vb2_dma_sg_memops;
-   vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-   vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
cam->dma_setup = mcam_ctlr_dma_sg;
cam->frame_complete = mcam_dma_sg_done;
cam->vb_alloc_ctx_sg = vb2_dma_sg_init_ctx(cam->dev);
@@ -1289,8 +1287,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
(unsigned long) cam);
vq->ops = &mcam_vb2_ops;
vq->mem_ops = &vb2_vmalloc_memops;
-   vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-   vq->io_modes = VB2_MMAP | VB2_READ;
cam->dma_setup = mcam_ctlr_dma_vmalloc;
cam->frame_complete = mcam_vmalloc_done;
 #endif
@@ -1579,6 +1575,7 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
.vidioc_querybuf= vb2_ioctl_querybuf,
.vidioc_qbuf= vb2_ioctl_qbuf,
.vidioc_dqbuf   = vb2_ioctl_dqbuf,
+   .vidioc_expbuf  = vb2_ioctl_expbuf,
.vidioc_streamon= vb2_ioctl_streamon,
.vidioc_streamoff   = vb2_ioctl_streamoff,
.vidioc_g_parm  = mcam_vidioc_g_parm,
-- 
2.1.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 00/18] marvell-ccic + ov7670 fixes

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This patch series makes loads of fixes and improvements to the marvell-ccic
and ov7670 drivers. This has been tested on an OLPC XO-1 laptop.

This patch series sits on top of this pull request:

https://patchwork.linuxtv.org/patch/28532/

I do need to check the last patch with Libin Yang since his patch from mid-2013
broke the driver for the OLPC laptop. Nobody noticed since the latest released
kernel from the OLPC project for that laptop is 3.3, which didn't have his 
patch.

This driver now passes the v4l2-compliance test-suite, so that's very nice.

Regards,

Hans

Hans Verkuil (18):
  marvell-ccic: fix vb2 warning
  marvell-ccic: fill in bus_info
  marvell-ccic: webcam drivers shouldn't support g/s_std
  ov7670: check for valid width/height in ov7670_enum_frame_interval
  marvell-ccic: fill in colorspace
  marvell-ccic: control handler fixes
  marvell-ccic: switch to struct v4l2_fh
  marvell-ccic: implement control events
  marvell-ccic: use vb2 helpers and core locking
  marvell-ccic: add create_bufs support
  marvell-ccic: add DMABUF support for all three DMA modes
  marvell-ccic: fix streaming issues
  marvell-ccic: correctly requeue buffers
  marvell-ccic: add planar support to dma-vmalloc
  marvell-ccic: drop V4L2_PIX_FMT_JPEG dead code
  ov7670: use colorspace SRGB instead of JPEG
  marvell-ccic: fix the bytesperline and sizeimage calculations
  marvell-ccic: fix Y'CbCr ordering

 drivers/media/i2c/ov7670.c|  25 +-
 drivers/media/platform/marvell-ccic/cafe-driver.c |   1 +
 drivers/media/platform/marvell-ccic/mcam-core.c   | 461 --
 drivers/media/platform/marvell-ccic/mcam-core.h   |  11 +-
 drivers/media/platform/marvell-ccic/mmp-driver.c  |   1 +
 5 files changed, 207 insertions(+), 292 deletions(-)

-- 
2.1.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 18/18] marvell-ccic: fix Y'CbCr ordering

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Various formats had their byte ordering implemented incorrectly, and
the V4L2_PIX_FMT_UYVY is actually impossible to create, instead you
get V4L2_PIX_FMT_YVYU.

This was working before commit ad6ac452227b7cb93ac79beec092850d178740b1
("add new formats support for marvell-ccic driver"). That commit broke
the original format support and the OLPC XO-1 laptop showed wrong
colors ever since (if you are crazy enough to attempt to run the latest
kernel on it, like I did).

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 16 
 drivers/media/platform/marvell-ccic/mcam-core.h |  8 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 9343051..4e3ef68 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -117,8 +117,8 @@ static struct mcam_format_struct {
.planar = false,
},
{
-   .desc   = "UYVY 4:2:2",
-   .pixelformat= V4L2_PIX_FMT_UYVY,
+   .desc   = "YVYU 4:2:2",
+   .pixelformat= V4L2_PIX_FMT_YVYU,
.mbus_code  = MEDIA_BUS_FMT_YUYV8_2X8,
.bpp= 2,
.planar = false,
@@ -751,7 +751,7 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
 
switch (fmt->pixelformat) {
case V4L2_PIX_FMT_YUYV:
-   case V4L2_PIX_FMT_UYVY:
+   case V4L2_PIX_FMT_YVYU:
widthy = fmt->width * 2;
widthuv = 0;
break;
@@ -778,20 +778,20 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
switch (fmt->pixelformat) {
case V4L2_PIX_FMT_YUV422P:
mcam_reg_write_mask(cam, REG_CTRL0,
-   C0_DF_YUV | C0_YUV_PLANAR | C0_YUVE_YVYU, C0_DF_MASK);
+   C0_DF_YUV | C0_YUV_PLANAR | C0_YUVE_UYVY, C0_DF_MASK);
break;
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
mcam_reg_write_mask(cam, REG_CTRL0,
-   C0_DF_YUV | C0_YUV_420PL | C0_YUVE_YVYU, C0_DF_MASK);
+   C0_DF_YUV | C0_YUV_420PL | C0_YUVE_VYUY, C0_DF_MASK);
break;
case V4L2_PIX_FMT_YUYV:
mcam_reg_write_mask(cam, REG_CTRL0,
-   C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_UYVY, C0_DF_MASK);
+   C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_NOSWAP, C0_DF_MASK);
break;
-   case V4L2_PIX_FMT_UYVY:
+   case V4L2_PIX_FMT_YVYU:
mcam_reg_write_mask(cam, REG_CTRL0,
-   C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_YUYV, C0_DF_MASK);
+   C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_SWAP24, C0_DF_MASK);
break;
case V4L2_PIX_FMT_RGB444:
mcam_reg_write_mask(cam, REG_CTRL0,
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h 
b/drivers/media/platform/marvell-ccic/mcam-core.h
index 2847e06..97167f6 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -331,10 +331,10 @@ int mccic_resume(struct mcam_camera *cam);
 #define  C0_YUVE_YVYU0x0001/* Y1CrY0Cb */
 #define  C0_YUVE_VYUY0x0002/* CrY1CbY0 */
 #define  C0_YUVE_UYVY0x0003/* CbY1CrY0 */
-#define  C0_YUVE_XYUV0x/* 420: .YUV*/
-#define  C0_YUVE_XYVU0x0001/* 420: .YVU*/
-#define  C0_YUVE_XUVY0x0002/* 420: .UVY*/
-#define  C0_YUVE_XVUY0x0003/* 420: .VUY*/
+#define  C0_YUVE_NOSWAP  0x/* no bytes swapping*/
+#define  C0_YUVE_SWAP13  0x0001/* swap byte 1 and 3*/
+#define  C0_YUVE_SWAP24  0x0002/* swap byte 2 and 4*/
+#define  C0_YUVE_SWAP1324 0x0003   /* swap bytes 1&3 and 2&4 */
 /* Bayer bits 18,19 if needed */
 #define  C0_EOF_VSYNC0x0040/* Generate EOF by VSYNC */
 #define  C0_VEDGE_CTRL   0x0080/* Detect falling edge of VSYNC 
*/
-- 
2.1.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 14/18] marvell-ccic: add planar support to dma-vmalloc

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The dma-vmalloc implementation didn't support planar formats, but with
a little bit of refactoring that is easy to fix.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 94 -
 1 file changed, 46 insertions(+), 48 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 0d94696..2495ab6 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -206,12 +206,6 @@ struct mcam_dma_desc {
u32 segment_len;
 };
 
-struct yuv_pointer_t {
-   dma_addr_t y;
-   dma_addr_t u;
-   dma_addr_t v;
-};
-
 /*
  * Our buffer type for working with videobuf2.  Note that the vb2
  * developers have decreed that struct vb2_buffer must be at the
@@ -223,7 +217,6 @@ struct mcam_vb_buffer {
struct mcam_dma_desc *dma_desc; /* Descriptor virtual address */
dma_addr_t dma_desc_pa; /* Descriptor physical address */
int dma_desc_nent;  /* Number of mapped descriptors */
-   struct yuv_pointer_t yuv_p;
 };
 
 static inline struct mcam_vb_buffer *vb_to_mvb(struct vb2_buffer *vb)
@@ -341,6 +334,47 @@ static void mcam_disable_mipi(struct mcam_camera *mcam)
mcam->mipi_enabled = false;
 }
 
+static bool mcam_fmt_is_planar(__u32 pfmt)
+{
+   struct mcam_format_struct *f;
+
+   f = mcam_find_format(pfmt);
+   return f->planar;
+}
+
+static void mcam_write_yuv_bases(struct mcam_camera *cam,
+unsigned frame, dma_addr_t base)
+{
+   struct v4l2_pix_format *fmt = &cam->pix_format;
+   u32 pixel_count = fmt->width * fmt->height;
+   dma_addr_t y, u = 0, v = 0;
+
+   y = base;
+
+   switch (fmt->pixelformat) {
+   case V4L2_PIX_FMT_YUV422P:
+   u = y + pixel_count;
+   v = u + pixel_count / 2;
+   break;
+   case V4L2_PIX_FMT_YUV420:
+   u = y + pixel_count;
+   v = u + pixel_count / 4;
+   break;
+   case V4L2_PIX_FMT_YVU420:
+   v = y + pixel_count;
+   u = v + pixel_count / 4;
+   break;
+   default:
+   break;
+   }
+
+   mcam_reg_write(cam, REG_Y0BAR + frame * 4, y);
+   if (mcam_fmt_is_planar(fmt->pixelformat)) {
+   mcam_reg_write(cam, REG_U0BAR + frame * 4, u);
+   mcam_reg_write(cam, REG_V0BAR + frame * 4, v);
+   }
+}
+
 /* --- */
 
 #ifdef MCAM_MODE_VMALLOC
@@ -411,15 +445,14 @@ static void mcam_free_dma_bufs(struct mcam_camera *cam)
 static void mcam_ctlr_dma_vmalloc(struct mcam_camera *cam)
 {
/*
-* Store the first two Y buffers (we aren't supporting
-* planar formats for now, so no UV bufs).  Then either
+* Store the first two YUV buffers. Then either
 * set the third if it exists, or tell the controller
 * to just use two.
 */
-   mcam_reg_write(cam, REG_Y0BAR, cam->dma_handles[0]);
-   mcam_reg_write(cam, REG_Y1BAR, cam->dma_handles[1]);
+   mcam_write_yuv_bases(cam, 0, cam->dma_handles[0]);
+   mcam_write_yuv_bases(cam, 1, cam->dma_handles[1]);
if (cam->nbufs > 2) {
-   mcam_reg_write(cam, REG_Y2BAR, cam->dma_handles[2]);
+   mcam_write_yuv_bases(cam, 2, cam->dma_handles[2]);
mcam_reg_clear_bit(cam, REG_CTRL1, C1_TWOBUFS);
} else
mcam_reg_set_bit(cam, REG_CTRL1, C1_TWOBUFS);
@@ -514,14 +547,6 @@ static inline int mcam_check_dma_buffers(struct 
mcam_camera *cam)
  * DMA-contiguous code.
  */
 
-static bool mcam_fmt_is_planar(__u32 pfmt)
-{
-   struct mcam_format_struct *f;
-
-   f = mcam_find_format(pfmt);
-   return f->planar;
-}
-
 /*
  * Set up a contiguous buffer for the given frame.  Here also is where
  * the underrun strategy is set: if there is no buffer available, reuse
@@ -533,9 +558,7 @@ static bool mcam_fmt_is_planar(__u32 pfmt)
 static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
 {
struct mcam_vb_buffer *buf;
-   struct v4l2_pix_format *fmt = &cam->pix_format;
dma_addr_t dma_handle;
-   u32 pixel_count = fmt->width * fmt->height;
struct vb2_buffer *vb;
 
/*
@@ -559,32 +582,7 @@ static void mcam_set_contig_buffer(struct mcam_camera 
*cam, int frame)
vb = &buf->vb_buf;
 
dma_handle = vb2_dma_contig_plane_dma_addr(vb, 0);
-   buf->yuv_p.y = dma_handle;
-
-   switch (cam->pix_format.pixelformat) {
-   case V4L2_PIX_FMT_YUV422P:
-   buf->yuv_p.u = buf->yuv_p.y + pixel_count;
-   buf->yuv_p.v = buf->yuv_p.u + pixel_count / 2;
-   break;
-   case V4L2_PIX_FMT_YUV420:
-   buf->yuv_p.u = buf->yuv_p.y + pixel_count;
-   buf->yuv_p.v = buf->yuv_p.

[PATCH 09/18] marvell-ccic: use vb2 helpers and core locking

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Use the V4L2 core locking system instead of rolling your own. Switch to
the vb2 fop and ioctl helpers to get rid of a lot of code. This also made
it easy to add VB2_READ to the DMA modes, since you get read() for free
with vb2 and these helpers.

Finally remove the users field: this information is also available from
the core framework, no need to keep track of it in the driver.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 218 +---
 drivers/media/platform/marvell-ccic/mcam-core.h |   1 -
 2 files changed, 43 insertions(+), 176 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 4d50182..b6b838f 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -971,7 +971,6 @@ static int mcam_cam_init(struct mcam_camera *cam)
 {
int ret;
 
-   mutex_lock(&cam->s_mutex);
if (cam->state != S_NOTREADY)
cam_warn(cam, "Cam init with device in funky state %d",
cam->state);
@@ -979,7 +978,6 @@ static int mcam_cam_init(struct mcam_camera *cam)
/* Get/set parameters? */
cam->state = S_IDLE;
mcam_ctlr_power_down(cam);
-   mutex_unlock(&cam->s_mutex);
return ret;
 }
 
@@ -1116,6 +1114,9 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, 
unsigned int count)
INIT_LIST_HEAD(&cam->buffers);
return -EINVAL;
}
+   cam->frame_state.frames = 0;
+   cam->frame_state.singles = 0;
+   cam->frame_state.delivered = 0;
cam->sequence = 0;
/*
 * Videobuf2 sneakily hoards all the buffers and won't
@@ -1144,6 +1145,9 @@ static void mcam_vb_stop_streaming(struct vb2_queue *vq)
struct mcam_camera *cam = vb2_get_drv_priv(vq);
unsigned long flags;
 
+   cam_dbg(cam, "stop_streaming: %d frames, %d singles, %d delivered\n",
+   cam->frame_state.frames, cam->frame_state.singles,
+   cam->frame_state.delivered);
if (cam->state == S_BUFWAIT) {
/* They never gave us buffers */
cam->state = S_IDLE;
@@ -1256,7 +1260,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
vq->ops = &mcam_vb2_ops;
vq->mem_ops = &vb2_dma_contig_memops;
vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-   vq->io_modes = VB2_MMAP | VB2_USERPTR;
+   vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
cam->dma_setup = mcam_ctlr_dma_contig;
cam->frame_complete = mcam_dma_contig_done;
cam->vb_alloc_ctx = vb2_dma_contig_init_ctx(cam->dev);
@@ -1269,7 +1273,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
vq->ops = &mcam_vb2_sg_ops;
vq->mem_ops = &vb2_dma_sg_memops;
vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-   vq->io_modes = VB2_MMAP | VB2_USERPTR;
+   vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ;
cam->dma_setup = mcam_ctlr_dma_sg;
cam->frame_complete = mcam_dma_sg_done;
cam->vb_alloc_ctx_sg = vb2_dma_sg_init_ctx(cam->dev);
@@ -1284,7 +1288,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
vq->ops = &mcam_vb2_ops;
vq->mem_ops = &vb2_vmalloc_memops;
vq->buf_struct_size = sizeof(struct mcam_vb_buffer);
-   vq->io_modes = VB2_MMAP;
+   vq->io_modes = VB2_MMAP | VB2_READ;
cam->dma_setup = mcam_ctlr_dma_vmalloc;
cam->frame_complete = mcam_vmalloc_done;
 #endif
@@ -1295,7 +1299,6 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
 
 static void mcam_cleanup_vb2(struct mcam_camera *cam)
 {
-   vb2_queue_release(&cam->vb_queue);
 #ifdef MCAM_MODE_DMA_CONTIG
if (cam->buffer_mode == B_DMA_contig)
vb2_dma_contig_cleanup_ctx(cam->vb_alloc_ctx);
@@ -1312,81 +1315,6 @@ static void mcam_cleanup_vb2(struct mcam_camera *cam)
  * The long list of V4L2 ioctl() operations.
  */
 
-static int mcam_vidioc_streamon(struct file *filp, void *priv,
-   enum v4l2_buf_type type)
-{
-   struct mcam_camera *cam = video_drvdata(filp);
-   int ret;
-
-   mutex_lock(&cam->s_mutex);
-   ret = vb2_streamon(&cam->vb_queue, type);
-   mutex_unlock(&cam->s_mutex);
-   return ret;
-}
-
-
-static int mcam_vidioc_streamoff(struct file *filp, void *priv,
-   enum v4l2_buf_type type)
-{
-   struct mcam_camera *cam = video_drvdata(filp);
-   int ret;
-
-   mutex_lock(&cam->s_mutex);
-   ret = vb2_streamoff(&cam->vb_queue, type);
-   mutex_unlock(&cam->s_mutex);
-   return ret;
-}
-
-
-static int mcam_vidioc_reqbufs(struct file *filp, void *priv,
- 

[PATCH 02/18] marvell-ccic: fill in bus_info

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The bus_info field of struct v4l2_querycap wasn't filled in and
v4l2-compliance complained about that. Fix this.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/cafe-driver.c | 1 +
 drivers/media/platform/marvell-ccic/mcam-core.c   | 3 +++
 drivers/media/platform/marvell-ccic/mcam-core.h   | 2 ++
 drivers/media/platform/marvell-ccic/mmp-driver.c  | 1 +
 4 files changed, 7 insertions(+)

diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c 
b/drivers/media/platform/marvell-ccic/cafe-driver.c
index 5628453..e857405 100644
--- a/drivers/media/platform/marvell-ccic/cafe-driver.c
+++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
@@ -476,6 +476,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
mcam->plat_power_up = cafe_ctlr_power_up;
mcam->plat_power_down = cafe_ctlr_power_down;
mcam->dev = &pdev->dev;
+   snprintf(mcam->bus_info, sizeof(mcam->bus_info), "PCI:%s", 
pci_name(pdev));
/*
 * Set the clock speed for the XO 1; I don't believe this
 * driver has ever run anywhere else.
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index bf160dd..e83ca1f 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1388,8 +1388,11 @@ static int mcam_vidioc_dqbuf(struct file *filp, void 
*priv,
 static int mcam_vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
 {
+   struct mcam_camera *cam = priv;
+
strcpy(cap->driver, "marvell_ccic");
strcpy(cap->card, "marvell_ccic");
+   strlcpy(cap->bus_info, cam->bus_info, sizeof(cap->bus_info));
cap->device_caps = V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h 
b/drivers/media/platform/marvell-ccic/mcam-core.h
index aa0c6ea..46bc715 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -163,6 +163,8 @@ struct mcam_camera {
unsigned int nbufs; /* How many are alloc'd */
int next_buf;   /* Next to consume (dev_lock) */
 
+   char bus_info[32];  /* querycap bus_info */
+
/* DMA buffers - vmalloc mode */
 #ifdef MCAM_MODE_VMALLOC
unsigned int dma_buf_size;  /* allocated size */
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c 
b/drivers/media/platform/marvell-ccic/mmp-driver.c
index 0ed9b3a..b5f165a 100644
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -371,6 +371,7 @@ static int mmpcam_probe(struct platform_device *pdev)
mcam->lane = pdata->lane;
mcam->chip_id = MCAM_ARMADA610;
mcam->buffer_mode = B_DMA_sg;
+   strlcpy(mcam->bus_info, "platform:mmp-camera", sizeof(mcam->bus_info));
spin_lock_init(&mcam->dev_lock);
/*
 * Get our I/O memory.
-- 
2.1.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 10/18] marvell-ccic: add create_bufs support

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This fixes the final v4l2-compliance warning.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index b6b838f..51b7291 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1073,7 +1073,9 @@ static int mcam_vb_queue_setup(struct vb2_queue *vq,
struct mcam_camera *cam = vb2_get_drv_priv(vq);
int minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2;
 
-   sizes[0] = cam->pix_format.sizeimage;
+   if (fmt && fmt->fmt.pix.sizeimage < cam->pix_format.sizeimage)
+   return -EINVAL;
+   sizes[0] = fmt ? fmt->fmt.pix.sizeimage : cam->pix_format.sizeimage;
*num_planes = 1; /* Someday we have to support planar formats... */
if (*nbufs < minbufs)
*nbufs = minbufs;
@@ -1380,7 +1382,7 @@ static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, 
void *priv,
 * Can't do anything if the device is not idle
 * Also can't if there are streaming buffers in place.
 */
-   if (cam->state != S_IDLE || cam->vb_queue.num_buffers > 0)
+   if (cam->state != S_IDLE || vb2_is_busy(&cam->vb_queue))
return -EBUSY;
 
f = mcam_find_format(fmt->fmt.pix.pixelformat);
@@ -1573,6 +1575,7 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
.vidioc_g_input = mcam_vidioc_g_input,
.vidioc_s_input = mcam_vidioc_s_input,
.vidioc_reqbufs = vb2_ioctl_reqbufs,
+   .vidioc_create_bufs = vb2_ioctl_create_bufs,
.vidioc_querybuf= vb2_ioctl_querybuf,
.vidioc_qbuf= vb2_ioctl_qbuf,
.vidioc_dqbuf   = vb2_ioctl_dqbuf,
-- 
2.1.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 17/18] marvell-ccic: fix the bytesperline and sizeimage calculations

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

These were calculated incorrectly for the planar formats.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 1a32610..9343051 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -127,21 +127,21 @@ static struct mcam_format_struct {
.desc   = "YUV 4:2:2 PLANAR",
.pixelformat= V4L2_PIX_FMT_YUV422P,
.mbus_code  = MEDIA_BUS_FMT_YUYV8_2X8,
-   .bpp= 2,
+   .bpp= 1,
.planar = true,
},
{
.desc   = "YUV 4:2:0 PLANAR",
.pixelformat= V4L2_PIX_FMT_YUV420,
.mbus_code  = MEDIA_BUS_FMT_YUYV8_2X8,
-   .bpp= 2,
+   .bpp= 1,
.planar = true,
},
{
.desc   = "YVU 4:2:0 PLANAR",
.pixelformat= V4L2_PIX_FMT_YVU420,
.mbus_code  = MEDIA_BUS_FMT_YUYV8_2X8,
-   .bpp= 2,
+   .bpp= 1,
.planar = true,
},
{
@@ -764,6 +764,7 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
default:
widthy = fmt->bytesperline;
widthuv = 0;
+   break;
}
 
mcam_reg_write_mask(cam, REG_IMGPITCH, widthuv << 16 | widthy,
@@ -1370,16 +1371,19 @@ static int mcam_vidioc_try_fmt_vid_cap(struct file 
*filp, void *priv,
v4l2_fill_mbus_format(&mbus_fmt, pix, f->mbus_code);
ret = sensor_call(cam, video, try_mbus_fmt, &mbus_fmt);
v4l2_fill_pix_format(pix, &mbus_fmt);
+   pix->bytesperline = pix->width * f->bpp;
switch (f->pixelformat) {
+   case V4L2_PIX_FMT_YUV422P:
+   pix->sizeimage = pix->height * pix->bytesperline * 2;
+   break;
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
-   pix->bytesperline = pix->width * 3 / 2;
+   pix->sizeimage = pix->height * pix->bytesperline * 3 / 2;
break;
default:
-   pix->bytesperline = pix->width * f->bpp;
+   pix->sizeimage = pix->height * pix->bytesperline;
break;
}
-   pix->sizeimage = pix->height * pix->bytesperline;
pix->colorspace = V4L2_COLORSPACE_SRGB;
return ret;
 }
-- 
2.1.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 16/18] ov7670: use colorspace SRGB instead of JPEG

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Even though the format is Y'CbCr, the colorspace used by the sensor
is almost certainly SRGB. The sensor is also not generating JPEG data,
so it makes no sense to use V4L2_COLORSPACE_JPEG here.

Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/ov7670.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 81a1e44..504472b 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -639,7 +639,7 @@ static struct ov7670_format_struct {
 } ov7670_formats[] = {
{
.mbus_code  = MEDIA_BUS_FMT_YUYV8_2X8,
-   .colorspace = V4L2_COLORSPACE_JPEG,
+   .colorspace = V4L2_COLORSPACE_SRGB,
.regs   = ov7670_fmt_yuv422,
.cmatrix= { 128, -128, 0, -34, -94, 128 },
},
-- 
2.1.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 15/18] marvell-ccic: drop V4L2_PIX_FMT_JPEG dead code

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This driver appeared to support the JPEG format when in reality
that was just dead code. Remove it.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 2495ab6..1a32610 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -755,11 +755,6 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
widthy = fmt->width * 2;
widthuv = 0;
break;
-   case V4L2_PIX_FMT_JPEG:
-   imgsz_h = (fmt->sizeimage / fmt->bytesperline) << IMGSZ_V_SHIFT;
-   widthy = fmt->bytesperline;
-   widthuv = 0;
-   break;
case V4L2_PIX_FMT_YUV422P:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
@@ -797,10 +792,6 @@ static void mcam_ctlr_image(struct mcam_camera *cam)
mcam_reg_write_mask(cam, REG_CTRL0,
C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_YUYV, C0_DF_MASK);
break;
-   case V4L2_PIX_FMT_JPEG:
-   mcam_reg_write_mask(cam, REG_CTRL0,
-   C0_DF_YUV | C0_YUV_PACKED | C0_YUVE_YUYV, C0_DF_MASK);
-   break;
case V4L2_PIX_FMT_RGB444:
mcam_reg_write_mask(cam, REG_CTRL0,
C0_DF_RGB | C0_RGBF_444 | C0_RGB4_XRGB, C0_DF_MASK);
-- 
2.1.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 12/18] marvell-ccic: fix streaming issues

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

- fill in timestamp
- fill in field
- start the sequence counter at 0, not 1

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index a1312a5..6b7b38b 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -239,6 +239,8 @@ static void mcam_buffer_done(struct mcam_camera *cam, int 
frame,
 {
vbuf->v4l2_buf.bytesused = cam->pix_format.sizeimage;
vbuf->v4l2_buf.sequence = cam->buf_seq[frame];
+   vbuf->v4l2_buf.field = V4L2_FIELD_NONE;
+   v4l2_get_timestamp(&vbuf->v4l2_buf.timestamp);
vb2_set_plane_payload(vbuf, 0, cam->pix_format.sizeimage);
vb2_buffer_done(vbuf, VB2_BUF_STATE_DONE);
 }
@@ -1671,7 +1673,7 @@ static void mcam_frame_complete(struct mcam_camera *cam, 
int frame)
set_bit(frame, &cam->flags);
clear_bit(CF_DMA_ACTIVE, &cam->flags);
cam->next_buf = frame;
-   cam->buf_seq[frame] = ++(cam->sequence);
+   cam->buf_seq[frame] = cam->sequence++;
cam->frame_state.frames++;
/*
 * "This should never happen"
-- 
2.1.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 13/18] marvell-ccic: correctly requeue buffers

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

If start_streaming fails or stop_streaming is called, then all queued
buffers need to be given back to vb2.

This prevents vb2 from calling WARN_ON when it detects that this is not
done correctly.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 39 -
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 6b7b38b..0d94696 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -607,6 +607,7 @@ static void mcam_dma_contig_done(struct mcam_camera *cam, 
int frame)
 
if (!test_bit(CF_SINGLE_BUFFER, &cam->flags)) {
cam->frame_state.delivered++;
+   cam->vb_bufs[frame] = NULL;
mcam_buffer_done(cam, frame, &buf->vb_buf);
}
mcam_set_contig_buffer(cam, frame);
@@ -1106,6 +1107,30 @@ static void mcam_vb_buf_queue(struct vb2_buffer *vb)
mcam_read_setup(cam);
 }
 
+static void mcam_vb_requeue_bufs(struct vb2_queue *vq,
+enum vb2_buffer_state state)
+{
+   struct mcam_camera *cam = vb2_get_drv_priv(vq);
+   struct mcam_vb_buffer *buf, *node;
+   unsigned long flags;
+   unsigned i;
+
+   spin_lock_irqsave(&cam->dev_lock, flags);
+   list_for_each_entry_safe(buf, node, &cam->buffers, queue) {
+   vb2_buffer_done(&buf->vb_buf, state);
+   list_del(&buf->queue);
+   }
+   for (i = 0; i < MAX_DMA_BUFS; i++) {
+   buf = cam->vb_bufs[i];
+
+   if (buf) {
+   vb2_buffer_done(&buf->vb_buf, state);
+   cam->vb_bufs[i] = NULL;
+   }
+   }
+   spin_unlock_irqrestore(&cam->dev_lock, flags);
+}
+
 /*
  * These need to be called with the mutex held from vb2
  */
@@ -1113,9 +1138,10 @@ static int mcam_vb_start_streaming(struct vb2_queue *vq, 
unsigned int count)
 {
struct mcam_camera *cam = vb2_get_drv_priv(vq);
unsigned int frame;
+   int ret;
 
if (cam->state != S_IDLE) {
-   INIT_LIST_HEAD(&cam->buffers);
+   mcam_vb_requeue_bufs(vq, VB2_BUF_STATE_QUEUED);
return -EINVAL;
}
cam->frame_state.frames = 0;
@@ -1141,13 +1167,15 @@ static int mcam_vb_start_streaming(struct vb2_queue 
*vq, unsigned int count)
for (frame = 0; frame < cam->nbufs; frame++)
clear_bit(CF_FRAME_SOF0 + frame, &cam->flags);
 
-   return mcam_read_setup(cam);
+   ret = mcam_read_setup(cam);
+   if (ret)
+   mcam_vb_requeue_bufs(vq, VB2_BUF_STATE_QUEUED);
+   return ret;
 }
 
 static void mcam_vb_stop_streaming(struct vb2_queue *vq)
 {
struct mcam_camera *cam = vb2_get_drv_priv(vq);
-   unsigned long flags;
 
cam_dbg(cam, "stop_streaming: %d frames, %d singles, %d delivered\n",
cam->frame_state.frames, cam->frame_state.singles,
@@ -1170,9 +1198,7 @@ static void mcam_vb_stop_streaming(struct vb2_queue *vq)
 * VB2 reclaims the buffers, so we need to forget
 * about them.
 */
-   spin_lock_irqsave(&cam->dev_lock, flags);
-   INIT_LIST_HEAD(&cam->buffers);
-   spin_unlock_irqrestore(&cam->dev_lock, flags);
+   mcam_vb_requeue_bufs(vq, VB2_BUF_STATE_ERROR);
 }
 
 
@@ -1786,7 +1812,6 @@ int mccic_register(struct mcam_camera *cam)
mcam_set_config_needed(cam, 1);
cam->pix_format = mcam_def_pix_format;
cam->mbus_code = mcam_def_mbus_code;
-   INIT_LIST_HEAD(&cam->buffers);
mcam_ctlr_init(cam);
 
/*
-- 
2.1.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 08/18] marvell-ccic: implement control events

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Now that this driver uses v4l2_fh, it is trivial to add support for
control events. Again, this fixes a v4l2-compliance failure.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 8456017..4d50182 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1665,6 +1666,8 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
.vidioc_s_parm  = mcam_vidioc_s_parm,
.vidioc_enum_framesizes = mcam_vidioc_enum_framesizes,
.vidioc_enum_frameintervals = mcam_vidioc_enum_frameintervals,
+   .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+   .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register  = mcam_vidioc_g_register,
.vidioc_s_register  = mcam_vidioc_s_register,
-- 
2.1.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 04/18] ov7670: check for valid width/height in ov7670_enum_frame_interval

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The width and height should be checked in the enum_frame_interval
op. This fixes a v4l2-compliance failure.

Signed-off-by: Hans Verkuil 
---
 drivers/media/i2c/ov7670.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index b984752..81a1e44 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -1073,10 +1073,33 @@ static int ov7670_enum_frame_interval(struct 
v4l2_subdev *sd,
  struct v4l2_subdev_pad_config *cfg,
  struct v4l2_subdev_frame_interval_enum 
*fie)
 {
+   struct ov7670_info *info = to_state(sd);
+   unsigned int n_win_sizes = info->devtype->n_win_sizes;
+   int i;
+
if (fie->pad)
return -EINVAL;
if (fie->index >= ARRAY_SIZE(ov7670_frame_rates))
return -EINVAL;
+
+   /*
+* Check if the width/height is valid.
+*
+* If a minimum width/height was requested, filter out the capture
+* windows that fall outside that.
+*/
+   for (i = 0; i < n_win_sizes; i++) {
+   struct ov7670_win_size *win = &info->devtype->win_sizes[i];
+
+   if (info->min_width && win->width < info->min_width)
+   continue;
+   if (info->min_height && win->height < info->min_height)
+   continue;
+   if (fie->width == win->width && fie->height == win->height)
+   break;
+   }
+   if (i == n_win_sizes)
+   return -EINVAL;
fie->interval.numerator = 1;
fie->interval.denominator = ov7670_frame_rates[fie->index];
return 0;
-- 
2.1.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 03/18] marvell-ccic: webcam drivers shouldn't support g/s_std

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

TV standards make no sense for webcam drivers, so drop these dummy
functions. This stops v4l2-compliance from complaining about this.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 15 ---
 1 file changed, 15 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index e83ca1f..76357cf 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1508,7 +1508,6 @@ static int mcam_vidioc_enum_input(struct file *filp, void 
*priv,
return -EINVAL;
 
input->type = V4L2_INPUT_TYPE_CAMERA;
-   input->std = V4L2_STD_ALL; /* Not sure what should go here */
strcpy(input->name, "Camera");
return 0;
 }
@@ -1526,18 +1525,6 @@ static int mcam_vidioc_s_input(struct file *filp, void 
*priv, unsigned int i)
return 0;
 }
 
-/* from vivi.c */
-static int mcam_vidioc_s_std(struct file *filp, void *priv, v4l2_std_id a)
-{
-   return 0;
-}
-
-static int mcam_vidioc_g_std(struct file *filp, void *priv, v4l2_std_id *a)
-{
-   *a = V4L2_STD_NTSC_M;
-   return 0;
-}
-
 /*
  * G/S_PARM.  Most of this is done by the sensor, but we are
  * the level which controls the number of read buffers.
@@ -1666,8 +1653,6 @@ static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = {
.vidioc_enum_input  = mcam_vidioc_enum_input,
.vidioc_g_input = mcam_vidioc_g_input,
.vidioc_s_input = mcam_vidioc_s_input,
-   .vidioc_s_std   = mcam_vidioc_s_std,
-   .vidioc_g_std   = mcam_vidioc_g_std,
.vidioc_reqbufs = mcam_vidioc_reqbufs,
.vidioc_querybuf= mcam_vidioc_querybuf,
.vidioc_qbuf= mcam_vidioc_qbuf,
-- 
2.1.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 07/18] marvell-ccic: switch to struct v4l2_fh

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Use struct v4l2_fh to represent a filehandle. This fixes the missing
g/s_priority handling of this driver that v4l2-compliance complained
about.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 48 +
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 51c9c8c..8456017 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1314,7 +1314,7 @@ static void mcam_cleanup_vb2(struct mcam_camera *cam)
 static int mcam_vidioc_streamon(struct file *filp, void *priv,
enum v4l2_buf_type type)
 {
-   struct mcam_camera *cam = filp->private_data;
+   struct mcam_camera *cam = video_drvdata(filp);
int ret;
 
mutex_lock(&cam->s_mutex);
@@ -1327,7 +1327,7 @@ static int mcam_vidioc_streamon(struct file *filp, void 
*priv,
 static int mcam_vidioc_streamoff(struct file *filp, void *priv,
enum v4l2_buf_type type)
 {
-   struct mcam_camera *cam = filp->private_data;
+   struct mcam_camera *cam = video_drvdata(filp);
int ret;
 
mutex_lock(&cam->s_mutex);
@@ -1340,7 +1340,7 @@ static int mcam_vidioc_streamoff(struct file *filp, void 
*priv,
 static int mcam_vidioc_reqbufs(struct file *filp, void *priv,
struct v4l2_requestbuffers *req)
 {
-   struct mcam_camera *cam = filp->private_data;
+   struct mcam_camera *cam = video_drvdata(filp);
int ret;
 
mutex_lock(&cam->s_mutex);
@@ -1353,7 +1353,7 @@ static int mcam_vidioc_reqbufs(struct file *filp, void 
*priv,
 static int mcam_vidioc_querybuf(struct file *filp, void *priv,
struct v4l2_buffer *buf)
 {
-   struct mcam_camera *cam = filp->private_data;
+   struct mcam_camera *cam = video_drvdata(filp);
int ret;
 
mutex_lock(&cam->s_mutex);
@@ -1365,7 +1365,7 @@ static int mcam_vidioc_querybuf(struct file *filp, void 
*priv,
 static int mcam_vidioc_qbuf(struct file *filp, void *priv,
struct v4l2_buffer *buf)
 {
-   struct mcam_camera *cam = filp->private_data;
+   struct mcam_camera *cam = video_drvdata(filp);
int ret;
 
mutex_lock(&cam->s_mutex);
@@ -1377,7 +1377,7 @@ static int mcam_vidioc_qbuf(struct file *filp, void *priv,
 static int mcam_vidioc_dqbuf(struct file *filp, void *priv,
struct v4l2_buffer *buf)
 {
-   struct mcam_camera *cam = filp->private_data;
+   struct mcam_camera *cam = video_drvdata(filp);
int ret;
 
mutex_lock(&cam->s_mutex);
@@ -1389,7 +1389,7 @@ static int mcam_vidioc_dqbuf(struct file *filp, void 
*priv,
 static int mcam_vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
 {
-   struct mcam_camera *cam = priv;
+   struct mcam_camera *cam = video_drvdata(file);
 
strcpy(cap->driver, "marvell_ccic");
strcpy(cap->card, "marvell_ccic");
@@ -1415,7 +1415,7 @@ static int mcam_vidioc_enum_fmt_vid_cap(struct file *filp,
 static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *fmt)
 {
-   struct mcam_camera *cam = priv;
+   struct mcam_camera *cam = video_drvdata(filp);
struct mcam_format_struct *f;
struct v4l2_pix_format *pix = &fmt->fmt.pix;
struct v4l2_mbus_framefmt mbus_fmt;
@@ -1445,7 +1445,7 @@ static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, 
void *priv,
 static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *fmt)
 {
-   struct mcam_camera *cam = priv;
+   struct mcam_camera *cam = video_drvdata(filp);
struct mcam_format_struct *f;
int ret;
 
@@ -1494,7 +1494,7 @@ out:
 static int mcam_vidioc_g_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *f)
 {
-   struct mcam_camera *cam = priv;
+   struct mcam_camera *cam = video_drvdata(filp);
 
f->fmt.pix = cam->pix_format;
return 0;
@@ -1534,7 +1534,7 @@ static int mcam_vidioc_s_input(struct file *filp, void 
*priv, unsigned int i)
 static int mcam_vidioc_g_parm(struct file *filp, void *priv,
struct v4l2_streamparm *parms)
 {
-   struct mcam_camera *cam = priv;
+   struct mcam_camera *cam = video_drvdata(filp);
int ret;
 
mutex_lock(&cam->s_mutex);
@@ -1547,7 +1547,7 @@ static int mcam_vidioc_g_parm(struct file *filp, void 
*priv,
 static int mcam_vidioc_s_parm(struct file *filp, void *priv,
struct v4l2_streamparm *parms)
 {
-   struct mcam_camera *cam = priv;
+   struct mcam_camera *cam = video_drvdata(filp);
int ret;
 
mutex_lock(&cam->s_mutex);
@@ -1560,7 +1560,7 @@ static int mcam_vidioc_s_parm(struct file *filp, void 
*priv,
 static int mcam_vidioc_enum_framesizes(str

[PATCH 06/18] marvell-ccic: control handler fixes

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

No controls were reported, even though the ov7670 does have controls.

Two reasons for this: the v4l2_ctrl_handler_init() call must come
before the ov7670 is loaded (otherwise the ov7670 won't know that
its controls should be added to the bridge driver), and the
v4l2_ctrl_handler_free() call at the end should only be called if
the ret value is non-zero (otherwise you would just free all the
controls that were just added).

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 7e54cef..51c9c8c 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1919,6 +1919,14 @@ int mccic_register(struct mcam_camera *cam)
mcam_ctlr_init(cam);
 
/*
+* Get the v4l2 setup done.
+*/
+   ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10);
+   if (ret)
+   goto out_unregister;
+   cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler;
+
+   /*
 * Try to find the sensor.
 */
sensor_cfg.clock_speed = cam->clock_speed;
@@ -1934,13 +1942,6 @@ int mccic_register(struct mcam_camera *cam)
ret = mcam_cam_init(cam);
if (ret)
goto out_unregister;
-   /*
-* Get the v4l2 setup done.
-*/
-   ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10);
-   if (ret)
-   goto out_unregister;
-   cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler;
 
mutex_lock(&cam->s_mutex);
cam->vdev = mcam_v4l_template;
@@ -1960,10 +1961,12 @@ int mccic_register(struct mcam_camera *cam)
}
 
 out:
-   v4l2_ctrl_handler_free(&cam->ctrl_handler);
+   if (ret)
+   v4l2_ctrl_handler_free(&cam->ctrl_handler);
mutex_unlock(&cam->s_mutex);
return ret;
 out_unregister:
+   v4l2_ctrl_handler_free(&cam->ctrl_handler);
v4l2_device_unregister(&cam->v4l2_dev);
return ret;
 }
-- 
2.1.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 05/18] marvell-ccic: fill in colorspace

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The colorspace field wasn't filled in properly. This fixes a v4l2-compliance
failure.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 76357cf..7e54cef 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -188,6 +188,7 @@ static const struct v4l2_pix_format mcam_def_pix_format = {
.field  = V4L2_FIELD_NONE,
.bytesperline   = VGA_WIDTH*2,
.sizeimage  = VGA_WIDTH*VGA_HEIGHT*2,
+   .colorspace = V4L2_COLORSPACE_SRGB,
 };
 
 static const u32 mcam_def_mbus_code = MEDIA_BUS_FMT_YUYV8_2X8;
@@ -1437,6 +1438,7 @@ static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, 
void *priv,
break;
}
pix->sizeimage = pix->height * pix->bytesperline;
+   pix->colorspace = V4L2_COLORSPACE_SRGB;
return ret;
 }
 
-- 
2.1.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 01/18] marvell-ccic: fix vb2 warning

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

We must set timestamp_flags in vb2_queue otherwise vb2 will complain
loudly about it.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/marvell-ccic/mcam-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c 
b/drivers/media/platform/marvell-ccic/mcam-core.c
index 9c64b5d..bf160dd 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1246,6 +1246,7 @@ static int mcam_setup_vb2(struct mcam_camera *cam)
vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vq->drv_priv = cam;
vq->lock = &cam->s_mutex;
+   vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
INIT_LIST_HEAD(&cam->buffers);
switch (cam->buffer_mode) {
case B_DMA_contig:
-- 
2.1.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


Re: [PATCH v4 1/2] media/v4l2-ctrls: Always run s_ctrl on volatile ctrls

2015-03-09 Thread Ricardo Ribalda Delgado
Hello

Back from holidays and back to this issue. Sorry for the delay.

> I'm not sure about Ricardo's use case, is it the one we've discussed on #v4l ?
> If so, and if I recall correctly, the idea was to perform an action with a
> parameter, and didn't require volatility.

In my case, there is a trigger overflow bit. The user acks the trigger
overflow by writting any value to the control.

There is no parameter. In that sense it looks like a volatile read + a
button on a controll.

> Your proposal is interesting as well, but I'm not sure about the
> V4L2_CTRL_FLAG_ACTION name. Aren't all controls supposed to have an action of
> some sort ? That's nitpicking of course.

What about the name STATELESS_WRITE ? or perhaps VOLATILE_WRITE? I
dont care about the name :), but better have it solved before I write
the doc :P

>
> Also, should the action flag be automatically set for button controls ? Button
> controls would in a way become type-less controls with the action flag set,
> that's interesting. I suppose type-less controls without the action flag don't
> make sense.

I agree!


Best regards and thanks!

-- 
Ricardo Ribalda
--
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 v2 2/7] media: rc: Add cec protocol handling

2015-03-09 Thread Bastien Nocera
On Mon, 2015-03-09 at 17:22 +0100, Kamil Debski wrote:
> Hi Mauro,
> 
> From: Mauro Carvalho Chehab [mailto:mche...@osg.samsung.com]
> Sent: Sunday, March 08, 2015 3:21 PM
> 
> > Em Thu, 22 Jan 2015 17:04:34 +0100
> > Kamil Debski  escreveu:
> > 
> > (c/c linux-input ML)
> > 
> > > Add cec protocol handling the RC framework.
> > 
> > I added some comments, that reflects my understanding from what's 
> > there at the keymap definitions found at:
> > http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf
> 
> Thank you very much for the review, Mauro. Your comments are very 
> much appreciated.

How does one use this new support? If I plug in my laptop to my TV, 
will using the TV's remote automatically send those key events to the 
laptop?

Cheers
--
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 18/19] usbvision: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/usbvision/usbvision-video.c | 70 ++-
 drivers/media/usb/usbvision/usbvision.h   |  4 +-
 2 files changed, 28 insertions(+), 46 deletions(-)

diff --git a/drivers/media/usb/usbvision/usbvision-video.c 
b/drivers/media/usb/usbvision/usbvision-video.c
index cd2fbf1..2579c87 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -471,7 +471,7 @@ static int vidioc_g_register(struct file *file, void *priv,
/* NT100x has a 8-bit register space */
err_code = usbvision_read_reg(usbvision, reg->reg&0xff);
if (err_code < 0) {
-   dev_err(&usbvision->vdev->dev,
+   dev_err(&usbvision->vdev.dev,
"%s: VIDIOC_DBG_G_REGISTER failed: error %d\n",
__func__, err_code);
return err_code;
@@ -490,7 +490,7 @@ static int vidioc_s_register(struct file *file, void *priv,
/* NT100x has a 8-bit register space */
err_code = usbvision_write_reg(usbvision, reg->reg & 0xff, reg->val);
if (err_code < 0) {
-   dev_err(&usbvision->vdev->dev,
+   dev_err(&usbvision->vdev.dev,
"%s: VIDIOC_DBG_S_REGISTER failed: error %d\n",
__func__, err_code);
return err_code;
@@ -1157,7 +1157,7 @@ static int usbvision_radio_open(struct file *file)
if (mutex_lock_interruptible(&usbvision->v4l2_lock))
return -ERESTARTSYS;
if (usbvision->user) {
-   dev_err(&usbvision->rdev->dev,
+   dev_err(&usbvision->rdev.dev,
"%s: Someone tried to open an already opened USBVision 
Radio!\n",
__func__);
err_code = -EBUSY;
@@ -1280,7 +1280,7 @@ static struct video_device usbvision_video_template = {
.fops   = &usbvision_fops,
.ioctl_ops  = &usbvision_ioctl_ops,
.name   = "usbvision-video",
-   .release= video_device_release,
+   .release= video_device_release_empty,
.tvnorms= USBVISION_NORMS,
 };
 
@@ -1312,58 +1312,46 @@ static const struct v4l2_ioctl_ops 
usbvision_radio_ioctl_ops = {
 static struct video_device usbvision_radio_template = {
.fops   = &usbvision_radio_fops,
.name   = "usbvision-radio",
-   .release= video_device_release,
+   .release= video_device_release_empty,
.ioctl_ops  = &usbvision_radio_ioctl_ops,
 };
 
 
-static struct video_device *usbvision_vdev_init(struct usb_usbvision 
*usbvision,
-   struct video_device *vdev_template,
-   char *name)
+static void usbvision_vdev_init(struct usb_usbvision *usbvision,
+   struct video_device *vdev,
+   const struct video_device *vdev_template,
+   const char *name)
 {
struct usb_device *usb_dev = usbvision->dev;
-   struct video_device *vdev;
 
if (usb_dev == NULL) {
dev_err(&usbvision->dev->dev,
"%s: usbvision->dev is not set\n", __func__);
-   return NULL;
+   return;
}
 
-   vdev = video_device_alloc();
-   if (NULL == vdev)
-   return NULL;
*vdev = *vdev_template;
vdev->lock = &usbvision->v4l2_lock;
vdev->v4l2_dev = &usbvision->v4l2_dev;
snprintf(vdev->name, sizeof(vdev->name), "%s", name);
video_set_drvdata(vdev, usbvision);
-   return vdev;
 }
 
 /* unregister video4linux devices */
 static void usbvision_unregister_video(struct usb_usbvision *usbvision)
 {
/* Radio Device: */
-   if (usbvision->rdev) {
+   if (video_is_registered(&usbvision->rdev)) {
PDEBUG(DBG_PROBE, "unregister %s [v4l2]",
-  video_device_node_name(usbvision->rdev));
-   if (video_is_registered(usbvision->rdev))
-   video_unregister_device(usbvision->rdev);
-   else
-   video_device_release(usbvision->rdev);
-   usbvision->rdev = NULL;
+  video_device_node_name(&usbvision->rdev));
+   video_unregister_device(&usbvision->rdev);
}
 
/* Video Device: */
-   if (usbvision->vdev) {
+   if (video_is_registered(&usbvision->vdev)) {
PDEBUG(DBG_PROBE, "unregister %s [v4l2]",
-  video_device_node_name(usbvision->vdev));
-   if (video_is_registered(usbvision->vdev))
-   video_unregister_device(usbvisi

[PATCH 19/19] cx231xx: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/cx231xx/cx231xx-417.c   | 33 ---
 drivers/media/usb/cx231xx/cx231xx-cards.c |  6 +-
 drivers/media/usb/cx231xx/cx231xx-video.c | 94 ++-
 drivers/media/usb/cx231xx/cx231xx.h   |  8 +--
 4 files changed, 49 insertions(+), 92 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c 
b/drivers/media/usb/cx231xx/cx231xx-417.c
index 3f295b4..983ea83 100644
--- a/drivers/media/usb/cx231xx/cx231xx-417.c
+++ b/drivers/media/usb/cx231xx/cx231xx-417.c
@@ -1868,13 +1868,9 @@ void cx231xx_417_unregister(struct cx231xx *dev)
dprintk(1, "%s()\n", __func__);
dprintk(3, "%s()\n", __func__);
 
-   if (dev->v4l_device) {
-   if (-1 != dev->v4l_device->minor)
-   video_unregister_device(dev->v4l_device);
-   else
-   video_device_release(dev->v4l_device);
+   if (video_is_registered(&dev->v4l_device)) {
+   video_unregister_device(&dev->v4l_device);
v4l2_ctrl_handler_free(&dev->mpeg_ctrl_handler.hdl);
-   dev->v4l_device = NULL;
}
 }
 
@@ -1911,25 +1907,21 @@ static struct cx2341x_handler_ops cx231xx_ops = {
.s_video_encoding = cx231xx_s_video_encoding,
 };
 
-static struct video_device *cx231xx_video_dev_alloc(
+static void cx231xx_video_dev_init(
struct cx231xx *dev,
struct usb_device *usbdev,
-   struct video_device *template,
-   char *type)
+   struct video_device *vfd,
+   const struct video_device *template,
+   const char *type)
 {
-   struct video_device *vfd;
-
dprintk(1, "%s()\n", __func__);
-   vfd = video_device_alloc();
-   if (NULL == vfd)
-   return NULL;
*vfd = *template;
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name,
type, cx231xx_boards[dev->model].name);
 
vfd->v4l2_dev = &dev->v4l2_dev;
vfd->lock = &dev->lock;
-   vfd->release = video_device_release;
+   vfd->release = video_device_release_empty;
vfd->ctrl_handler = &dev->mpeg_ctrl_handler.hdl;
video_set_drvdata(vfd, dev);
if (dev->tuner_type == TUNER_ABSENT) {
@@ -1938,9 +1930,6 @@ static struct video_device *cx231xx_video_dev_alloc(
v4l2_disable_ioctl(vfd, VIDIOC_G_TUNER);
v4l2_disable_ioctl(vfd, VIDIOC_S_TUNER);
}
-
-   return vfd;
-
 }
 
 int cx231xx_417_register(struct cx231xx *dev)
@@ -1983,9 +1972,9 @@ int cx231xx_417_register(struct cx231xx *dev)
cx2341x_handler_set_50hz(&dev->mpeg_ctrl_handler, false);
 
/* Allocate and initialize V4L video device */
-   dev->v4l_device = cx231xx_video_dev_alloc(dev,
-   dev->udev, &cx231xx_mpeg_template, "mpeg");
-   err = video_register_device(dev->v4l_device,
+   cx231xx_video_dev_init(dev, dev->udev,
+   &dev->v4l_device, &cx231xx_mpeg_template, "mpeg");
+   err = video_register_device(&dev->v4l_device,
VFL_TYPE_GRABBER, -1);
if (err < 0) {
dprintk(3, "%s: can't register mpeg device\n", dev->name);
@@ -1994,7 +1983,7 @@ int cx231xx_417_register(struct cx231xx *dev)
}
 
dprintk(3, "%s: registered device video%d [mpeg]\n",
-  dev->name, dev->v4l_device->num);
+  dev->name, dev->v4l_device.num);
 
return 0;
 }
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 85220b9..fe00da1 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1230,9 +1230,9 @@ static void cx231xx_create_media_graph(struct cx231xx 
*dev)
if (tuner)
media_entity_create_link(tuner, 0, decoder, 0,
 MEDIA_LNK_FL_ENABLED);
-   media_entity_create_link(decoder, 1, &dev->vdev->entity, 0,
+   media_entity_create_link(decoder, 1, &dev->vdev.entity, 0,
 MEDIA_LNK_FL_ENABLED);
-   media_entity_create_link(decoder, 2, &dev->vbi_dev->entity, 0,
+   media_entity_create_link(decoder, 2, &dev->vbi_dev.entity, 0,
 MEDIA_LNK_FL_ENABLED);
 #endif
 }
@@ -1748,7 +1748,7 @@ static void cx231xx_usb_disconnect(struct usb_interface 
*interface)
if (dev->users) {
dev_warn(dev->dev,
 "device %s is open! Deregistration and memory 
deallocation are deferred on close.\n",
-video_device_node_name(dev->vdev));
+video_device_node_name(&dev->vdev));
 
/* Even having users, it is safe to remove the RC i2c driver */
cx231xx_ir_exit(dev);
diff --git a/drivers/med

[PATCH 16/19] tm6000: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/tm6000/tm6000-video.c | 59 +
 drivers/media/usb/tm6000/tm6000.h   |  4 +--
 2 files changed, 17 insertions(+), 46 deletions(-)

diff --git a/drivers/media/usb/tm6000/tm6000-video.c 
b/drivers/media/usb/tm6000/tm6000-video.c
index 0f14d3c..77ce9ef 100644
--- a/drivers/media/usb/tm6000/tm6000-video.c
+++ b/drivers/media/usb/tm6000/tm6000-video.c
@@ -1576,7 +1576,7 @@ static struct video_device tm6000_template = {
.name   = "tm6000",
.fops   = &tm6000_fops,
.ioctl_ops  = &video_ioctl_ops,
-   .release= video_device_release,
+   .release= video_device_release_empty,
.tvnorms= TM6000_STD,
 };
 
@@ -1609,25 +1609,19 @@ static struct video_device tm6000_radio_template = {
  * --
  */
 
-static struct video_device *vdev_init(struct tm6000_core *dev,
+static void vdev_init(struct tm6000_core *dev,
+   struct video_device *vfd,
const struct video_device
*template, const char *type_name)
 {
-   struct video_device *vfd;
-
-   vfd = video_device_alloc();
-   if (NULL == vfd)
-   return NULL;
-
*vfd = *template;
vfd->v4l2_dev = &dev->v4l2_dev;
-   vfd->release = video_device_release;
+   vfd->release = video_device_release_empty;
vfd->lock = &dev->lock;
 
snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
 
video_set_drvdata(vfd, dev);
-   return vfd;
 }
 
 int tm6000_v4l2_register(struct tm6000_core *dev)
@@ -1658,62 +1652,46 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
if (ret)
goto free_ctrl;
 
-   dev->vfd = vdev_init(dev, &tm6000_template, "video");
+   vdev_init(dev, &dev->vfd, &tm6000_template, "video");
 
-   if (!dev->vfd) {
-   printk(KERN_INFO "%s: can't register video device\n",
-  dev->name);
-   ret = -ENOMEM;
-   goto free_ctrl;
-   }
-   dev->vfd->ctrl_handler = &dev->ctrl_handler;
+   dev->vfd.ctrl_handler = &dev->ctrl_handler;
 
/* init video dma queues */
INIT_LIST_HEAD(&dev->vidq.active);
INIT_LIST_HEAD(&dev->vidq.queued);
 
-   ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
+   ret = video_register_device(&dev->vfd, VFL_TYPE_GRABBER, video_nr);
 
if (ret < 0) {
printk(KERN_INFO "%s: can't register video device\n",
   dev->name);
-   video_device_release(dev->vfd);
-   dev->vfd = NULL;
goto free_ctrl;
}
 
printk(KERN_INFO "%s: registered device %s\n",
-  dev->name, video_device_node_name(dev->vfd));
+  dev->name, video_device_node_name(&dev->vfd));
 
if (dev->caps.has_radio) {
-   dev->radio_dev = vdev_init(dev, &tm6000_radio_template,
+   vdev_init(dev, &dev->radio_dev, &tm6000_radio_template,
   "radio");
-   if (!dev->radio_dev) {
-   printk(KERN_INFO "%s: can't register radio device\n",
-  dev->name);
-   ret = -ENXIO;
-   goto unreg_video;
-   }
-
-   dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler;
-   ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO,
+   dev->radio_dev.ctrl_handler = &dev->radio_ctrl_handler;
+   ret = video_register_device(&dev->radio_dev, VFL_TYPE_RADIO,
radio_nr);
if (ret < 0) {
printk(KERN_INFO "%s: can't register radio device\n",
   dev->name);
-   video_device_release(dev->radio_dev);
goto unreg_video;
}
 
printk(KERN_INFO "%s: registered device %s\n",
-  dev->name, video_device_node_name(dev->radio_dev));
+  dev->name, video_device_node_name(&dev->radio_dev));
}
 
printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board 
(Load status: %d)\n", ret);
return ret;
 
 unreg_video:
-   video_unregister_device(dev->vfd);
+   video_unregister_device(&dev->vfd);
 free_ctrl:
v4l2_ctrl_handler_free(&dev->ctrl_handler);
v4l2_ctrl_handler_free(&dev->radio_ctrl_handler);
@@ -1722,19 +1700,12 @@ free_ctrl:
 
 int tm6000_v4l2_unregister(struct tm6000_core *dev)
 {
-   video_unregister_device(dev->vfd);
+   video_unregister_device(&dev->

[PATCH 10/19] sta2x11: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
Cc: Federico Vaga 
---
 drivers/media/pci/sta2x11/sta2x11_vip.c | 34 -
 1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c 
b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 22450f5..b8358df 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -127,7 +127,7 @@ static inline struct vip_buffer *to_vip_buffer(struct 
vb2_buffer *vb2)
  */
 struct sta2x11_vip {
struct v4l2_device v4l2_dev;
-   struct video_device *video_dev;
+   struct video_device video_dev;
struct pci_dev *pdev;
struct i2c_adapter *adapter;
unsigned int register_save_area[IRQ_COUNT + SAVE_COUNT + AUX_COUNT];
@@ -763,7 +763,7 @@ static const struct v4l2_ioctl_ops vip_ioctl_ops = {
 
 static struct video_device video_dev_template = {
.name = KBUILD_MODNAME,
-   .release = video_device_release,
+   .release = video_device_release_empty,
.fops = &vip_fops,
.ioctl_ops = &vip_ioctl_ops,
.tvnorms = V4L2_STD_ALL,
@@ -1082,19 +1082,13 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev,
goto release_buf;
}
 
-   /* Alloc, initialize and register video device */
-   vip->video_dev = video_device_alloc();
-   if (!vip->video_dev) {
-   ret = -ENOMEM;
-   goto release_irq;
-   }
+   /* Initialize and register video device */
+   vip->video_dev = video_dev_template;
+   vip->video_dev.v4l2_dev = &vip->v4l2_dev;
+   vip->video_dev.queue = &vip->vb_vidq;
+   video_set_drvdata(&vip->video_dev, vip);
 
-   vip->video_dev = &video_dev_template;
-   vip->video_dev->v4l2_dev = &vip->v4l2_dev;
-   vip->video_dev->queue = &vip->vb_vidq;
-   video_set_drvdata(vip->video_dev, vip);
-
-   ret = video_register_device(vip->video_dev, VFL_TYPE_GRABBER, -1);
+   ret = video_register_device(&vip->video_dev, VFL_TYPE_GRABBER, -1);
if (ret)
goto vrelease;
 
@@ -1124,12 +1118,9 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev,
return 0;
 
 vunreg:
-   video_set_drvdata(vip->video_dev, NULL);
+   video_set_drvdata(&vip->video_dev, NULL);
 vrelease:
-   if (video_is_registered(vip->video_dev))
-   video_unregister_device(vip->video_dev);
-   else
-   video_device_release(vip->video_dev);
+   video_unregister_device(&vip->video_dev);
 release_irq:
free_irq(pdev->irq, vip);
 release_buf:
@@ -1175,9 +1166,8 @@ static void sta2x11_vip_remove_one(struct pci_dev *pdev)
 
sta2x11_vip_clear_register(vip);
 
-   video_set_drvdata(vip->video_dev, NULL);
-   video_unregister_device(vip->video_dev);
-   /*do not call video_device_release() here, is already done */
+   video_set_drvdata(&vip->video_dev, NULL);
+   video_unregister_device(&vip->video_dev);
free_irq(pdev->irq, vip);
pci_disable_msi(pdev);
vb2_queue_release(&vip->vb_vidq);
-- 
2.1.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 08/19] bttv: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/pci/bt8xx/bttv-driver.c | 73 +++
 drivers/media/pci/bt8xx/bttvp.h   |  6 +--
 2 files changed, 25 insertions(+), 54 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c 
b/drivers/media/pci/bt8xx/bttv-driver.c
index 4ec2a3c..bc12060 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2474,7 +2474,7 @@ static int bttv_querycap(struct file *file, void  *priv,
return -EINVAL;
 
strlcpy(cap->driver, "bttv", sizeof(cap->driver));
-   strlcpy(cap->card, btv->video_dev->name, sizeof(cap->card));
+   strlcpy(cap->card, btv->video_dev.name, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
 "PCI:%s", pci_name(btv->c.pci));
cap->capabilities =
@@ -2484,9 +2484,9 @@ static int bttv_querycap(struct file *file, void  *priv,
V4L2_CAP_DEVICE_CAPS;
if (no_overlay <= 0)
cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
-   if (btv->vbi_dev)
+   if (video_is_registered(&btv->vbi_dev))
cap->capabilities |= V4L2_CAP_VBI_CAPTURE;
-   if (btv->radio_dev)
+   if (video_is_registered(&btv->radio_dev))
cap->capabilities |= V4L2_CAP_RADIO;
 
/*
@@ -3905,18 +3905,14 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
 /* --- */
 /* initialization  */
 
-static struct video_device *vdev_init(struct bttv *btv,
- const struct video_device *template,
- const char *type_name)
+static void vdev_init(struct bttv *btv,
+ struct video_device *vfd,
+ const struct video_device *template,
+ const char *type_name)
 {
-   struct video_device *vfd;
-
-   vfd = video_device_alloc();
-   if (NULL == vfd)
-   return NULL;
*vfd = *template;
vfd->v4l2_dev = &btv->c.v4l2_dev;
-   vfd->release = video_device_release;
+   vfd->release = video_device_release_empty;
video_set_drvdata(vfd, btv);
snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)",
 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "",
@@ -3927,32 +3923,13 @@ static struct video_device *vdev_init(struct bttv *btv,
v4l2_disable_ioctl(vfd, VIDIOC_G_TUNER);
v4l2_disable_ioctl(vfd, VIDIOC_S_TUNER);
}
-   return vfd;
 }
 
 static void bttv_unregister_video(struct bttv *btv)
 {
-   if (btv->video_dev) {
-   if (video_is_registered(btv->video_dev))
-   video_unregister_device(btv->video_dev);
-   else
-   video_device_release(btv->video_dev);
-   btv->video_dev = NULL;
-   }
-   if (btv->vbi_dev) {
-   if (video_is_registered(btv->vbi_dev))
-   video_unregister_device(btv->vbi_dev);
-   else
-   video_device_release(btv->vbi_dev);
-   btv->vbi_dev = NULL;
-   }
-   if (btv->radio_dev) {
-   if (video_is_registered(btv->radio_dev))
-   video_unregister_device(btv->radio_dev);
-   else
-   video_device_release(btv->radio_dev);
-   btv->radio_dev = NULL;
-   }
+   video_unregister_device(&btv->video_dev);
+   video_unregister_device(&btv->vbi_dev);
+   video_unregister_device(&btv->radio_dev);
 }
 
 /* register video4linux devices */
@@ -3962,44 +3939,38 @@ static int bttv_register_video(struct bttv *btv)
pr_notice("Overlay support disabled\n");
 
/* video */
-   btv->video_dev = vdev_init(btv, &bttv_video_template, "video");
+   vdev_init(btv, &btv->video_dev, &bttv_video_template, "video");
 
-   if (NULL == btv->video_dev)
-   goto err;
-   if (video_register_device(btv->video_dev, VFL_TYPE_GRABBER,
+   if (video_register_device(&btv->video_dev, VFL_TYPE_GRABBER,
  video_nr[btv->c.nr]) < 0)
goto err;
pr_info("%d: registered device %s\n",
-   btv->c.nr, video_device_node_name(btv->video_dev));
-   if (device_create_file(&btv->video_dev->dev,
+   btv->c.nr, video_device_node_name(&btv->video_dev));
+   if (device_create_file(&btv->video_dev.dev,
 &dev_attr_card)<0) {
pr_err("%d: device_create_file 'card' failed\n", btv->c.nr);
goto err;
}
 
/* vbi */
-   btv->vbi_dev = vdev_

[PATCH 11/19] m2m-deinterlace: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
Cc: Javier Martin 
---
 drivers/media/platform/m2m-deinterlace.c | 21 ++---
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/m2m-deinterlace.c 
b/drivers/media/platform/m2m-deinterlace.c
index b70c1ae..92d9549 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -127,7 +127,7 @@ static struct deinterlace_fmt *find_format(struct 
v4l2_format *f)
 
 struct deinterlace_dev {
struct v4l2_device  v4l2_dev;
-   struct video_device *vfd;
+   struct video_device vfd;
 
atomic_tbusy;
struct mutexdev_mutex;
@@ -983,7 +983,7 @@ static struct video_device deinterlace_videodev = {
.fops   = &deinterlace_fops,
.ioctl_ops  = &deinterlace_ioctl_ops,
.minor  = -1,
-   .release= video_device_release,
+   .release= video_device_release_empty,
.vfl_dir= VFL_DIR_M2M,
 };
 
@@ -1026,13 +1026,7 @@ static int deinterlace_probe(struct platform_device 
*pdev)
atomic_set(&pcdev->busy, 0);
mutex_init(&pcdev->dev_mutex);
 
-   vfd = video_device_alloc();
-   if (!vfd) {
-   v4l2_err(&pcdev->v4l2_dev, "Failed to allocate video device\n");
-   ret = -ENOMEM;
-   goto unreg_dev;
-   }
-
+   vfd = &pcdev->vfd;
*vfd = deinterlace_videodev;
vfd->lock = &pcdev->dev_mutex;
vfd->v4l2_dev = &pcdev->v4l2_dev;
@@ -1040,12 +1034,11 @@ static int deinterlace_probe(struct platform_device 
*pdev)
ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
if (ret) {
v4l2_err(&pcdev->v4l2_dev, "Failed to register video device\n");
-   goto rel_vdev;
+   goto unreg_dev;
}
 
video_set_drvdata(vfd, pcdev);
snprintf(vfd->name, sizeof(vfd->name), "%s", deinterlace_videodev.name);
-   pcdev->vfd = vfd;
v4l2_info(&pcdev->v4l2_dev, MEM2MEM_TEST_MODULE_NAME
" Device registered as /dev/video%d\n", vfd->num);
 
@@ -1069,11 +1062,9 @@ static int deinterlace_probe(struct platform_device 
*pdev)
 
v4l2_m2m_release(pcdev->m2m_dev);
 err_m2m:
-   video_unregister_device(pcdev->vfd);
+   video_unregister_device(&pcdev->vfd);
 err_ctx:
vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
-rel_vdev:
-   video_device_release(vfd);
 unreg_dev:
v4l2_device_unregister(&pcdev->v4l2_dev);
 rel_dma:
@@ -1088,7 +1079,7 @@ static int deinterlace_remove(struct platform_device 
*pdev)
 
v4l2_info(&pcdev->v4l2_dev, "Removing " MEM2MEM_TEST_MODULE_NAME);
v4l2_m2m_release(pcdev->m2m_dev);
-   video_unregister_device(pcdev->vfd);
+   video_unregister_device(&pcdev->vfd);
v4l2_device_unregister(&pcdev->v4l2_dev);
vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
dma_release_channel(pcdev->dma_chan);
-- 
2.1.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 13/19] wl128x: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/radio/wl128x/fmdrv_v4l2.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c 
b/drivers/media/radio/wl128x/fmdrv_v4l2.c
index a5bd3f6..fb42f0f 100644
--- a/drivers/media/radio/wl128x/fmdrv_v4l2.c
+++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c
@@ -36,7 +36,7 @@
 #include "fmdrv_rx.h"
 #include "fmdrv_tx.h"
 
-static struct video_device *gradio_dev;
+static struct video_device gradio_dev;
 static u8 radio_disconnected;
 
 /* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
@@ -517,7 +517,7 @@ static struct video_device fm_viddev_template = {
.fops = &fm_drv_fops,
.ioctl_ops = &fm_drv_ioctl_ops,
.name = FM_DRV_NAME,
-   .release = video_device_release,
+   .release = video_device_release_empty,
/*
 * To ensure both the tuner and modulator ioctls are accessible we
 * set the vfl_dir to M2M to indicate this.
@@ -543,29 +543,21 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int 
radio_nr)
/* Init mutex for core locking */
mutex_init(&fmdev->mutex);
 
-   /* Allocate new video device */
-   gradio_dev = video_device_alloc();
-   if (NULL == gradio_dev) {
-   fmerr("Can't allocate video device\n");
-   return -ENOMEM;
-   }
-
/* Setup FM driver's V4L2 properties */
-   memcpy(gradio_dev, &fm_viddev_template, sizeof(fm_viddev_template));
+   gradio_dev = fm_viddev_template;
 
-   video_set_drvdata(gradio_dev, fmdev);
+   video_set_drvdata(&gradio_dev, fmdev);
 
-   gradio_dev->lock = &fmdev->mutex;
-   gradio_dev->v4l2_dev = &fmdev->v4l2_dev;
+   gradio_dev.lock = &fmdev->mutex;
+   gradio_dev.v4l2_dev = &fmdev->v4l2_dev;
 
/* Register with V4L2 subsystem as RADIO device */
-   if (video_register_device(gradio_dev, VFL_TYPE_RADIO, radio_nr)) {
-   video_device_release(gradio_dev);
+   if (video_register_device(&gradio_dev, VFL_TYPE_RADIO, radio_nr)) {
fmerr("Could not register video device\n");
return -ENOMEM;
}
 
-   fmdev->radio_dev = gradio_dev;
+   fmdev->radio_dev = &gradio_dev;
 
/* Register to v4l2 ctrl handler framework */
fmdev->radio_dev->ctrl_handler = &fmdev->ctrl_handler;
@@ -611,13 +603,13 @@ void *fm_v4l2_deinit_video_device(void)
struct fmdev *fmdev;
 
 
-   fmdev = video_get_drvdata(gradio_dev);
+   fmdev = video_get_drvdata(&gradio_dev);
 
/* Unregister to v4l2 ctrl handler framework*/
v4l2_ctrl_handler_free(&fmdev->ctrl_handler);
 
/* Unregister RADIO device from V4L2 subsystem */
-   video_unregister_device(gradio_dev);
+   video_unregister_device(&gradio_dev);
 
v4l2_device_unregister(&fmdev->v4l2_dev);
 
-- 
2.1.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 09/19] cx18: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
Cc: Andy Walls 
---
 drivers/media/pci/cx18/cx18-alsa-main.c |  2 +-
 drivers/media/pci/cx18/cx18-driver.h|  2 +-
 drivers/media/pci/cx18/cx18-fileops.c   |  2 +-
 drivers/media/pci/cx18/cx18-ioctl.c |  2 +-
 drivers/media/pci/cx18/cx18-streams.c   | 62 -
 drivers/media/pci/cx18/cx18-streams.h   |  2 +-
 6 files changed, 28 insertions(+), 44 deletions(-)

diff --git a/drivers/media/pci/cx18/cx18-alsa-main.c 
b/drivers/media/pci/cx18/cx18-alsa-main.c
index ea272bc..0b0e801 100644
--- a/drivers/media/pci/cx18/cx18-alsa-main.c
+++ b/drivers/media/pci/cx18/cx18-alsa-main.c
@@ -216,7 +216,7 @@ static int cx18_alsa_load(struct cx18 *cx)
}
 
s = &cx->streams[CX18_ENC_STREAM_TYPE_PCM];
-   if (s->video_dev == NULL) {
+   if (s->video_dev.v4l2_dev == NULL) {
CX18_DEBUG_ALSA_INFO("%s: PCM stream for card is disabled - "
 "skipping\n", __func__);
return 0;
diff --git a/drivers/media/pci/cx18/cx18-driver.h 
b/drivers/media/pci/cx18/cx18-driver.h
index ec40f2d..b15beed 100644
--- a/drivers/media/pci/cx18/cx18-driver.h
+++ b/drivers/media/pci/cx18/cx18-driver.h
@@ -373,7 +373,7 @@ struct cx18_in_work_order {
 struct cx18_stream {
/* These first five fields are always set, even if the stream
   is not actually created. */
-   struct video_device *video_dev; /* NULL when stream not created */
+   struct video_device video_dev;  /* v4l2_dev is NULL when stream not 
created */
struct cx18_dvb *dvb;   /* DVB / Digital Transport */
struct cx18 *cx;/* for ease of use */
const char *name;   /* name of the stream */
diff --git a/drivers/media/pci/cx18/cx18-fileops.c 
b/drivers/media/pci/cx18/cx18-fileops.c
index 76a3b4a..d245445 100644
--- a/drivers/media/pci/cx18/cx18-fileops.c
+++ b/drivers/media/pci/cx18/cx18-fileops.c
@@ -797,7 +797,7 @@ static int cx18_serialized_open(struct cx18_stream *s, 
struct file *filp)
CX18_DEBUG_WARN("nomem on v4l2 open\n");
return -ENOMEM;
}
-   v4l2_fh_init(&item->fh, s->video_dev);
+   v4l2_fh_init(&item->fh, &s->video_dev);
 
item->cx = cx;
item->type = s->type;
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c 
b/drivers/media/pci/cx18/cx18-ioctl.c
index c2e0093..0230b0f 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -1039,7 +1039,7 @@ static int cx18_log_status(struct file *file, void *fh)
for (i = 0; i < CX18_MAX_STREAMS; i++) {
struct cx18_stream *s = &cx->streams[i];
 
-   if (s->video_dev == NULL || s->buffers == 0)
+   if (s->video_dev.v4l2_dev == NULL || s->buffers == 0)
continue;
CX18_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d 
buffers) in use\n",
  s->name, s->s_flags,
diff --git a/drivers/media/pci/cx18/cx18-streams.c 
b/drivers/media/pci/cx18/cx18-streams.c
index 369445f..cf7ddaf 100644
--- a/drivers/media/pci/cx18/cx18-streams.c
+++ b/drivers/media/pci/cx18/cx18-streams.c
@@ -254,11 +254,8 @@ static struct videobuf_queue_ops cx18_videobuf_qops = {
 static void cx18_stream_init(struct cx18 *cx, int type)
 {
struct cx18_stream *s = &cx->streams[type];
-   struct video_device *video_dev = s->video_dev;
 
-   /* we need to keep video_dev, so restore it afterwards */
memset(s, 0, sizeof(*s));
-   s->video_dev = video_dev;
 
/* initialize cx18_stream fields */
s->dvb = NULL;
@@ -319,12 +316,12 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
 
/*
 * These five fields are always initialized.
-* For analog capture related streams, if video_dev == NULL then the
+* For analog capture related streams, if video_dev.v4l2_dev == NULL 
then the
 * stream is not in use.
 * For the TS stream, if dvb == NULL then the stream is not in use.
 * In those cases no other fields but these four can be used.
 */
-   s->video_dev = NULL;
+   s->video_dev.v4l2_dev = NULL;
s->dvb = NULL;
s->cx = cx;
s->type = type;
@@ -367,24 +364,17 @@ static int cx18_prep_dev(struct cx18 *cx, int type)
if (num_offset == -1)
return 0;
 
-   /* allocate and initialize the v4l2 video device structure */
-   s->video_dev = video_device_alloc();
-   if (s->video_dev == NULL) {
-   CX18_ERR("Couldn't allocate v4l2 video_device for %s\n",
-   s->name);
-   return -ENOMEM;
-   }
-
-   snprintf(s->video_dev->name, sizeof(s->video_dev->name), "%s %s",
+   /* initialize the v4l2 v

[PATCH 17/19] uvc: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
Cc: Laurent Pinchart 
---
 drivers/media/usb/uvc/uvc_driver.c | 22 --
 drivers/media/usb/uvc/uvc_v4l2.c   |  2 +-
 drivers/media/usb/uvc/uvcvideo.h   |  2 +-
 3 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_driver.c 
b/drivers/media/usb/uvc/uvc_driver.c
index cf27006..8dd3f7b 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1669,10 +1669,6 @@ static void uvc_delete(struct uvc_device *dev)
 #ifdef CONFIG_MEDIA_CONTROLLER
uvc_mc_cleanup_entity(entity);
 #endif
-   if (entity->vdev) {
-   video_device_release(entity->vdev);
-   entity->vdev = NULL;
-   }
kfree(entity);
}
 
@@ -1717,11 +1713,10 @@ static void uvc_unregister_video(struct uvc_device *dev)
atomic_inc(&dev->nstreams);
 
list_for_each_entry(stream, &dev->streams, list) {
-   if (stream->vdev == NULL)
+   if (!video_is_registered(&stream->vdev))
continue;
 
-   video_unregister_device(stream->vdev);
-   stream->vdev = NULL;
+   video_unregister_device(&stream->vdev);
 
uvc_debugfs_cleanup_stream(stream);
}
@@ -1736,7 +1731,7 @@ static void uvc_unregister_video(struct uvc_device *dev)
 static int uvc_register_video(struct uvc_device *dev,
struct uvc_streaming *stream)
 {
-   struct video_device *vdev;
+   struct video_device *vdev = &stream->vdev;
int ret;
 
/* Initialize the video buffers queue. */
@@ -1757,12 +1752,6 @@ static int uvc_register_video(struct uvc_device *dev,
uvc_debugfs_init_stream(stream);
 
/* Register the device with V4L. */
-   vdev = video_device_alloc();
-   if (vdev == NULL) {
-   uvc_printk(KERN_ERR, "Failed to allocate video device (%d).\n",
-  ret);
-   return -ENOMEM;
-   }
 
/* We already hold a reference to dev->udev. The video device will be
 * unregistered before the reference is released, so we don't need to
@@ -1780,15 +1769,12 @@ static int uvc_register_video(struct uvc_device *dev,
/* Set the driver data before calling video_register_device, otherwise
 * uvc_v4l2_open might race us.
 */
-   stream->vdev = vdev;
video_set_drvdata(vdev, stream);
 
ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
if (ret < 0) {
uvc_printk(KERN_ERR, "Failed to register video device (%d).\n",
   ret);
-   stream->vdev = NULL;
-   video_device_release(vdev);
return ret;
}
 
@@ -1827,7 +1813,7 @@ static int uvc_register_terms(struct uvc_device *dev,
if (ret < 0)
return ret;
 
-   term->vdev = stream->vdev;
+   term->vdev = &stream->vdev;
}
 
return 0;
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 43e953f..c08b202 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -511,7 +511,7 @@ static int uvc_v4l2_open(struct file *file)
stream->dev->users++;
mutex_unlock(&stream->dev->lock);
 
-   v4l2_fh_init(&handle->vfh, stream->vdev);
+   v4l2_fh_init(&handle->vfh, &stream->vdev);
v4l2_fh_add(&handle->vfh);
handle->chain = stream->chain;
handle->stream = stream;
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index c63e5b5..1b594c2 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -443,7 +443,7 @@ struct uvc_stats_stream {
 struct uvc_streaming {
struct list_head list;
struct uvc_device *dev;
-   struct video_device *vdev;
+   struct video_device vdev;
struct uvc_video_chain *chain;
atomic_t active;
 
-- 
2.1.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 14/19] gadget/uvc: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
Cc: Laurent Pinchart 
---
 drivers/usb/gadget/function/f_uvc.c | 44 +++--
 drivers/usb/gadget/function/uvc.h   |  2 +-
 2 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c 
b/drivers/usb/gadget/function/f_uvc.c
index 3242bc6..cf0df8f 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -222,7 +222,7 @@ uvc_function_ep0_complete(struct usb_ep *ep, struct 
usb_request *req)
v4l2_event.type = UVC_EVENT_DATA;
uvc_event->data.length = req->actual;
memcpy(&uvc_event->data.data, req->buf, req->actual);
-   v4l2_event_queue(uvc->vdev, &v4l2_event);
+   v4l2_event_queue(&uvc->vdev, &v4l2_event);
}
 }
 
@@ -256,7 +256,7 @@ uvc_function_setup(struct usb_function *f, const struct 
usb_ctrlrequest *ctrl)
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_SETUP;
memcpy(&uvc_event->req, ctrl, sizeof(uvc_event->req));
-   v4l2_event_queue(uvc->vdev, &v4l2_event);
+   v4l2_event_queue(&uvc->vdev, &v4l2_event);
 
return 0;
 }
@@ -315,7 +315,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned 
interface, unsigned alt)
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_CONNECT;
uvc_event->speed = cdev->gadget->speed;
-   v4l2_event_queue(uvc->vdev, &v4l2_event);
+   v4l2_event_queue(&uvc->vdev, &v4l2_event);
 
uvc->state = UVC_STATE_CONNECTED;
}
@@ -343,7 +343,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned 
interface, unsigned alt)
 
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_STREAMOFF;
-   v4l2_event_queue(uvc->vdev, &v4l2_event);
+   v4l2_event_queue(&uvc->vdev, &v4l2_event);
 
uvc->state = UVC_STATE_CONNECTED;
return 0;
@@ -370,7 +370,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned 
interface, unsigned alt)
 
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_STREAMON;
-   v4l2_event_queue(uvc->vdev, &v4l2_event);
+   v4l2_event_queue(&uvc->vdev, &v4l2_event);
return USB_GADGET_DELAYED_STATUS;
 
default:
@@ -388,7 +388,7 @@ uvc_function_disable(struct usb_function *f)
 
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_DISCONNECT;
-   v4l2_event_queue(uvc->vdev, &v4l2_event);
+   v4l2_event_queue(&uvc->vdev, &v4l2_event);
 
uvc->state = UVC_STATE_DISCONNECTED;
 
@@ -435,25 +435,19 @@ static int
 uvc_register_video(struct uvc_device *uvc)
 {
struct usb_composite_dev *cdev = uvc->func.config->cdev;
-   struct video_device *video;
 
/* TODO reference counting. */
-   video = video_device_alloc();
-   if (video == NULL)
-   return -ENOMEM;
-
-   video->v4l2_dev = &uvc->v4l2_dev;
-   video->fops = &uvc_v4l2_fops;
-   video->ioctl_ops = &uvc_v4l2_ioctl_ops;
-   video->release = video_device_release;
-   video->vfl_dir = VFL_DIR_TX;
-   video->lock = &uvc->video.mutex;
-   strlcpy(video->name, cdev->gadget->name, sizeof(video->name));
-
-   uvc->vdev = video;
-   video_set_drvdata(video, uvc);
-
-   return video_register_device(video, VFL_TYPE_GRABBER, -1);
+   uvc->vdev.v4l2_dev = &uvc->v4l2_dev;
+   uvc->vdev.fops = &uvc_v4l2_fops;
+   uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops;
+   uvc->vdev.release = video_device_release_empty;
+   uvc->vdev.vfl_dir = VFL_DIR_TX;
+   uvc->vdev.lock = &uvc->video.mutex;
+   strlcpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name));
+
+   video_set_drvdata(&uvc->vdev, uvc);
+
+   return video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1);
 }
 
 #define UVC_COPY_DESCRIPTOR(mem, dst, desc) \
@@ -766,8 +760,6 @@ uvc_function_bind(struct usb_configuration *c, struct 
usb_function *f)
 
 error:
v4l2_device_unregister(&uvc->v4l2_dev);
-   if (uvc->vdev)
-   video_device_release(uvc->vdev);
 
if (uvc->control_ep)
uvc->control_ep->driver_data = NULL;
@@ -898,7 +890,7 @@ static void uvc_unbind(struct usb_configuration *c, struct 
usb_function *f)
 
INFO(cdev, "%s\n", __func__);
 
-   video_unregister_device(uvc->vdev);
+   video_unregister_device(&uvc->vdev);
v4l2_device_unregister(&uvc->v4l2_dev);
uvc->control_ep->driver_data = NULL;
uvc->video.ep->driver_data = NULL;
diff --git a/drivers/

[PATCH 15/19] hdpvr: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/hdpvr/hdpvr-core.c  | 10 +++---
 drivers/media/usb/hdpvr/hdpvr-video.c | 19 ++-
 drivers/media/usb/hdpvr/hdpvr.h   |  2 +-
 3 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c 
b/drivers/media/usb/hdpvr/hdpvr-core.c
index 42b4cdf..3fc6419 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -69,10 +69,6 @@ MODULE_DEVICE_TABLE(usb, hdpvr_table);
 void hdpvr_delete(struct hdpvr_device *dev)
 {
hdpvr_free_buffers(dev);
-
-   if (dev->video_dev)
-   video_device_release(dev->video_dev);
-
usb_put_dev(dev->udev);
 }
 
@@ -397,7 +393,7 @@ static int hdpvr_probe(struct usb_interface *interface,
 
/* let the user know what node this device is now attached to */
v4l2_info(&dev->v4l2_dev, "device now attached to %s\n",
- video_device_node_name(dev->video_dev));
+ video_device_node_name(&dev->video_dev));
return 0;
 
 reg_fail:
@@ -420,7 +416,7 @@ static void hdpvr_disconnect(struct usb_interface 
*interface)
struct hdpvr_device *dev = to_hdpvr_dev(usb_get_intfdata(interface));
 
v4l2_info(&dev->v4l2_dev, "device %s disconnected\n",
- video_device_node_name(dev->video_dev));
+ video_device_node_name(&dev->video_dev));
/* prevent more I/O from starting and stop any ongoing */
mutex_lock(&dev->io_mutex);
dev->status = STATUS_DISCONNECTED;
@@ -436,7 +432,7 @@ static void hdpvr_disconnect(struct usb_interface 
*interface)
 #if IS_ENABLED(CONFIG_I2C)
i2c_del_adapter(&dev->i2c_adapter);
 #endif
-   video_unregister_device(dev->video_dev);
+   video_unregister_device(&dev->video_dev);
atomic_dec(&dev_nr);
 }
 
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c 
b/drivers/media/usb/hdpvr/hdpvr-video.c
index 59d15fd..d8d8c0f 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -797,7 +797,7 @@ static int vidioc_s_input(struct file *file, void *_fh,
 * Comment this out for now, but if the legacy mode can be
 * removed in the future, then this code should be enabled
 * again.
-   dev->video_dev->tvnorms =
+   dev->video_dev.tvnorms =
(index != HDPVR_COMPONENT) ? V4L2_STD_ALL : 0;
 */
}
@@ -1228,19 +1228,12 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, 
struct device *parent,
}
 
/* setup and register video device */
-   dev->video_dev = video_device_alloc();
-   if (!dev->video_dev) {
-   v4l2_err(&dev->v4l2_dev, "video_device_alloc() failed\n");
-   res = -ENOMEM;
-   goto error;
-   }
-
-   *dev->video_dev = hdpvr_video_template;
-   strcpy(dev->video_dev->name, "Hauppauge HD PVR");
-   dev->video_dev->v4l2_dev = &dev->v4l2_dev;
-   video_set_drvdata(dev->video_dev, dev);
+   dev->video_dev = hdpvr_video_template;
+   strcpy(dev->video_dev.name, "Hauppauge HD PVR");
+   dev->video_dev.v4l2_dev = &dev->v4l2_dev;
+   video_set_drvdata(&dev->video_dev, dev);
 
-   res = video_register_device(dev->video_dev, VFL_TYPE_GRABBER, devnum);
+   res = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, devnum);
if (res < 0) {
v4l2_err(&dev->v4l2_dev, "video_device registration failed\n");
goto error;
diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h
index dc685d4..a319430 100644
--- a/drivers/media/usb/hdpvr/hdpvr.h
+++ b/drivers/media/usb/hdpvr/hdpvr.h
@@ -66,7 +66,7 @@ struct hdpvr_options {
 /* Structure to hold all of our device specific stuff */
 struct hdpvr_device {
/* the v4l device for this device */
-   struct video_device *video_dev;
+   struct video_device video_dev;
/* the control handler for this device */
struct v4l2_ctrl_handler hdl;
/* the usb device for this device */
-- 
2.1.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 12/19] em28xx: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/usb/em28xx/em28xx-video.c | 119 ++--
 drivers/media/usb/em28xx/em28xx.h   |   6 +-
 2 files changed, 54 insertions(+), 71 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
b/drivers/media/usb/em28xx/em28xx-video.c
index 9ecf656..14eba9c 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1472,7 +1472,7 @@ static int vidioc_enum_input(struct file *file, void 
*priv,
(EM28XX_VMUX_CABLE == INPUT(n)->type))
i->type = V4L2_INPUT_TYPE_TUNER;
 
-   i->std = dev->v4l2->vdev->tvnorms;
+   i->std = dev->v4l2->vdev.tvnorms;
/* webcams do not have the STD API */
if (dev->board.is_webcam)
i->capabilities = 0;
@@ -1730,9 +1730,9 @@ static int vidioc_querycap(struct file *file, void  *priv,
 
cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS |
V4L2_CAP_READWRITE | V4L2_CAP_VIDEO_CAPTURE | 
V4L2_CAP_STREAMING;
-   if (v4l2->vbi_dev)
+   if (video_is_registered(&v4l2->vbi_dev))
cap->capabilities |= V4L2_CAP_VBI_CAPTURE;
-   if (v4l2->radio_dev)
+   if (video_is_registered(&v4l2->radio_dev))
cap->capabilities |= V4L2_CAP_RADIO;
return 0;
 }
@@ -1966,20 +1966,20 @@ static int em28xx_v4l2_fini(struct em28xx *dev)
 
em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
 
-   if (v4l2->radio_dev) {
+   if (video_is_registered(&v4l2->radio_dev)) {
em28xx_info("V4L2 device %s deregistered\n",
-   video_device_node_name(v4l2->radio_dev));
-   video_unregister_device(v4l2->radio_dev);
+   video_device_node_name(&v4l2->radio_dev));
+   video_unregister_device(&v4l2->radio_dev);
}
-   if (v4l2->vbi_dev) {
+   if (video_is_registered(&v4l2->vbi_dev)) {
em28xx_info("V4L2 device %s deregistered\n",
-   video_device_node_name(v4l2->vbi_dev));
-   video_unregister_device(v4l2->vbi_dev);
+   video_device_node_name(&v4l2->vbi_dev));
+   video_unregister_device(&v4l2->vbi_dev);
}
-   if (v4l2->vdev) {
+   if (video_is_registered(&v4l2->vdev)) {
em28xx_info("V4L2 device %s deregistered\n",
-   video_device_node_name(v4l2->vdev));
-   video_unregister_device(v4l2->vdev);
+   video_device_node_name(&v4l2->vdev));
+   video_unregister_device(&v4l2->vdev);
}
 
v4l2_ctrl_handler_free(&v4l2->ctrl_handler);
@@ -2127,7 +2127,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 static const struct video_device em28xx_video_template = {
.fops   = &em28xx_v4l_fops,
.ioctl_ops  = &video_ioctl_ops,
-   .release= video_device_release,
+   .release= video_device_release_empty,
.tvnorms= V4L2_STD_ALL,
 };
 
@@ -2156,7 +2156,7 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
 static struct video_device em28xx_radio_template = {
.fops   = &radio_fops,
.ioctl_ops  = &radio_ioctl_ops,
-   .release= video_device_release,
+   .release= video_device_release_empty,
 };
 
 /* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */
@@ -2179,17 +2179,11 @@ static unsigned short msp3400_addrs[] = {
 
 / usb interface **/
 
-static struct video_device
-*em28xx_vdev_init(struct em28xx *dev,
- const struct video_device *template,
- const char *type_name)
+static void em28xx_vdev_init(struct em28xx *dev,
+struct video_device *vfd,
+const struct video_device *template,
+const char *type_name)
 {
-   struct video_device *vfd;
-
-   vfd = video_device_alloc();
-   if (NULL == vfd)
-   return NULL;
-
*vfd= *template;
vfd->v4l2_dev   = &dev->v4l2->v4l2_dev;
vfd->lock   = &dev->lock;
@@ -2200,7 +2194,6 @@ static struct video_device
 dev->name, type_name);
 
video_set_drvdata(vfd, dev);
-   return vfd;
 }
 
 static void em28xx_tuner_setup(struct em28xx *dev, unsigned short tuner_addr)
@@ -2491,38 +2484,33 @@ static int em28xx_v4l2_init(struct em28xx *dev)
goto unregister_dev;
 
/* allocate and fill video video_device struct */
-   v4l2->vdev = em28xx_vdev_init(dev, &em28xx_video_template, "video");
-   if (!v4l2->vdev) {
-   em28xx_errdev("cannot allocate video_device.

[PATCH 06/19] cx88: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/pci/cx88/cx88-blackbird.c | 22 +---
 drivers/media/pci/cx88/cx88-core.c  | 18 --
 drivers/media/pci/cx88/cx88-video.c | 61 -
 drivers/media/pci/cx88/cx88.h   | 17 -
 4 files changed, 46 insertions(+), 72 deletions(-)

diff --git a/drivers/media/pci/cx88/cx88-blackbird.c 
b/drivers/media/pci/cx88/cx88-blackbird.c
index b6be46e..24216ef 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -1102,32 +1102,26 @@ static int cx8802_blackbird_advise_release(struct 
cx8802_driver *drv)
 
 static void blackbird_unregister_video(struct cx8802_dev *dev)
 {
-   if (dev->mpeg_dev) {
-   if (video_is_registered(dev->mpeg_dev))
-   video_unregister_device(dev->mpeg_dev);
-   else
-   video_device_release(dev->mpeg_dev);
-   dev->mpeg_dev = NULL;
-   }
+   video_unregister_device(&dev->mpeg_dev);
 }
 
 static int blackbird_register_video(struct cx8802_dev *dev)
 {
int err;
 
-   dev->mpeg_dev = cx88_vdev_init(dev->core, dev->pci,
-  &cx8802_mpeg_template, "mpeg");
-   dev->mpeg_dev->ctrl_handler = &dev->cxhdl.hdl;
-   video_set_drvdata(dev->mpeg_dev, dev);
-   dev->mpeg_dev->queue = &dev->vb2_mpegq;
-   err = video_register_device(dev->mpeg_dev, VFL_TYPE_GRABBER, -1);
+   cx88_vdev_init(dev->core, dev->pci, &dev->mpeg_dev,
+  &cx8802_mpeg_template, "mpeg");
+   dev->mpeg_dev.ctrl_handler = &dev->cxhdl.hdl;
+   video_set_drvdata(&dev->mpeg_dev, dev);
+   dev->mpeg_dev.queue = &dev->vb2_mpegq;
+   err = video_register_device(&dev->mpeg_dev, VFL_TYPE_GRABBER, -1);
if (err < 0) {
printk(KERN_INFO "%s/2: can't register mpeg device\n",
   dev->core->name);
return err;
}
printk(KERN_INFO "%s/2: registered device %s [mpeg]\n",
-  dev->core->name, video_device_node_name(dev->mpeg_dev));
+  dev->core->name, video_device_node_name(&dev->mpeg_dev));
return 0;
 }
 
diff --git a/drivers/media/pci/cx88/cx88-core.c 
b/drivers/media/pci/cx88/cx88-core.c
index c38d5a1..3501be9 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -985,17 +985,14 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id 
norm)
 
 /* -- */
 
-struct video_device *cx88_vdev_init(struct cx88_core *core,
-   struct pci_dev *pci,
-   const struct video_device *template_,
-   const char *type)
+void cx88_vdev_init(struct cx88_core *core,
+   struct pci_dev *pci,
+   struct video_device *vfd,
+   const struct video_device *template_,
+   const char *type)
 {
-   struct video_device *vfd;
-
-   vfd = video_device_alloc();
-   if (NULL == vfd)
-   return NULL;
*vfd = *template_;
+
/*
 * The dev pointer of v4l2_device is NULL, instead we set the
 * video_device dev_parent pointer to the correct PCI bus device.
@@ -1004,11 +1001,10 @@ struct video_device *cx88_vdev_init(struct cx88_core 
*core,
 */
vfd->v4l2_dev = &core->v4l2_dev;
vfd->dev_parent = &pci->dev;
-   vfd->release = video_device_release;
+   vfd->release = video_device_release_empty;
vfd->lock = &core->lock;
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
 core->name, type, core->board.name);
-   return vfd;
 }
 
 struct cx88_core* cx88_core_get(struct pci_dev *pci)
diff --git a/drivers/media/pci/cx88/cx88-video.c 
b/drivers/media/pci/cx88/cx88-video.c
index 860c98fc..c9decd8 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -1274,27 +1274,9 @@ static const struct v4l2_ctrl_ops cx8800_ctrl_aud_ops = {
 
 static void cx8800_unregister_video(struct cx8800_dev *dev)
 {
-   if (dev->radio_dev) {
-   if (video_is_registered(dev->radio_dev))
-   video_unregister_device(dev->radio_dev);
-   else
-   video_device_release(dev->radio_dev);
-   dev->radio_dev = NULL;
-   }
-   if (dev->vbi_dev) {
-   if (video_is_registered(dev->vbi_dev))
-   video_unregister_device(dev->vbi_dev);
-   else
-   video_device_release(dev->vbi_dev);
-   dev->vbi_dev = NULL;
-   }
-   if (dev->video_dev) {
-   if (video_is_

[PATCH 07/19] meye: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/pci/meye/meye.c | 19 ++-
 drivers/media/pci/meye/meye.h |  2 +-
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index 9d9f90c..3b5297d 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -1546,7 +1546,7 @@ static struct video_device meye_template = {
.name   = "meye",
.fops   = &meye_fops,
.ioctl_ops  = &meye_ioctl_ops,
-   .release= video_device_release,
+   .release= video_device_release_empty,
 };
 
 static const struct v4l2_ctrl_ops meye_ctrl_ops = {
@@ -1633,11 +1633,6 @@ static int meye_probe(struct pci_dev *pcidev, const 
struct pci_device_id *ent)
}
ret = -ENOMEM;
meye.mchip_dev = pcidev;
-   meye.vdev = video_device_alloc();
-   if (!meye.vdev) {
-   v4l2_err(v4l2_dev, "video_device_alloc() failed!\n");
-   goto outnotdev;
-   }
 
meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
if (!meye.grab_temp) {
@@ -1658,8 +1653,8 @@ static int meye_probe(struct pci_dev *pcidev, const 
struct pci_device_id *ent)
goto outkfifoalloc2;
}
 
-   memcpy(meye.vdev, &meye_template, sizeof(meye_template));
-   meye.vdev->v4l2_dev = &meye.v4l2_dev;
+   meye.vdev = meye_template;
+   meye.vdev.v4l2_dev = &meye.v4l2_dev;
 
ret = -EIO;
if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
@@ -1743,9 +1738,9 @@ static int meye_probe(struct pci_dev *pcidev, const 
struct pci_device_id *ent)
}
 
v4l2_ctrl_handler_setup(&meye.hdl);
-   meye.vdev->ctrl_handler = &meye.hdl;
+   meye.vdev.ctrl_handler = &meye.hdl;
 
-   if (video_register_device(meye.vdev, VFL_TYPE_GRABBER,
+   if (video_register_device(&meye.vdev, VFL_TYPE_GRABBER,
  video_nr) < 0) {
v4l2_err(v4l2_dev, "video_register_device failed\n");
goto outvideoreg;
@@ -1777,14 +1772,12 @@ outkfifoalloc2:
 outkfifoalloc1:
vfree(meye.grab_temp);
 outvmalloc:
-   video_device_release(meye.vdev);
-outnotdev:
return ret;
 }
 
 static void meye_remove(struct pci_dev *pcidev)
 {
-   video_unregister_device(meye.vdev);
+   video_unregister_device(&meye.vdev);
 
mchip_hic_stop();
 
diff --git a/drivers/media/pci/meye/meye.h b/drivers/media/pci/meye/meye.h
index 6fed927..751be5e 100644
--- a/drivers/media/pci/meye/meye.h
+++ b/drivers/media/pci/meye/meye.h
@@ -311,7 +311,7 @@ struct meye {
struct kfifo doneq; /* queue for grabbed buffers */
spinlock_t doneq_lock;  /* lock protecting the queue */
wait_queue_head_t proc_list;/* wait queue */
-   struct video_device *vdev;  /* video device parameters */
+   struct video_device vdev;   /* video device parameters */
u16 brightness;
u16 hue;
u16 contrast;
-- 
2.1.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 01/19] ivtv: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
Cc: Andy Walls 
---
 drivers/media/pci/ivtv/ivtv-alsa-main.c |   2 +-
 drivers/media/pci/ivtv/ivtv-alsa-pcm.c  |   2 +-
 drivers/media/pci/ivtv/ivtv-driver.c|   4 +-
 drivers/media/pci/ivtv/ivtv-driver.h|   2 +-
 drivers/media/pci/ivtv/ivtv-fileops.c   |   2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c |   8 +--
 drivers/media/pci/ivtv/ivtv-irq.c   |   8 +--
 drivers/media/pci/ivtv/ivtv-streams.c   | 107 ++--
 drivers/media/pci/ivtv/ivtv-streams.h   |   2 +-
 9 files changed, 61 insertions(+), 76 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtv-alsa-main.c 
b/drivers/media/pci/ivtv/ivtv-alsa-main.c
index 39b5292..41fa215 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-main.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-main.c
@@ -224,7 +224,7 @@ static int ivtv_alsa_load(struct ivtv *itv)
}
 
s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM];
-   if (s->vdev == NULL) {
+   if (s->vdev.v4l2_dev == NULL) {
IVTV_DEBUG_ALSA_INFO("%s: PCM stream for card is disabled - "
 "skipping\n", __func__);
return 0;
diff --git a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c 
b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
index 7bf9cbc..f198b98 100644
--- a/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
+++ b/drivers/media/pci/ivtv/ivtv-alsa-pcm.c
@@ -167,7 +167,7 @@ static int snd_ivtv_pcm_capture_open(struct 
snd_pcm_substream *substream)
 
s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM];
 
-   v4l2_fh_init(&item.fh, s->vdev);
+   v4l2_fh_init(&item.fh, &s->vdev);
item.itv = itv;
item.type = s->type;
 
diff --git a/drivers/media/pci/ivtv/ivtv-driver.c 
b/drivers/media/pci/ivtv/ivtv-driver.c
index 802642d..c2e60b4 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -1284,7 +1284,7 @@ static int ivtv_probe(struct pci_dev *pdev, const struct 
pci_device_id *pci_id)
return 0;
 
 free_streams:
-   ivtv_streams_cleanup(itv, 1);
+   ivtv_streams_cleanup(itv);
 free_irq:
free_irq(itv->pdev->irq, (void *)itv);
 free_i2c:
@@ -1444,7 +1444,7 @@ static void ivtv_remove(struct pci_dev *pdev)
flush_kthread_worker(&itv->irq_worker);
kthread_stop(itv->irq_worker_task);
 
-   ivtv_streams_cleanup(itv, 1);
+   ivtv_streams_cleanup(itv);
ivtv_udma_free(itv);
 
v4l2_ctrl_handler_free(&itv->cxhdl.hdl);
diff --git a/drivers/media/pci/ivtv/ivtv-driver.h 
b/drivers/media/pci/ivtv/ivtv-driver.h
index bc309f42c..e8b6c7a 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.h
+++ b/drivers/media/pci/ivtv/ivtv-driver.h
@@ -327,7 +327,7 @@ struct ivtv;/* forward 
reference */
 struct ivtv_stream {
/* These first four fields are always set, even if the stream
   is not actually created. */
-   struct video_device *vdev;  /* NULL when stream not created */
+   struct video_device vdev;   /* vdev.v4l2_dev is NULL if there is no 
device */
struct ivtv *itv;   /* for ease of use */
const char *name;   /* name of the stream */
int type;   /* stream type */
diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c 
b/drivers/media/pci/ivtv/ivtv-fileops.c
index e5ff627..605d280 100644
--- a/drivers/media/pci/ivtv/ivtv-fileops.c
+++ b/drivers/media/pci/ivtv/ivtv-fileops.c
@@ -995,7 +995,7 @@ static int ivtv_open(struct file *filp)
IVTV_DEBUG_WARN("nomem on v4l2 open\n");
return -ENOMEM;
}
-   v4l2_fh_init(&item->fh, s->vdev);
+   v4l2_fh_init(&item->fh, &s->vdev);
item->itv = itv;
item->type = s->type;
 
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c 
b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 4d8ee18..fa87565 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -987,7 +987,7 @@ int ivtv_s_input(struct file *file, void *fh, unsigned int 
inp)
else
std = V4L2_STD_ALL;
for (i = 0; i <= IVTV_ENC_STREAM_TYPE_VBI; i++)
-   itv->streams[i].vdev->tvnorms = std;
+   itv->streams[i].vdev.tvnorms = std;
 
/* prevent others from messing with the streams until
   we're finished changing inputs. */
@@ -1038,7 +1038,7 @@ static int ivtv_g_frequency(struct file *file, void *fh, 
struct v4l2_frequency *
struct ivtv *itv = fh2id(fh)->itv;
struct ivtv_stream *s = &itv->streams[fh2id(fh)->type];
 
-   if (s->vdev->vfl_dir)
+   if (s->vdev.vfl_dir)
return -ENOTTY;
if (vf->tuner != 0)
return -EINVAL;
@@ -1052,7 +1052,7 @@ int ivtv_s_frequency(struct file *file, void *fh, const 
struct v4l2_frequency *v
st

[PATCH 05/19] dt3155v4l: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/dt3155v4l/dt3155v4l.c | 30 ++---
 drivers/staging/media/dt3155v4l/dt3155v4l.h |  4 ++--
 2 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c 
b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index e60a53e..52a8ffe 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -244,7 +244,7 @@ dt3155_wait_prepare(struct vb2_queue *q)
 {
struct dt3155_priv *pd = vb2_get_drv_priv(q);
 
-   mutex_unlock(pd->vdev->lock);
+   mutex_unlock(pd->vdev.lock);
 }
 
 static void
@@ -252,7 +252,7 @@ dt3155_wait_finish(struct vb2_queue *q)
 {
struct dt3155_priv *pd = vb2_get_drv_priv(q);
 
-   mutex_lock(pd->vdev->lock);
+   mutex_lock(pd->vdev.lock);
 }
 
 static int
@@ -824,7 +824,7 @@ static struct video_device dt3155_vdev = {
.fops = &dt3155_fops,
.ioctl_ops = &dt3155_ioctl_ops,
.minor = -1,
-   .release = video_device_release,
+   .release = video_device_release_empty,
.tvnorms = DT3155_CURRENT_NORM,
 };
 
@@ -904,24 +904,21 @@ dt3155_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL);
if (!pd)
return -ENOMEM;
-   pd->vdev = video_device_alloc();
-   if (!pd->vdev)
-   return -ENOMEM;
 
-   *pd->vdev = dt3155_vdev;
+   pd->vdev = dt3155_vdev;
pci_set_drvdata(pdev, pd);/* for use in dt3155_remove() */
-   video_set_drvdata(pd->vdev, pd);  /* for use in video_fops */
+   video_set_drvdata(&pd->vdev, pd);  /* for use in video_fops */
pd->users = 0;
pd->pdev = pdev;
INIT_LIST_HEAD(&pd->dmaq);
mutex_init(&pd->mux);
-   pd->vdev->lock = &pd->mux; /* for locking v4l2_file_operations */
+   pd->vdev.lock = &pd->mux; /* for locking v4l2_file_operations */
spin_lock_init(&pd->lock);
pd->csr2 = csr2_init;
pd->config = config_init;
err = pci_enable_device(pdev);
if (err)
-   goto err_enable_dev;
+   return err;
err = pci_request_region(pdev, 0, pci_name(pdev));
if (err)
goto err_req_region;
@@ -933,13 +930,13 @@ dt3155_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
err = dt3155_init_board(pdev);
if (err)
goto err_init_board;
-   err = video_register_device(pd->vdev, VFL_TYPE_GRABBER, -1);
+   err = video_register_device(&pd->vdev, VFL_TYPE_GRABBER, -1);
if (err)
goto err_init_board;
if (dt3155_alloc_coherent(&pdev->dev, DT3155_CHUNK_SIZE,
DMA_MEMORY_MAP))
dev_info(&pdev->dev, "preallocated 8 buffers\n");
-   dev_info(&pdev->dev, "/dev/video%i is ready\n", pd->vdev->minor);
+   dev_info(&pdev->dev, "/dev/video%i is ready\n", pd->vdev.minor);
return 0;  /*   success   */
 
 err_init_board:
@@ -948,9 +945,6 @@ err_pci_iomap:
pci_release_region(pdev, 0);
 err_req_region:
pci_disable_device(pdev);
-err_enable_dev:
-   video_device_release(pd->vdev);
-
return err;
 }
 
@@ -960,14 +954,10 @@ dt3155_remove(struct pci_dev *pdev)
struct dt3155_priv *pd = pci_get_drvdata(pdev);
 
dt3155_free_coherent(&pdev->dev);
-   video_unregister_device(pd->vdev);
+   video_unregister_device(&pd->vdev);
pci_iounmap(pdev, pd->regs);
pci_release_region(pdev, 0);
pci_disable_device(pdev);
-   /*
-* video_device_release() is invoked automatically
-* see: struct video_device dt3155_vdev
-*/
 }
 
 static const struct pci_device_id pci_ids[] = {
diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.h 
b/drivers/staging/media/dt3155v4l/dt3155v4l.h
index 2e4f89d..96f01a0 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.h
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.h
@@ -178,7 +178,7 @@ struct dt3155_stats {
 /**
  * struct dt3155_priv - private data structure
  *
- * @vdev:  pointer to video_device structure
+ * @vdev:  video_device structure
  * @pdev:  pointer to pci_dev structure
  * @q  pointer to vb2_queue structure
  * @curr_buf:  pointer to curren buffer
@@ -193,7 +193,7 @@ struct dt3155_stats {
  * @config:local copy of config register
  */
 struct dt3155_priv {
-   struct video_device *vdev;
+   struct video_device vdev;
struct pci_dev *pdev;
struct vb2_queue *q;
struct vb2_buffer *curr_buf;
-- 
2.1.4

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

[PATCH 02/19] vim2m: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
Cc: Kamil Debski 
---
 drivers/media/platform/vim2m.c | 23 +++
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/vim2m.c b/drivers/media/platform/vim2m.c
index d9d844a..4d6b4cc 100644
--- a/drivers/media/platform/vim2m.c
+++ b/drivers/media/platform/vim2m.c
@@ -142,7 +142,7 @@ static struct vim2m_fmt *find_format(struct v4l2_format *f)
 
 struct vim2m_dev {
struct v4l2_device  v4l2_dev;
-   struct video_device *vfd;
+   struct video_device vfd;
 
atomic_tnum_inst;
struct mutexdev_mutex;
@@ -968,7 +968,7 @@ static struct video_device vim2m_videodev = {
.fops   = &vim2m_fops,
.ioctl_ops  = &vim2m_ioctl_ops,
.minor  = -1,
-   .release= video_device_release,
+   .release= video_device_release_empty,
 };
 
 static struct v4l2_m2m_ops m2m_ops = {
@@ -996,26 +996,19 @@ static int vim2m_probe(struct platform_device *pdev)
atomic_set(&dev->num_inst, 0);
mutex_init(&dev->dev_mutex);
 
-   vfd = video_device_alloc();
-   if (!vfd) {
-   v4l2_err(&dev->v4l2_dev, "Failed to allocate video device\n");
-   ret = -ENOMEM;
-   goto unreg_dev;
-   }
-
-   *vfd = vim2m_videodev;
+   dev->vfd = vim2m_videodev;
+   vfd = &dev->vfd;
vfd->lock = &dev->dev_mutex;
vfd->v4l2_dev = &dev->v4l2_dev;
 
ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
if (ret) {
v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
-   goto rel_vdev;
+   goto unreg_dev;
}
 
video_set_drvdata(vfd, dev);
snprintf(vfd->name, sizeof(vfd->name), "%s", vim2m_videodev.name);
-   dev->vfd = vfd;
v4l2_info(&dev->v4l2_dev,
"Device registered as /dev/video%d\n", vfd->num);
 
@@ -1033,9 +1026,7 @@ static int vim2m_probe(struct platform_device *pdev)
 
 err_m2m:
v4l2_m2m_release(dev->m2m_dev);
-   video_unregister_device(dev->vfd);
-rel_vdev:
-   video_device_release(vfd);
+   video_unregister_device(&dev->vfd);
 unreg_dev:
v4l2_device_unregister(&dev->v4l2_dev);
 
@@ -1049,7 +1040,7 @@ static int vim2m_remove(struct platform_device *pdev)
v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME);
v4l2_m2m_release(dev->m2m_dev);
del_timer_sync(&dev->timer);
-   video_unregister_device(dev->vfd);
+   video_unregister_device(&dev->vfd);
v4l2_device_unregister(&dev->v4l2_dev);
 
return 0;
-- 
2.1.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 03/19] saa7146: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/media/common/saa7146/saa7146_fops.c | 19 ---
 drivers/media/pci/saa7146/hexium_gemini.c   |  2 +-
 drivers/media/pci/saa7146/hexium_orion.c|  2 +-
 drivers/media/pci/saa7146/mxb.c |  4 ++--
 drivers/media/pci/ttpci/av7110.h|  4 ++--
 drivers/media/pci/ttpci/budget-av.c |  2 +-
 include/media/saa7146_vv.h  |  4 ++--
 7 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_fops.c 
b/drivers/media/common/saa7146/saa7146_fops.c
index b7d6393..df1e8c9 100644
--- a/drivers/media/common/saa7146/saa7146_fops.c
+++ b/drivers/media/common/saa7146/saa7146_fops.c
@@ -587,26 +587,20 @@ int saa7146_vv_release(struct saa7146_dev* dev)
 }
 EXPORT_SYMBOL_GPL(saa7146_vv_release);
 
-int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
+int saa7146_register_device(struct video_device *vfd, struct saa7146_dev *dev,
char *name, int type)
 {
-   struct video_device *vfd;
int err;
int i;
 
DEB_EE("dev:%p, name:'%s', type:%d\n", dev, name, type);
 
-   // released by vfd->release
-   vfd = video_device_alloc();
-   if (vfd == NULL)
-   return -ENOMEM;
-
vfd->fops = &video_fops;
if (type == VFL_TYPE_GRABBER)
vfd->ioctl_ops = &dev->ext_vv_data->vid_ops;
else
vfd->ioctl_ops = &dev->ext_vv_data->vbi_ops;
-   vfd->release = video_device_release;
+   vfd->release = video_device_release_empty;
vfd->lock = &dev->v4l2_lock;
vfd->v4l2_dev = &dev->v4l2_dev;
vfd->tvnorms = 0;
@@ -618,25 +612,20 @@ int saa7146_register_device(struct video_device **vid, 
struct saa7146_dev* dev,
err = video_register_device(vfd, type, -1);
if (err < 0) {
ERR("cannot register v4l2 device. skipping.\n");
-   video_device_release(vfd);
return err;
}
 
pr_info("%s: registered device %s [v4l2]\n",
dev->name, video_device_node_name(vfd));
-
-   *vid = vfd;
return 0;
 }
 EXPORT_SYMBOL_GPL(saa7146_register_device);
 
-int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* 
dev)
+int saa7146_unregister_device(struct video_device *vfd, struct saa7146_dev 
*dev)
 {
DEB_EE("dev:%p\n", dev);
 
-   video_unregister_device(*vid);
-   *vid = NULL;
-
+   video_unregister_device(vfd);
return 0;
 }
 EXPORT_SYMBOL_GPL(saa7146_unregister_device);
diff --git a/drivers/media/pci/saa7146/hexium_gemini.c 
b/drivers/media/pci/saa7146/hexium_gemini.c
index 366434f..03cbcd2 100644
--- a/drivers/media/pci/saa7146/hexium_gemini.c
+++ b/drivers/media/pci/saa7146/hexium_gemini.c
@@ -66,7 +66,7 @@ struct hexium
 {
int type;
 
-   struct video_device *video_dev;
+   struct video_device video_dev;
struct i2c_adapter  i2c_adapter;
 
int cur_input;  /* current input */
diff --git a/drivers/media/pci/saa7146/hexium_orion.c 
b/drivers/media/pci/saa7146/hexium_orion.c
index a1eb26d..15f0d66 100644
--- a/drivers/media/pci/saa7146/hexium_orion.c
+++ b/drivers/media/pci/saa7146/hexium_orion.c
@@ -63,7 +63,7 @@ struct hexium_data
 struct hexium
 {
int type;
-   struct video_device *video_dev;
+   struct video_device video_dev;
struct i2c_adapter  i2c_adapter;
 
int cur_input;  /* current input */
diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c
index c4c8fce..0ca1e07 100644
--- a/drivers/media/pci/saa7146/mxb.c
+++ b/drivers/media/pci/saa7146/mxb.c
@@ -151,8 +151,8 @@ static struct mxb_routing TEA6420_line[MXB_AUDIOS + 1][2] = 
{
 
 struct mxb
 {
-   struct video_device *video_dev;
-   struct video_device *vbi_dev;
+   struct video_device video_dev;
+   struct video_device vbi_dev;
 
struct i2c_adapter  i2c_adapter;
 
diff --git a/drivers/media/pci/ttpci/av7110.h b/drivers/media/pci/ttpci/av7110.h
index ef3d960..835635b 100644
--- a/drivers/media/pci/ttpci/av7110.h
+++ b/drivers/media/pci/ttpci/av7110.h
@@ -102,8 +102,8 @@ struct av7110 {
struct dvb_device   dvb_dev;
struct dvb_net  dvb_net;
 
-   struct video_device *v4l_dev;
-   struct video_device *vbi_dev;
+   struct video_device v4l_dev;
+   struct video_device vbi_dev;
 
struct saa7146_dev  *dev;
 
diff --git a/drivers/media/pci/ttpci/budget-av.c 
b/drivers/media/pci/ttpci/budget-av.c
index 0ba3875..54c9910 100644
--- a/drivers/media/pci/ttpci/budget-av.c
+++ b/drivers/media/pci/ttpci/budget-av.c
@@ -68,7 +68,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 

[PATCH 04/19] radio-bcm2048: embed video_device

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil 
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 33 ---
 1 file changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 297ceaa..bd50fb2 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -279,7 +279,7 @@ struct region_info {
 
 struct bcm2048_device {
struct i2c_client *client;
-   struct video_device *videodev;
+   struct video_device videodev;
struct work_struct work;
struct completion compl;
struct mutex mutex;
@@ -2583,7 +2583,7 @@ static struct v4l2_ioctl_ops bcm2048_ioctl_ops = {
 static struct video_device bcm2048_viddev_template = {
.fops   = &bcm2048_fops,
.name   = BCM2048_DRIVER_NAME,
-   .release= video_device_release,
+   .release= video_device_release_empty,
.ioctl_ops  = &bcm2048_ioctl_ops,
 };
 
@@ -2602,13 +2602,6 @@ static int bcm2048_i2c_driver_probe(struct i2c_client 
*client,
goto exit;
}
 
-   bdev->videodev = video_device_alloc();
-   if (!bdev->videodev) {
-   dev_dbg(&client->dev, "Failed to alloc video device.\n");
-   err = -ENOMEM;
-   goto free_bdev;
-   }
-
bdev->client = client;
i2c_set_clientdata(client, bdev);
mutex_init(&bdev->mutex);
@@ -2621,16 +2614,16 @@ static int bcm2048_i2c_driver_probe(struct i2c_client 
*client,
client->name, bdev);
if (err < 0) {
dev_err(&client->dev, "Could not request IRQ\n");
-   goto free_vdev;
+   goto free_bdev;
}
dev_dbg(&client->dev, "IRQ requested.\n");
} else {
dev_dbg(&client->dev, "IRQ not configured. Using timeouts.\n");
}
 
-   *bdev->videodev = bcm2048_viddev_template;
-   video_set_drvdata(bdev->videodev, bdev);
-   if (video_register_device(bdev->videodev, VFL_TYPE_RADIO, radio_nr)) {
+   bdev->videodev = bcm2048_viddev_template;
+   video_set_drvdata(&bdev->videodev, bdev);
+   if (video_register_device(&bdev->videodev, VFL_TYPE_RADIO, radio_nr)) {
dev_dbg(&client->dev, "Could not register video device.\n");
err = -EIO;
goto free_irq;
@@ -2653,18 +2646,13 @@ static int bcm2048_i2c_driver_probe(struct i2c_client 
*client,
 free_sysfs:
bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs));
 free_registration:
-   video_unregister_device(bdev->videodev);
-   /* video_unregister_device frees bdev->videodev */
-   bdev->videodev = NULL;
+   video_unregister_device(&bdev->videodev);
skip_release = 1;
 free_irq:
if (client->irq)
free_irq(client->irq, bdev);
-free_vdev:
-   if (!skip_release)
-   video_device_release(bdev->videodev);
-   i2c_set_clientdata(client, NULL);
 free_bdev:
+   i2c_set_clientdata(client, NULL);
kfree(bdev);
 exit:
return err;
@@ -2673,16 +2661,13 @@ exit:
 static int __exit bcm2048_i2c_driver_remove(struct i2c_client *client)
 {
struct bcm2048_device *bdev = i2c_get_clientdata(client);
-   struct video_device *vd;
 
if (!client->adapter)
return -ENODEV;
 
if (bdev) {
-   vd = bdev->videodev;
-
bcm2048_sysfs_unregister_properties(bdev, ARRAY_SIZE(attrs));
-   video_unregister_device(vd);
+   video_unregister_device(&bdev->videodev);
 
if (bdev->power_state)
bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);
-- 
2.1.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 00/19] embed video_device struct

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This patch series converts 19 drivers so that they embed struct video_device
in their main struct. That simplifies the error handling since there is no
longer any need to call video_device_alloc or video_device_release.

Eventually (13 drivers still to go) all drivers should do this and we can
get rid of the ugly video_device_alloc/release/release_empty functions.

Regards,

Hans

Hans Verkuil (19):
  ivtv: embed video_device
  vim2m: embed video_device
  saa7146: embed video_device
  radio-bcm2048: embed video_device
  dt3155v4l: embed video_device
  cx88: embed video_device
  meye: embed video_device
  bttv: embed video_device
  cx18: embed video_device
  sta2x11: embed video_device
  m2m-deinterlace: embed video_device
  em28xx: embed video_device
  wl128x: embed video_device
  gadget/uvc: embed video_device
  hdpvr: embed video_device
  tm6000: embed video_device
  uvc: embed video_device
  usbvision: embed video_device
  cx231xx: embed video_device

 drivers/media/common/saa7146/saa7146_fops.c   |  19 +---
 drivers/media/pci/bt8xx/bttv-driver.c |  73 +---
 drivers/media/pci/bt8xx/bttvp.h   |   6 +-
 drivers/media/pci/cx18/cx18-alsa-main.c   |   2 +-
 drivers/media/pci/cx18/cx18-driver.h  |   2 +-
 drivers/media/pci/cx18/cx18-fileops.c |   2 +-
 drivers/media/pci/cx18/cx18-ioctl.c   |   2 +-
 drivers/media/pci/cx18/cx18-streams.c |  62 +-
 drivers/media/pci/cx18/cx18-streams.h |   2 +-
 drivers/media/pci/cx88/cx88-blackbird.c   |  22 ++---
 drivers/media/pci/cx88/cx88-core.c|  18 ++--
 drivers/media/pci/cx88/cx88-video.c   |  61 +
 drivers/media/pci/cx88/cx88.h |  17 ++--
 drivers/media/pci/ivtv/ivtv-alsa-main.c   |   2 +-
 drivers/media/pci/ivtv/ivtv-alsa-pcm.c|   2 +-
 drivers/media/pci/ivtv/ivtv-driver.c  |   4 +-
 drivers/media/pci/ivtv/ivtv-driver.h  |   2 +-
 drivers/media/pci/ivtv/ivtv-fileops.c |   2 +-
 drivers/media/pci/ivtv/ivtv-ioctl.c   |   8 +-
 drivers/media/pci/ivtv/ivtv-irq.c |   8 +-
 drivers/media/pci/ivtv/ivtv-streams.c | 107 ++-
 drivers/media/pci/ivtv/ivtv-streams.h |   2 +-
 drivers/media/pci/meye/meye.c |  19 ++--
 drivers/media/pci/meye/meye.h |   2 +-
 drivers/media/pci/saa7146/hexium_gemini.c |   2 +-
 drivers/media/pci/saa7146/hexium_orion.c  |   2 +-
 drivers/media/pci/saa7146/mxb.c   |   4 +-
 drivers/media/pci/sta2x11/sta2x11_vip.c   |  34 +++-
 drivers/media/pci/ttpci/av7110.h  |   4 +-
 drivers/media/pci/ttpci/budget-av.c   |   2 +-
 drivers/media/platform/m2m-deinterlace.c  |  21 ++---
 drivers/media/platform/vim2m.c|  23 ++---
 drivers/media/radio/wl128x/fmdrv_v4l2.c   |  28 +++---
 drivers/media/usb/cx231xx/cx231xx-417.c   |  33 +++
 drivers/media/usb/cx231xx/cx231xx-cards.c |   6 +-
 drivers/media/usb/cx231xx/cx231xx-video.c |  94 +++-
 drivers/media/usb/cx231xx/cx231xx.h   |   8 +-
 drivers/media/usb/em28xx/em28xx-video.c   | 119 +++---
 drivers/media/usb/em28xx/em28xx.h |   6 +-
 drivers/media/usb/hdpvr/hdpvr-core.c  |  10 +--
 drivers/media/usb/hdpvr/hdpvr-video.c |  19 ++--
 drivers/media/usb/hdpvr/hdpvr.h   |   2 +-
 drivers/media/usb/tm6000/tm6000-video.c   |  59 -
 drivers/media/usb/tm6000/tm6000.h |   4 +-
 drivers/media/usb/usbvision/usbvision-video.c |  70 ++-
 drivers/media/usb/usbvision/usbvision.h   |   4 +-
 drivers/media/usb/uvc/uvc_driver.c|  22 +
 drivers/media/usb/uvc/uvc_v4l2.c  |   2 +-
 drivers/media/usb/uvc/uvcvideo.h  |   2 +-
 drivers/staging/media/bcm2048/radio-bcm2048.c |  33 ++-
 drivers/staging/media/dt3155v4l/dt3155v4l.c   |  30 +++
 drivers/staging/media/dt3155v4l/dt3155v4l.h   |   4 +-
 drivers/usb/gadget/function/f_uvc.c   |  44 --
 drivers/usb/gadget/function/uvc.h |   2 +-
 include/media/saa7146_vv.h|   4 +-
 55 files changed, 419 insertions(+), 724 deletions(-)

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


RE: [RFC v2 2/7] media: rc: Add cec protocol handling

2015-03-09 Thread Kamil Debski
Hi Mauro, 

From: Mauro Carvalho Chehab [mailto:mche...@osg.samsung.com]
Sent: Sunday, March 08, 2015 3:21 PM

> Em Thu, 22 Jan 2015 17:04:34 +0100
> Kamil Debski  escreveu:
> 
> (c/c linux-input ML)
> 
> > Add cec protocol handling the RC framework.
> 
> I added some comments, that reflects my understanding from what's there
> at the keymap definitions found at:
>   http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf

Thank you very much for the review, Mauro. Your comments are very much 
appreciated.
 
> 
> >
> > Signed-off-by: Kamil Debski 
> > ---
> >  drivers/media/rc/keymaps/Makefile |1 +
> >  drivers/media/rc/keymaps/rc-cec.c |  133
> +
> >  drivers/media/rc/rc-main.c|1 +
> >  include/media/rc-core.h   |1 +
> >  include/media/rc-map.h|5 +-
> >  5 files changed, 140 insertions(+), 1 deletion(-)  create mode
> 100644
> > drivers/media/rc/keymaps/rc-cec.c
> >
> > diff --git a/drivers/media/rc/keymaps/Makefile
> > b/drivers/media/rc/keymaps/Makefile
> > index abf6079..56f10d6 100644
> > --- a/drivers/media/rc/keymaps/Makefile
> > +++ b/drivers/media/rc/keymaps/Makefile
> > @@ -18,6 +18,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
> > rc-behold.o \
> > rc-behold-columbus.o \
> > rc-budget-ci-old.o \
> > +   rc-cec.o \
> > rc-cinergy-1400.o \
> > rc-cinergy.o \
> > rc-delock-61959.o \
> > diff --git a/drivers/media/rc/keymaps/rc-cec.c
> > b/drivers/media/rc/keymaps/rc-cec.c
> > new file mode 100644
> > index 000..f2826c5
> > --- /dev/null
> > +++ b/drivers/media/rc/keymaps/rc-cec.c
> > @@ -0,0 +1,133 @@
> > +/* Keytable for the CEC remote control
> > + *
> > + * Copyright (c) 2015 by Kamil Debski
> > + *
> > + * This program is free software; you can redistribute it and/or
> > +modify
> > + * it under the terms of the GNU General Public License as published
> > +by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + */
> > +
> > +#include 
> > +#include 
> > +
> > +/* CEC Spec "High-Definition Multimedia Interface Specification" can
> > +be obtained
> > + * here: http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf
> > + * The list of control codes is listed in Table 27: User Control
> > +Codes p. 95 */
> > +
> > +static struct rc_map_table cec[] = {
> > +   { 0x00, KEY_SELECT }, /* XXX CEC Spec: Select, should it be
> > +KEY_SELECT or KEY_OK? */
> 
> KEY_OK is better, IMHO.
> 
> > +   { 0x01, KEY_UP },
> > +   { 0x02, KEY_DOWN },
> > +   { 0x03, KEY_LEFT },
> > +   { 0x04, KEY_RIGHT },
> > +   /* XXX 0x05-0x08 CEC Spec: Right-Up, Right-Down, Left-Up, Left-
> Down
> > +*/
> 
> I think you need to send a patch to linux-input, in order to add those
> keycodes.
> 
> > +   { 0x09, KEY_CONTEXT_MENU }, /* CEC Spec: Root Menu - see Note 2
> */
> > +   /* Note 2: This is the initial display that a device shows. It is
> > +* device-dependent and can be, for example, a contents menu,
> setup
> > +* menu, favorite menu or other menu. The actual menu displayed
> > +* may also depend on the device’s current state. */
> > +   { 0x0a, KEY_SETUP },
> > +   { 0x0b, KEY_MENU }, /* CEC Spec: Contents Menu */
> > +   { 0x0c, KEY_FAVORITES }, /* CEC Spec: Favorite Menu */
> > +   { 0x0d, KEY_EXIT },
> > +   /* 0x0e-0x1f: Reserved */
> > +   /* 0x20-0x29: Keys 0 to 9 */
> > +   { 0x20, KEY_0 },
> > +   { 0x21, KEY_1 },
> > +   { 0x22, KEY_2 },
> > +   { 0x23, KEY_3 },
> > +   { 0x24, KEY_4 },
> > +   { 0x25, KEY_5 },
> > +   { 0x26, KEY_6 },
> > +   { 0x27, KEY_7 },
> > +   { 0x28, KEY_8 },
> > +   { 0x29, KEY_9 },
> 
> Better to use KEY_NUMERIC_* here, as this is not affected by the shift
> state.
> 
> > +   { 0x2a, KEY_DOT },
> > +   { 0x2b, KEY_ENTER },
> > +   { 0x2c, KEY_CLEAR },
> > +   /* 0x2d-0x2e: Reserved */
> 
> > +   /* XXX 0x2f: CEC Spec: Next Favorite */
> Again another addition to Linux keystroke codes.
> 
> > +   { 0x30, KEY_CHANNELUP },
> > +   { 0x31, KEY_CHANNELDOWN },
> > +   { 0x32, KEY_PREVIOUS }, /* CEC Spec: Previous Channel */
> > +   { 0x33, KEY_SOUND }, /* CEC Spec: Sound Select */
> > +   /* XXX 0x34: CEC Spec: Input Select */
> 
> Another key to be added. Yet, other keymaps have a key to select the
> input source. Most use KEY_VIDEO, to select the video input source, and
> KEY_AUDIO, to select the audio input source.
> 
> So, KEY_VIDEO is likely the best choice here.
> 
> > +   { 0x35, KEY_INFO }, /* CEC Spec: Display Information */
> > +   { 0x36, KEY_HELP },
> > +   { 0x37, KEY_PAGEUP },
> > +   { 0x38, KEY_PAGEDOWN },
> > +   /* 0x39-0x3f: Reserved */
> > +   { 0x40, KEY_POWER },
> > +   { 0x41, KEY_VOLUMEUP },
> > +   { 0x42, KEY_VOLUMEDOWN },
> > +   { 0x43, KEY_MUTE },
> > +   { 0x44, KEY_PLAY },
> > +   { 0x45, KEY_STOP }, /* XXX CEC Spec: Stop, what about KEY_STOPCD?
> */
> > 

RE: [RFC v2 3/7] cec: add new framework for cec support.

2015-03-09 Thread Kamil Debski
Hi Sean,

From: Sean Young [mailto:s...@mess.org]
Sent: Sunday, March 08, 2015 11:45 AM
> 
> Hi Kamil,
> 
> On Fri, Mar 06, 2015 at 05:14:50PM +0100, Kamil Debski wrote:
> > 3) As you suggested - load an empty keymap whenever the pass through
> > mode is enabled.
> > I am not that familiar with the RC core. Is there a simple way to
> > switch to an empty map from the kernel? There is the ir_setkeytable
> > function, but it is static in rc-main.c, so it cannot be used in
> other
> > kernel modules. Any hints, Sean?
> 
> Why is it problematic if keypresses are passed to the input layer?

I gave this a thought over the weekend and I think I agree that this
shouldn't be much of a problem. I had doubts that there could be an
application that could use both the input device and at the same time
parse the raw messages to get keycodes. In reality this should not
happen, as someone using the "raw"/"promiscuous" mode would be aware
of how it works - that the keycodes are still passed to the input device.

> 
> You can only set the default keymap for an rc-device from kernel space;
> from user space you can clear the table using input ioctl, see:
> 
> http://git.linuxtv.org/cgit.cgi/v4l-
> utils.git/tree/utils/keytable/keytable.c#n1277
> 
> You can select MAP_EMPTY as the default keymap if that is appropriate;
> using
> ir-setkeytable(1) a different keymap can be selected.
> 
> 
> Sean

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


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


RE: [RFC v2 3/7] cec: add new framework for cec support.

2015-03-09 Thread Kamil Debski
Hi Mauro,

Thank you for your comments.

From: Mauro Carvalho Chehab [mailto:mche...@osg.samsung.com]
Sent: Sunday, March 08, 2015 4:42 PM

> 
> Em Fri, 06 Mar 2015 17:14:50 +0100
> Kamil Debski  escreveu:
> 
> > Hi Sean, Hans,
> >
> > I am sorry to reply so late, I was busy with other work. I am
> > preparing the next version of the CEC framework and I would like to
> > discuss your comment.
> 
> I'll do a deeper review of this patch when I have some time. For now,
> let me add my comments about the pass-trough mode. See below.

I think I might have confused you with the pass-through mode. I think it
would be good if I explained it in detail.

I guess my initial name choice wasn't fortunate. I prefer the name "raw"
over "pass through" as it is closer to what I meant by adding this feature. 
Maybe even "promiscuous" could be better.

The CEC framework does filtering on the messages it receives. It will
filter messages not directed to the device (different logical address)
and will do parsing of the keystrokes. The keystrokes are then reported by
the input framework to the userspace and won't be read by the CEC_RECEIVE
ioctl.

In the "raw"/"promiscuous" the messages on the CEC bus would not be
filtered and all of them should be passed to the userspace. This will
include messages not intended for the particular device and keystroke
messages. I think that this mode could be useful, e.g. for debugging and
maybe for devices that act as switches.

My original idea was that in the "raw" mode the CEC framework would stop
passing the keycodes from the CEC bus to the input device. I see that
this can be problematic, hence I think that suspending from passing the
keycodes to the input framework is not necessary. 

I think that this solution would be acceptable for you guys. Mauro, Sean,
Hans, tell me if I am wrong? To recap - the "raw"/"promiscuous" mode would
only disable filtering of messages and had no effect on passing keycodes
to the input device.

> >
> > From: Sean Young [mailto:s...@mess.org]
> > Sent: Friday, January 23, 2015 12:08 PM
> > >
> > > On Thu, Jan 22, 2015 at 05:04:35PM +0100, Kamil Debski wrote:
> > > > Add the CEC framework.
> > > -snip-
> > > > +Remote control handling
> > > > +---
> > > > +
> > > > +The CEC framework provides two ways of handling the key messages
> > > > +of remote control. In the first case, the CEC framework will
> > > > +handle these messages and provide the keypressed via the RC
> > > > +framework. In the second case the messages related to the key
> > > > +down/up events are not parsed by the framework and are passed to
> > > > +the userspace as raw
> > > messages.
> > > > +
> > > > +Switching between these modes is done with a special ioctl.
> > > > +
> > > > +#define CEC_G_KEY_PASSTHROUGH  _IOR('a', 10, __u8)
> > > > +#define CEC_S_KEY_PASSTHROUGH  _IOW('a', 11, __u8)
> > > > +#define CEC_KEY_PASSTHROUGH_DISABLE0
> > > > +#define CEC_KEY_PASSTHROUGH_ENABLE 1
> > >
> > > This is ugly. This ioctl stops keypresses from going to rc-core.
> The
> > > cec device is still registered with rc-core but no keys will be
> > > passed to it.
> > > This could also be handled by loading an empty keymap; this way the
> > > input layer will still receive scancodes but no keypresses.
> >
> > I see here a few options that can be done:
> >
> > 1) Remove the past through option altogether I think I would opt for
> > leaving it. There should be some mode that would enable raw access to
> > the CEC bus. Maybe it should be something more like a promiscuous
> mode
> > in Wi-Fi networks. What do you think? Sean, Hans?
> >
> > 2) Leave the pass through mode, but without disabling passing the
> > keyup/down events to the RC framework. This way an application could
> > capture all messages, but the input device would not be crippled in
> > any way. The problem with this solution is that key presses could be
> > accounted twice.
> >
> > 3) As you suggested - load an empty keymap whenever the pass through
> > mode is enabled.
> > I am not that familiar with the RC core. Is there a simple way to
> > switch to an empty map from the kernel? There is the ir_setkeytable
> > function, but it is static in rc-main.c, so it cannot be used in
> other
> > kernel modules. Any hints, Sean?
> >
> > 4) Remove the input device whenever a pass through mode is enabled.
> > This is an alternative to the solution number 3. I think it would not
> > be great, because a
> > /dev/input/event* that appears
> > and disappears could be confusing.
> 
> (4) doesn't seem nice.
> 
> I don't think that the driver itself should cleanup the keymap. This is
> something that the userspace app(s) should explicitly request.

I agree.

> With regards to the "raw" mode, the RC core currently has two ways to
> send/receive raw data:
> 
> 1) Via LIRC. This needs to be extended to pass scancodes, as, currently,
> it sends/receive pulses. We need such extension for other usages,
> anyway, so adding it makes sense.

T

Re: [PATCH 00/29] vivid: add support for 4:2:0 formats

2015-03-09 Thread Hans Verkuil
On 03/09/2015 04:44 PM, Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> This patch series adds support for most of the 4:2:0 formats that V4L2 has.
> In addition, it fixes various bugs, adds some new features and refactors
> the test pattern generation code.
> 
> The first 8 patches fix bugs and add support for new red/blue checkerboard
> patterns.
> 
> Patches 9-19 add 4:2:0 support to the test pattern generator code.
> 
> Patches 20-25 refactors the test pattern generation function which become
> much, much too large.
> 
> Patches 26-28 add vivid driver support for the 4:2:0 formats and the last
> patch finally enables support for the new formats.
> 
> Besides the new 4:2:0 formats support was also added for PIX_FMT_GREY and
> some missing 4:2:2 formats.

Before I forget: an updated v4l-utils with qv4l2 support for all the new
formats is here:

http://git.linuxtv.org/cgit.cgi/hverkuil/v4l-utils.git/log/?h=yuv420

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: [PATCH] v4l: mt9v032: Add OF support

2015-03-09 Thread Carlos Sanmartín Bustos
Hi Laurent,

I am agree with your argumentations. I hope for the v2.

Best regards,

Carlos Sanmartín

2015-03-09 12:19 GMT+01:00 Laurent Pinchart :
> Hi Carlos,
>
> Thank you for the review.
>
> On Monday 09 March 2015 10:45:31 Carlos Sanmartín Bustos wrote:
>> Hi Laurent,
>>
>> Looks good. One question, why not deprecate the platform data? I can't
>> see any device using the mt9v032 pdata, I was making a similar patch
>> but deprecating pdata.
>
> The sensor could be used on non-DT platforms. As keeping platform data support
> doesn't really make the code more complex and doesn't prevent cleanups or
> other refactoring, I don't see much harm in keeping it for now.
>
> For DT-based platforms, of course, DT should be used.
>
>> Some more comment:
>>
>> 2015-03-08 14:45 GMT+01:00 Laurent Pinchart:
>> > Parse DT properties into a platform data structure when a DT node is
>> > available.
>> >
>> > Signed-off-by: Laurent Pinchart 
>> > ---
>> >
>> >  .../devicetree/bindings/media/i2c/mt9v032.txt  | 41 ++
>> >  MAINTAINERS|  1 +
>> >  drivers/media/i2c/mt9v032.c| 66 -
>> >  3 files changed, 107 insertions(+), 1 deletion(-)
>> >  create mode 100644
>> >  Documentation/devicetree/bindings/media/i2c/mt9v032.txt
>
> [snip]
>
>> > diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
>> > index 3267c18..a6ea091 100644
>> > --- a/drivers/media/i2c/mt9v032.c
>> > +++ b/drivers/media/i2c/mt9v032.c
>
> [snip]
>
>> > +static struct mt9v032_platform_data *
>> > +mt9v032_get_pdata(struct i2c_client *client)
>> > +{
>> > +   struct mt9v032_platform_data *pdata;
>> > +   struct v4l2_of_endpoint endpoint;
>> > +   struct device_node *np;
>> > +   struct property *prop;
>> > +
>> > +   if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
>> > +   return client->dev.platform_data;
>> > +
>> > +   np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL);
>> > +   if (!np)
>> > +   return NULL;
>> > +
>> > +   if (v4l2_of_parse_endpoint(np, &endpoint) < 0)
>> > +   goto done;
>>
>> Here I have one little testing:
>>
>> if (endpoint.bus_type != V4L2_MBUS_PARALLEL) {
>> dev_err(dev, "invalid bus type, must be parallel\n");
>> goto done;
>> }
>
> Good question, should drivers check DT properties that they don't use, in
> order to catch errors in DT ? This would slightly increase the kernel size in
> order to prevent people from connecting a parallel sensor to a CSI-2 bus,
> which is obviously impossible in hardware :-)
>
>> > +
>> > +   pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
>> > +   if (!pdata)
>> > +   goto done;
>> > +
>> > +   prop = of_find_property(np, "link-freqs", NULL);
>> > +   if (prop) {
>> > +   size_t size = prop->length / 8;
>> > +   u64 *link_freqs;
>> > +
>> > +   link_freqs = devm_kzalloc(&client->dev,
>> > + size * sizeof(*link_freqs),
>> > + GFP_KERNEL);
>> > +   if (!link_freqs)
>> > +   goto done;
>> > +
>> > +   if (of_property_read_u64_array(np, "link-frequencies",
>> > +  link_freqs, size) < 0)
>> > +   goto done;
>> > +
>> > +   pdata->link_freqs = link_freqs;
>> > +   pdata->link_def_freq = link_freqs[0];
>> > +   }
>> > +
>> > +   pdata->clk_pol = !!(endpoint.bus.parallel.flags &
>> > +   V4L2_MBUS_PCLK_SAMPLE_RISING);
>> > +
>> > +done:
>> > +   of_node_put(np);
>> > +   return pdata;
>> > +}
>
> [snip]
>
>> > @@ -1034,9 +1086,21 @@ static const struct i2c_device_id mt9v032_id[] = {
>> >  };
>> >  MODULE_DEVICE_TABLE(i2c, mt9v032_id);
>> >
>> > +#if IS_ENABLED(CONFIG_OF)
>> > +static const struct of_device_id mt9v032_of_match[] = {
>> > +   { .compatible = "mt9v032" },
>> > +   { .compatible = "mt9v032m" },
>> > +   { .compatible = "mt9v034" },
>> > +   { .compatible = "mt9v034m" },
>> > +   { /* Sentinel */ }
>> > +};
>> > +MODULE_DEVICE_TABLE(of, mt9v032_of_match);
>> > +#endif
>>
>> I have this:
>> #if IS_ENABLED(CONFIG_OF)
>> static const struct of_device_id mt9v032_of_match[] = {
>> { .compatible = "aptina,mt9v022", },
>> { .compatible = "aptina,mt9v022m", },
>> { .compatible = "aptina,mt9v024", },
>> { .compatible = "aptina,mt9v024m", },
>> { .compatible = "aptina,mt9v032", },
>> { .compatible = "aptina,mt9v032m", },
>> { .compatible = "aptina,mt9v034", },
>> { .compatible = "aptina,mt9v034m", },
>
> Looks like I forgot to update my patch for mt9v02* support. Sorry about that,
> I'll fix it. And the "aptina," prefix of course belongs there.
>
>> { /* sentinel */ },
>> };
>>
>> MODULE_DEVICE_TABLE(of, mt9v032_of_matc

[PATCH 28/29] vivid: add downsampling support

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Add support in vivid for downsampling. Most of the changes are in
vivid_copy_buffer which needs to know about the right line widths.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-kthread-cap.c | 68 ++--
 drivers/media/platform/vivid/vivid-vid-out.c |  7 +--
 2 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c 
b/drivers/media/platform/vivid/vivid-kthread-cap.c
index 22e1784..1727f54 100644
--- a/drivers/media/platform/vivid/vivid-kthread-cap.c
+++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
@@ -249,8 +249,9 @@ static int vivid_copy_buffer(struct vivid_dev *dev, 
unsigned p, u8 *vcapbuf,
bool blank = dev->must_blank[vid_cap_buf->vb.v4l2_buf.index];
struct tpg_data *tpg = &dev->tpg;
struct vivid_buffer *vid_out_buf = NULL;
-   unsigned pixsize = tpg_g_twopixelsize(tpg, p) / 2;
-   unsigned img_width = dev->compose_cap.width;
+   unsigned vdiv = dev->fmt_out->vdownsampling[p];
+   unsigned twopixsize = tpg_g_twopixelsize(tpg, p);
+   unsigned img_width = tpg_hdiv(tpg, p, dev->compose_cap.width);
unsigned img_height = dev->compose_cap.height;
unsigned stride_cap = tpg->bytesperline[p];
unsigned stride_out = dev->bytesperline_out[p];
@@ -269,6 +270,7 @@ static int vivid_copy_buffer(struct vivid_dev *dev, 
unsigned p, u8 *vcapbuf,
unsigned vid_overlay_fract_part = 0;
unsigned vid_overlay_y = 0;
unsigned vid_overlay_error = 0;
+   unsigned vid_cap_left = tpg_hdiv(tpg, p, dev->loop_vid_cap.left);
unsigned vid_cap_right;
bool quick;
 
@@ -287,23 +289,25 @@ static int vivid_copy_buffer(struct vivid_dev *dev, 
unsigned p, u8 *vcapbuf,
  dev->bytesperline_out, dev->fmt_out_rect.height);
if (p < dev->fmt_out->buffers)
voutbuf += vid_out_buf->vb.v4l2_planes[p].data_offset;
-   voutbuf += dev->loop_vid_out.left * pixsize + dev->loop_vid_out.top * 
stride_out;
-   vcapbuf += dev->compose_cap.left * pixsize + dev->compose_cap.top * 
stride_cap;
+   voutbuf += tpg_hdiv(tpg, p, dev->loop_vid_out.left) +
+   (dev->loop_vid_out.top / vdiv) * stride_out;
+   vcapbuf += tpg_hdiv(tpg, p, dev->compose_cap.left) +
+   (dev->compose_cap.top / vdiv) * stride_cap;
 
if (dev->loop_vid_copy.width == 0 || dev->loop_vid_copy.height == 0) {
/*
 * If there is nothing to copy, then just fill the capture 
window
 * with black.
 */
-   for (y = 0; y < hmax; y++, vcapbuf += stride_cap)
-   memcpy(vcapbuf, tpg->black_line[p], img_width * 
pixsize);
+   for (y = 0; y < hmax / vdiv; y++, vcapbuf += stride_cap)
+   memcpy(vcapbuf, tpg->black_line[p], img_width);
return 0;
}
 
if (dev->overlay_out_enabled &&
dev->loop_vid_overlay.width && dev->loop_vid_overlay.height) {
vosdbuf = dev->video_vbase;
-   vosdbuf += dev->loop_fb_copy.left * pixsize +
+   vosdbuf += (dev->loop_fb_copy.left * twopixsize) / 2 +
   dev->loop_fb_copy.top * stride_osd;
vid_overlay_int_part = dev->loop_vid_overlay.height /
   dev->loop_vid_overlay_cap.height;
@@ -311,12 +315,12 @@ static int vivid_copy_buffer(struct vivid_dev *dev, 
unsigned p, u8 *vcapbuf,
 dev->loop_vid_overlay_cap.height;
}
 
-   vid_cap_right = dev->loop_vid_cap.left + dev->loop_vid_cap.width;
+   vid_cap_right = tpg_hdiv(tpg, p, dev->loop_vid_cap.left + 
dev->loop_vid_cap.width);
/* quick is true if no video scaling is needed */
quick = dev->loop_vid_out.width == dev->loop_vid_cap.width;
 
dev->cur_scaled_line = dev->loop_vid_out.height;
-   for (y = 0; y < hmax; y++, vcapbuf += stride_cap) {
+   for (y = 0; y < hmax; y += vdiv, vcapbuf += stride_cap) {
/* osdline is true if this line requires overlay blending */
bool osdline = vosdbuf && y >= dev->loop_vid_overlay_cap.top &&
  y < dev->loop_vid_overlay_cap.top + 
dev->loop_vid_overlay_cap.height;
@@ -327,34 +331,34 @@ static int vivid_copy_buffer(struct vivid_dev *dev, 
unsigned p, u8 *vcapbuf,
 */
if (y < dev->loop_vid_cap.top ||
y >= dev->loop_vid_cap.top + dev->loop_vid_cap.height) {
-   memcpy(vcapbuf, tpg->black_line[p], img_width * 
pixsize);
+   memcpy(vcapbuf, tpg->black_line[p], img_width);
continue;
}
 
/* fill the left border with black */
if (dev->loop_vid_cap.left)
-   memcpy(vcapbuf, tpg->blac

[PATCH 26/29] vivid: add new format fields

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

These fields are necessary to handle the new planar formats.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-core.h   |  4 +-
 drivers/media/platform/vivid/vivid-vid-cap.c| 18 --
 drivers/media/platform/vivid/vivid-vid-common.c | 84 ++---
 drivers/media/platform/vivid/vivid-vid-out.c|  8 +--
 4 files changed, 81 insertions(+), 33 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-core.h 
b/drivers/media/platform/vivid/vivid-core.h
index 191d9b5..bcefd19 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -79,12 +79,14 @@ extern unsigned vivid_debug;
 struct vivid_fmt {
const char *name;
u32 fourcc;  /* v4l2 format id */
-   u8  depth;
boolis_yuv;
boolcan_do_overlay;
+   u8  vdownsampling[TPG_MAX_PLANES];
u32 alpha_mask;
u8  planes;
+   u8  buffers;
u32 data_offset[TPG_MAX_PLANES];
+   u32 bit_depth[TPG_MAX_PLANES];
 };
 
 extern struct vivid_fmt vivid_formats[];
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c 
b/drivers/media/platform/vivid/vivid-vid-cap.c
index d41ac44..4d50961 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -42,20 +42,26 @@ static const struct vivid_fmt formats_ovl[] = {
{
.name = "RGB565 (LE)",
.fourcc   = V4L2_PIX_FMT_RGB565, /* gggb rggg */
-   .depth= 16,
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
.planes   = 1,
+   .buffers = 1,
},
{
.name = "XRGB555 (LE)",
.fourcc   = V4L2_PIX_FMT_XRGB555, /* gggb argg */
-   .depth= 16,
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
.planes   = 1,
+   .buffers = 1,
},
{
.name = "ARGB555 (LE)",
.fourcc   = V4L2_PIX_FMT_ARGB555, /* gggb argg */
-   .depth= 16,
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
.planes   = 1,
+   .buffers = 1,
},
 };
 
@@ -597,9 +603,9 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,
/* This driver supports custom bytesperline values */
 
/* Calculate the minimum supported bytesperline value */
-   bytesperline = (mp->width * fmt->depth) >> 3;
+   bytesperline = (mp->width * fmt->bit_depth[0]) >> 3;
/* Calculate the maximum supported bytesperline value */
-   max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->depth) >> 3;
+   max_bpl = (MAX_ZOOM * MAX_WIDTH * fmt->bit_depth[0]) >> 3;
mp->num_planes = fmt->planes;
for (p = 0; p < mp->num_planes; p++) {
if (pfmt[p].bytesperline > max_bpl)
@@ -1224,7 +1230,7 @@ int vivid_vid_cap_s_fbuf(struct file *file, void *fh,
fmt = vivid_get_format(dev, a->fmt.pixelformat);
if (!fmt || !fmt->can_do_overlay)
return -EINVAL;
-   if (a->fmt.bytesperline < (a->fmt.width * fmt->depth) / 8)
+   if (a->fmt.bytesperline < (a->fmt.width * fmt->bit_depth[0]) / 8)
return -EINVAL;
if (a->fmt.height * a->fmt.bytesperline < a->fmt.sizeimage)
return -EINVAL;
diff --git a/drivers/media/platform/vivid/vivid-vid-common.c 
b/drivers/media/platform/vivid/vivid-vid-common.c
index 49c9bc6..7a02aef 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -46,139 +46,179 @@ struct vivid_fmt vivid_formats[] = {
{
.name = "4:2:2, packed, YUYV",
.fourcc   = V4L2_PIX_FMT_YUYV,
-   .depth= 16,
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
.is_yuv   = true,
.planes   = 1,
+   .buffers = 1,
.data_offset = { PLANE0_DATA_OFFSET, 0 },
},
{
.name = "4:2:2, packed, UYVY",
.fourcc   = V4L2_PIX_FMT_UYVY,
-   .depth= 16,
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
.is_yuv   = true,
.planes   = 1,
+   .buffers = 1,
},
{
.name = "4:2:2, packed, YVYU",
.fourcc   = V4L2_PIX_FMT_YVYU,
-   .depth= 16,
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
.is_yuv   = true,
.planes   = 1,
+   .buffers = 1,
},
{
.name = "4:2:2, packed, VYUY",
.fourcc   = V4L2_PIX_FMT_VYUY,
-   .depth= 16,
+   .

[PATCH 25/29] vivid-tpg: split off the pattern drawing code.

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The last part of the vivid-tpg refactoring: split off the pattern
drawing code into a function of its own. This greatly improves the
readability and maintainability of this code.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 320 ---
 1 file changed, 162 insertions(+), 158 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 5ff9db9..e7086e1 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1689,19 +1689,153 @@ static void tpg_fill_plane_extras(const struct 
tpg_data *tpg,
}
 }
 
-void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf)
+static void tpg_fill_plane_pattern(const struct tpg_data *tpg,
+  const struct tpg_draw_params *params,
+  unsigned p, unsigned h, u8 *vbuf)
+{
+   unsigned twopixsize = params->twopixsize;
+   unsigned img_width = params->img_width;
+   unsigned mv_hor_old = params->mv_hor_old;
+   unsigned mv_hor_new = params->mv_hor_new;
+   unsigned mv_vert_old = params->mv_vert_old;
+   unsigned mv_vert_new = params->mv_vert_new;
+   unsigned frame_line = params->frame_line;
+   unsigned frame_line_next = params->frame_line_next;
+   unsigned line_offset = tpg_hscale_div(tpg, p, tpg->crop.left);
+   bool even;
+   bool fill_blank = false;
+   unsigned pat_line_old;
+   unsigned pat_line_new;
+   u8 *linestart_older;
+   u8 *linestart_newer;
+   u8 *linestart_top;
+   u8 *linestart_bottom;
+
+   even = !(frame_line & 1);
+
+   if (h >= params->hmax) {
+   if (params->hmax == tpg->compose.height)
+   return;
+   if (!tpg->perc_fill_blank)
+   return;
+   fill_blank = true;
+   }
+
+   if (tpg->vflip) {
+   frame_line = tpg->src_height - frame_line - 1;
+   frame_line_next = tpg->src_height - frame_line_next - 1;
+   }
+
+   if (fill_blank) {
+   linestart_older = tpg->contrast_line[p];
+   linestart_newer = tpg->contrast_line[p];
+   } else if (tpg->qual != TPG_QUAL_NOISE &&
+  (frame_line < tpg->border.top ||
+   frame_line >= tpg->border.top + tpg->border.height)) {
+   linestart_older = tpg->black_line[p];
+   linestart_newer = tpg->black_line[p];
+   } else if (tpg->pattern == TPG_PAT_NOISE || tpg->qual == 
TPG_QUAL_NOISE) {
+   linestart_older = tpg->random_line[p] +
+ twopixsize * prandom_u32_max(tpg->src_width / 
2);
+   linestart_newer = tpg->random_line[p] +
+ twopixsize * prandom_u32_max(tpg->src_width / 
2);
+   } else {
+   unsigned frame_line_old =
+   (frame_line + mv_vert_old) % tpg->src_height;
+   unsigned frame_line_new =
+   (frame_line + mv_vert_new) % tpg->src_height;
+   unsigned pat_line_next_old;
+   unsigned pat_line_next_new;
+
+   pat_line_old = tpg_get_pat_line(tpg, frame_line_old);
+   pat_line_new = tpg_get_pat_line(tpg, frame_line_new);
+   linestart_older = tpg->lines[pat_line_old][p] + mv_hor_old;
+   linestart_newer = tpg->lines[pat_line_new][p] + mv_hor_new;
+
+   if (tpg->vdownsampling[p] > 1 && frame_line != frame_line_next) 
{
+   int avg_pat;
+
+   /*
+* Now decide whether we need to use 
downsampled_lines[].
+* That's necessary if the two lines use different 
patterns.
+*/
+   pat_line_next_old = tpg_get_pat_line(tpg,
+   (frame_line_next + mv_vert_old) % 
tpg->src_height);
+   pat_line_next_new = tpg_get_pat_line(tpg,
+   (frame_line_next + mv_vert_new) % 
tpg->src_height);
+
+   switch (tpg->field) {
+   case V4L2_FIELD_INTERLACED:
+   case V4L2_FIELD_INTERLACED_BT:
+   case V4L2_FIELD_INTERLACED_TB:
+   avg_pat = tpg_pattern_avg(tpg, pat_line_old, 
pat_line_new);
+   if (avg_pat < 0)
+   break;
+   linestart_older = 
tpg->downsampled_lines[avg_pat][p] + mv_hor_old;
+   linestart_newer = linestart_older;
+   break;
+   case V4L2_FIELD_NONE:
+   case V4L2_FIELD_TOP:
+   case V4L2_FIELD_BOTTOM:
+  

[PATCH 27/29] vivid: add support for single buffer planar formats

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Make vivid aware of the difference of planes and buffers. Note that
this does not yet add support for hor/vert downsampled formats.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-core.h|  2 +-
 drivers/media/platform/vivid/vivid-kthread-cap.c | 54 --
 drivers/media/platform/vivid/vivid-vid-cap.c | 58 ++--
 drivers/media/platform/vivid/vivid-vid-common.c  |  2 +-
 drivers/media/platform/vivid/vivid-vid-out.c | 70 ++--
 5 files changed, 106 insertions(+), 80 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-core.h 
b/drivers/media/platform/vivid/vivid-core.h
index bcefd19..9e15aee 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -334,7 +334,7 @@ struct vivid_dev {
u32 ycbcr_enc_out;
u32 quantization_out;
u32 service_set_out;
-   u32 bytesperline_out[TPG_MAX_PLANES];
+   unsignedbytesperline_out[TPG_MAX_PLANES];
unsignedtv_field_out;
unsignedtv_audio_output;
boolvbi_out_have_wss;
diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c 
b/drivers/media/platform/vivid/vivid-kthread-cap.c
index 9976d45..22e1784 100644
--- a/drivers/media/platform/vivid/vivid-kthread-cap.c
+++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
@@ -229,6 +229,20 @@ static void vivid_precalc_copy_rects(struct vivid_dev *dev)
dev->loop_vid_overlay_cap.left, dev->loop_vid_overlay_cap.top);
 }
 
+static void *plane_vaddr(struct tpg_data *tpg, struct vivid_buffer *buf,
+unsigned p, unsigned bpl[TPG_MAX_PLANES], unsigned h)
+{
+   unsigned i;
+   void *vbuf;
+
+   if (p == 0 || tpg_g_buffers(tpg) > 1)
+   return vb2_plane_vaddr(&buf->vb, p);
+   vbuf = vb2_plane_vaddr(&buf->vb, 0);
+   for (i = 0; i < p; i++)
+   vbuf += bpl[i] * h / tpg->vdownsampling[i];
+   return vbuf;
+}
+
 static int vivid_copy_buffer(struct vivid_dev *dev, unsigned p, u8 *vcapbuf,
struct vivid_buffer *vid_cap_buf)
 {
@@ -269,8 +283,10 @@ static int vivid_copy_buffer(struct vivid_dev *dev, 
unsigned p, u8 *vcapbuf,
 
vid_cap_buf->vb.v4l2_buf.field = vid_out_buf->vb.v4l2_buf.field;
 
-   voutbuf = vb2_plane_vaddr(&vid_out_buf->vb, p) +
- vid_out_buf->vb.v4l2_planes[p].data_offset;
+   voutbuf = plane_vaddr(tpg, vid_out_buf, p,
+ dev->bytesperline_out, dev->fmt_out_rect.height);
+   if (p < dev->fmt_out->buffers)
+   voutbuf += vid_out_buf->vb.v4l2_planes[p].data_offset;
voutbuf += dev->loop_vid_out.left * pixsize + dev->loop_vid_out.top * 
stride_out;
vcapbuf += dev->compose_cap.left * pixsize + dev->compose_cap.top * 
stride_cap;
 
@@ -395,6 +411,7 @@ update_vid_out_y:
 
 static void vivid_fillbuff(struct vivid_dev *dev, struct vivid_buffer *buf)
 {
+   struct tpg_data *tpg = &dev->tpg;
unsigned factor = V4L2_FIELD_HAS_T_OR_B(dev->field_cap) ? 2 : 1;
unsigned line_height = 16 / factor;
bool is_tv = vivid_is_sdtv_cap(dev);
@@ -436,28 +453,29 @@ static void vivid_fillbuff(struct vivid_dev *dev, struct 
vivid_buffer *buf)
} else {
buf->vb.v4l2_buf.field = dev->field_cap;
}
-   tpg_s_field(&dev->tpg, buf->vb.v4l2_buf.field,
+   tpg_s_field(tpg, buf->vb.v4l2_buf.field,
dev->field_cap == V4L2_FIELD_ALTERNATE);
-   tpg_s_perc_fill_blank(&dev->tpg, 
dev->must_blank[buf->vb.v4l2_buf.index]);
+   tpg_s_perc_fill_blank(tpg, dev->must_blank[buf->vb.v4l2_buf.index]);
 
vivid_precalc_copy_rects(dev);
 
-   for (p = 0; p < tpg_g_planes(&dev->tpg); p++) {
-   void *vbuf = vb2_plane_vaddr(&buf->vb, p);
+   for (p = 0; p < tpg_g_planes(tpg); p++) {
+   void *vbuf = plane_vaddr(tpg, buf, p,
+tpg->bytesperline, tpg->buf_height);
 
/*
 * The first plane of a multiplanar format has a non-zero
 * data_offset. This helps testing whether the application
 * correctly supports non-zero data offsets.
 */
-   if (dev->fmt_cap->data_offset[p]) {
+   if (p < tpg_g_buffers(tpg) && dev->fmt_cap->data_offset[p]) {
memset(vbuf, dev->fmt_cap->data_offset[p] & 0xff,
   dev->fmt_cap->data_offset[p]);
vbuf += dev->fmt_cap->data_offset[p];
}
-   tpg_calc_text_basep(&dev->tpg, basep, p, vbuf);
+   tpg_calc_text_basep(tpg, basep, p, vbuf);
if (!is

[PATCH 22/29] vivid-tpg: move pattern-related fields to struct tpg_draw_params

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Add a new function that fills in pattern-related fields in struct
tpg_draw_params.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 30 --
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 1e5eefa..c477730 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1539,13 +1539,26 @@ struct tpg_draw_params {
unsigned right_pillar_start;
 };
 
+static void tpg_fill_params_pattern(const struct tpg_data *tpg, unsigned p,
+   struct tpg_draw_params *params)
+{
+   params->mv_hor_old =
+   tpg_hscale_div(tpg, p, tpg->mv_hor_count % tpg->src_width);
+   params->mv_hor_new =
+   tpg_hscale_div(tpg, p, (tpg->mv_hor_count + tpg->mv_hor_step) %
+  tpg->src_width);
+   params->mv_vert_old = tpg->mv_vert_count % tpg->src_height;
+   params->mv_vert_new =
+   (tpg->mv_vert_count + tpg->mv_vert_step) % tpg->src_height;
+}
+
 void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf)
 {
struct tpg_draw_params params;
-   unsigned mv_hor_old = tpg->mv_hor_count % tpg->src_width;
-   unsigned mv_hor_new = (tpg->mv_hor_count + tpg->mv_hor_step) % 
tpg->src_width;
-   unsigned mv_vert_old = tpg->mv_vert_count % tpg->src_height;
-   unsigned mv_vert_new = (tpg->mv_vert_count + tpg->mv_vert_step) % 
tpg->src_height;
+   unsigned mv_hor_old;
+   unsigned mv_hor_new;
+   unsigned mv_vert_old;
+   unsigned mv_vert_new;
unsigned wss_width;
unsigned f;
int h;
@@ -1574,12 +1587,17 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
params.stride = tpg->bytesperline[p];
params.hmax = (tpg->compose.height * tpg->perc_fill) / 100;
 
+   tpg_fill_params_pattern(tpg, p, ¶ms);
+
+   mv_hor_old = params.mv_hor_old;
+   mv_hor_new = params.mv_hor_new;
+   mv_vert_old = params.mv_vert_old;
+   mv_vert_new = params.mv_vert_new;
+
twopixsize = params.twopixsize;
img_width = params.img_width;
stride = params.stride;
 
-   mv_hor_old = tpg_hscale_div(tpg, p, mv_hor_old);
-   mv_hor_new = tpg_hscale_div(tpg, p, mv_hor_new);
wss_width = tpg->crop.left < tpg->src_width / 2 ?
tpg->src_width / 2 - tpg->crop.left : 0;
if (wss_width > tpg->crop.width)
-- 
2.1.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 24/29] vivid-tpg: move the 'extras' drawing to a separate function

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This moves the drawing code for the extras (border, square, etc) to
a function of its own instead of having this in the main for loop.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 216 +++
 1 file changed, 104 insertions(+), 112 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index a738ce1..5ff9db9 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1590,6 +1590,105 @@ static void tpg_fill_params_extras(const struct 
tpg_data *tpg,
(params->is_60hz ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
 }
 
+static void tpg_fill_plane_extras(const struct tpg_data *tpg,
+ const struct tpg_draw_params *params,
+ unsigned p, unsigned h, u8 *vbuf)
+{
+   unsigned twopixsize = params->twopixsize;
+   unsigned img_width = params->img_width;
+   unsigned frame_line = params->frame_line;
+   const struct v4l2_rect *sq = &tpg->square;
+   const struct v4l2_rect *b = &tpg->border;
+   const struct v4l2_rect *c = &tpg->crop;
+
+   if (params->is_tv && !params->is_60hz &&
+   frame_line == 0 && params->wss_width) {
+   /*
+* Replace the first half of the top line of a 50 Hz frame
+* with random data to simulate a WSS signal.
+*/
+   u8 *wss = tpg->random_line[p] + params->wss_random_offset;
+
+   memcpy(vbuf, wss, params->wss_width);
+   }
+
+   if (tpg->show_border && frame_line >= b->top &&
+   frame_line < b->top + b->height) {
+   unsigned bottom = b->top + b->height - 1;
+   unsigned left = params->left_pillar_width;
+   unsigned right = params->right_pillar_start;
+
+   if (frame_line == b->top || frame_line == b->top + 1 ||
+   frame_line == bottom || frame_line == bottom - 1) {
+   memcpy(vbuf + left, tpg->contrast_line[p],
+   right - left);
+   } else {
+   if (b->left >= c->left &&
+   b->left < c->left + c->width)
+   memcpy(vbuf + left,
+   tpg->contrast_line[p], twopixsize);
+   if (b->left + b->width > c->left &&
+   b->left + b->width <= c->left + c->width)
+   memcpy(vbuf + right - twopixsize,
+   tpg->contrast_line[p], twopixsize);
+   }
+   }
+   if (tpg->qual != TPG_QUAL_NOISE && frame_line >= b->top &&
+   frame_line < b->top + b->height) {
+   memcpy(vbuf, tpg->black_line[p], params->left_pillar_width);
+   memcpy(vbuf + params->right_pillar_start, tpg->black_line[p],
+  img_width - params->right_pillar_start);
+   }
+   if (tpg->show_square && frame_line >= sq->top &&
+   frame_line < sq->top + sq->height &&
+   sq->left < c->left + c->width &&
+   sq->left + sq->width >= c->left) {
+   unsigned left = sq->left;
+   unsigned width = sq->width;
+
+   if (c->left > left) {
+   width -= c->left - left;
+   left = c->left;
+   }
+   if (c->left + c->width < left + width)
+   width -= left + width - c->left - c->width;
+   left -= c->left;
+   left = tpg_hscale_div(tpg, p, left);
+   width = tpg_hscale_div(tpg, p, width);
+   memcpy(vbuf + left, tpg->contrast_line[p], width);
+   }
+   if (tpg->insert_sav) {
+   unsigned offset = tpg_hdiv(tpg, p, tpg->compose.width / 3);
+   u8 *p = vbuf + offset;
+   unsigned vact = 0, hact = 0;
+
+   p[0] = 0xff;
+   p[1] = 0;
+   p[2] = 0;
+   p[3] = 0x80 | (params->sav_eav_f << 6) |
+   (vact << 5) | (hact << 4) |
+   ((hact ^ vact) << 3) |
+   ((hact ^ params->sav_eav_f) << 2) |
+   ((params->sav_eav_f ^ vact) << 1) |
+   (hact ^ vact ^ params->sav_eav_f);
+   }
+   if (tpg->insert_eav) {
+   unsigned offset = tpg_hdiv(tpg, p, tpg->compose.width * 2 / 3);
+   u8 *p = vbuf + offset;
+   unsigned vact = 0, hact = 1;
+
+   p[0] = 0xff;
+   p[1] = 0;
+   p[2] = 0;
+   p[3] = 0x80 | (params->sav_eav_f << 6) |
+   (vact << 5) | (hact << 4) |
+   ((hact ^ vact) << 3) |
+   ((hact ^ params->sav_eav_f) << 2) |
+

[PATCH 29/29] vivid: add the new planar and monochrome formats

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Everything is in place to support these formats, so add them to
the list.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-vid-common.c | 114 +++-
 1 file changed, 111 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-vid-common.c 
b/drivers/media/platform/vivid/vivid-vid-common.c
index 0f93fea..7cb4aa0 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -51,7 +51,7 @@ struct vivid_fmt vivid_formats[] = {
.is_yuv   = true,
.planes   = 1,
.buffers = 1,
-   .data_offset = { PLANE0_DATA_OFFSET, 0 },
+   .data_offset = { PLANE0_DATA_OFFSET },
},
{
.name = "4:2:2, packed, UYVY",
@@ -81,6 +81,78 @@ struct vivid_fmt vivid_formats[] = {
.buffers = 1,
},
{
+   .name = "YUV 4:2:2 triplanar",
+   .fourcc   = V4L2_PIX_FMT_YUV422P,
+   .vdownsampling = { 1, 1, 1 },
+   .bit_depth = { 8, 4, 4 },
+   .is_yuv   = true,
+   .planes   = 3,
+   .buffers = 1,
+   },
+   {
+   .name = "YUV 4:2:0 triplanar",
+   .fourcc   = V4L2_PIX_FMT_YUV420,
+   .vdownsampling = { 1, 2, 2 },
+   .bit_depth = { 8, 4, 4 },
+   .is_yuv   = true,
+   .planes   = 3,
+   .buffers = 1,
+   },
+   {
+   .name = "YVU 4:2:0 triplanar",
+   .fourcc   = V4L2_PIX_FMT_YVU420,
+   .vdownsampling = { 1, 2, 2 },
+   .bit_depth = { 8, 4, 4 },
+   .is_yuv   = true,
+   .planes   = 3,
+   .buffers = 1,
+   },
+   {
+   .name = "YUV 4:2:0 biplanar",
+   .fourcc   = V4L2_PIX_FMT_NV12,
+   .vdownsampling = { 1, 2 },
+   .bit_depth = { 8, 8 },
+   .is_yuv   = true,
+   .planes   = 2,
+   .buffers = 1,
+   },
+   {
+   .name = "YVU 4:2:0 biplanar",
+   .fourcc   = V4L2_PIX_FMT_NV21,
+   .vdownsampling = { 1, 2 },
+   .bit_depth = { 8, 8 },
+   .is_yuv   = true,
+   .planes   = 2,
+   .buffers = 1,
+   },
+   {
+   .name = "YUV 4:2:2 biplanar",
+   .fourcc   = V4L2_PIX_FMT_NV16,
+   .vdownsampling = { 1, 1 },
+   .bit_depth = { 8, 8 },
+   .is_yuv   = true,
+   .planes   = 2,
+   .buffers = 1,
+   },
+   {
+   .name = "YVU 4:2:2 biplanar",
+   .fourcc   = V4L2_PIX_FMT_NV61,
+   .vdownsampling = { 1, 1 },
+   .bit_depth = { 8, 8 },
+   .is_yuv   = true,
+   .planes   = 2,
+   .buffers = 1,
+   },
+   {
+   .name = "Monochrome",
+   .fourcc   = V4L2_PIX_FMT_GREY,
+   .vdownsampling = { 1 },
+   .bit_depth = { 8 },
+   .is_yuv   = true,
+   .planes   = 1,
+   .buffers = 1,
+   },
+   {
.name = "RGB565 (LE)",
.fourcc   = V4L2_PIX_FMT_RGB565, /* gggb rggg */
.vdownsampling = { 1 },
@@ -221,10 +293,46 @@ struct vivid_fmt vivid_formats[] = {
.buffers = 2,
.data_offset = { 0, PLANE0_DATA_OFFSET },
},
+   {
+   .name = "4:2:0, triplanar, YUV",
+   .fourcc   = V4L2_PIX_FMT_YUV420M,
+   .vdownsampling = { 1, 2, 2 },
+   .bit_depth = { 8, 4, 4 },
+   .is_yuv   = true,
+   .planes   = 3,
+   .buffers = 3,
+   },
+   {
+   .name = "4:2:0, triplanar, YVU",
+   .fourcc   = V4L2_PIX_FMT_YVU420M,
+   .vdownsampling = { 1, 2, 2 },
+   .bit_depth = { 8, 4, 4 },
+   .is_yuv   = true,
+   .planes   = 3,
+   .buffers = 3,
+   },
+   {
+   .name = "4:2:0, biplanar, YUV",
+   .fourcc   = V4L2_PIX_FMT_NV12M,
+   .vdownsampling = { 1, 2 },
+   .bit_depth = { 8, 8 },
+   .is_yuv   = true,
+   .planes   = 2,
+   .buffers = 2,
+   },
+   {
+   .name = "4:2:0, biplanar, YVU",
+   .fourcc   = V4L2_PIX_FMT_NV21M,
+   .vdownsampling = { 1, 2 },
+   .bit_depth = { 8, 8 },
+   .is_yuv   = true,
+   .planes   = 2,
+   .buffers = 2,
+   },
 };
 
-/* There are 2 multiplanar formats in the list */
-#define VIVID_MPLANAR_FORMATS 2
+/* There are 6 multiplanar formats in the list */
+#defin

[PATCH 23/29] vivid-tpg: move 'extras' parameters to tpg_draw_params

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Any parameters related to drawing 'extras' like the border, the square,
etc. are moved to struct tpg_draw_params.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 100 ++-
 1 file changed, 58 insertions(+), 42 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index c477730..a738ce1 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1552,6 +1552,44 @@ static void tpg_fill_params_pattern(const struct 
tpg_data *tpg, unsigned p,
(tpg->mv_vert_count + tpg->mv_vert_step) % tpg->src_height;
 }
 
+static void tpg_fill_params_extras(const struct tpg_data *tpg,
+  unsigned p,
+  struct tpg_draw_params *params)
+{
+   unsigned left_pillar_width = 0;
+   unsigned right_pillar_start = params->img_width;
+
+   params->wss_width = tpg->crop.left < tpg->src_width / 2 ?
+   tpg->src_width / 2 - tpg->crop.left : 0;
+   if (params->wss_width > tpg->crop.width)
+   params->wss_width = tpg->crop.width;
+   params->wss_width = tpg_hscale_div(tpg, p, params->wss_width);
+   params->wss_random_offset =
+   params->twopixsize * prandom_u32_max(tpg->src_width / 2);
+
+   if (tpg->crop.left < tpg->border.left) {
+   left_pillar_width = tpg->border.left - tpg->crop.left;
+   if (left_pillar_width > tpg->crop.width)
+   left_pillar_width = tpg->crop.width;
+   left_pillar_width = tpg_hscale_div(tpg, p, left_pillar_width);
+   }
+   params->left_pillar_width = left_pillar_width;
+
+   if (tpg->crop.left + tpg->crop.width >
+   tpg->border.left + tpg->border.width) {
+   right_pillar_start =
+   tpg->border.left + tpg->border.width - tpg->crop.left;
+   right_pillar_start =
+   tpg_hscale_div(tpg, p, right_pillar_start);
+   if (right_pillar_start > params->img_width)
+   right_pillar_start = params->img_width;
+   }
+   params->right_pillar_start = right_pillar_start;
+
+   params->sav_eav_f = tpg->field ==
+   (params->is_60hz ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
+}
+
 void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf)
 {
struct tpg_draw_params params;
@@ -1559,15 +1597,11 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
unsigned mv_hor_new;
unsigned mv_vert_old;
unsigned mv_vert_new;
-   unsigned wss_width;
-   unsigned f;
int h;
unsigned twopixsize;
unsigned vdiv = tpg->vdownsampling[p];
unsigned img_width;
unsigned line_offset;
-   unsigned left_pillar_width = 0;
-   unsigned right_pillar_start;
unsigned stride;
unsigned factor = V4L2_FIELD_HAS_T_OR_B(tpg->field) ? 2 : 1;
u8 *orig_vbuf = vbuf;
@@ -1594,33 +1628,14 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
mv_vert_old = params.mv_vert_old;
mv_vert_new = params.mv_vert_new;
 
+   tpg_fill_params_extras(tpg, p, ¶ms);
+
twopixsize = params.twopixsize;
img_width = params.img_width;
stride = params.stride;
 
-   wss_width = tpg->crop.left < tpg->src_width / 2 ?
-   tpg->src_width / 2 - tpg->crop.left : 0;
-   if (wss_width > tpg->crop.width)
-   wss_width = tpg->crop.width;
-   wss_width = tpg_hscale_div(tpg, p, wss_width);
-
vbuf += tpg_hdiv(tpg, p, tpg->compose.left);
line_offset = tpg_hscale_div(tpg, p, tpg->crop.left);
-   if (tpg->crop.left < tpg->border.left) {
-   left_pillar_width = tpg->border.left - tpg->crop.left;
-   if (left_pillar_width > tpg->crop.width)
-   left_pillar_width = tpg->crop.width;
-   left_pillar_width = tpg_hscale_div(tpg, p, left_pillar_width);
-   }
-   right_pillar_start = img_width;
-   if (tpg->crop.left + tpg->crop.width > tpg->border.left + 
tpg->border.width) {
-   right_pillar_start = tpg->border.left + tpg->border.width - 
tpg->crop.left;
-   right_pillar_start = tpg_hscale_div(tpg, p, right_pillar_start);
-   if (right_pillar_start > img_width)
-   right_pillar_start = img_width;
-   }
-
-   f = tpg->field == (params.is_60hz ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
 
for (h = 0; h < tpg->compose.height; h++) {
bool even;
@@ -1809,22 +1824,21 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
buf_line /= vdiv;
}
 
-   if (params.is_tv && !params.is_

[PATCH 18/29] vivid-tpg: add helper functions to simplify common calculations

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Add helper functions to handle horizontal downscaling and horizontal
scaling.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 130 ++-
 drivers/media/platform/vivid/vivid-tpg.h |  23 ++
 2 files changed, 80 insertions(+), 73 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 766cbf5..a919363 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -183,6 +183,9 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
tpg->recalc_colors = true;
tpg->vdownsampling[0] = 1;
tpg->hdownsampling[0] = 1;
+   tpg->hmask[0] = ~0;
+   tpg->hmask[1] = ~0;
+   tpg->hmask[2] = ~0;
 
switch (fourcc) {
case V4L2_PIX_FMT_RGB565:
@@ -231,6 +234,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_NV61:
tpg->vdownsampling[1] = 1;
tpg->hdownsampling[1] = 1;
+   tpg->hmask[1] = ~1;
tpg->planes = 2;
tpg->is_yuv = true;
break;
@@ -242,6 +246,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_NV21:
tpg->vdownsampling[1] = 2;
tpg->hdownsampling[1] = 1;
+   tpg->hmask[1] = ~1;
tpg->planes = 2;
tpg->is_yuv = true;
break;
@@ -249,6 +254,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YVYU:
case V4L2_PIX_FMT_VYUY:
+   tpg->hmask[0] = ~1;
tpg->is_yuv = true;
break;
default:
@@ -1116,6 +1122,7 @@ static void tpg_calculate_square_border(struct tpg_data 
*tpg)
 static void tpg_precalculate_line(struct tpg_data *tpg)
 {
enum tpg_color contrast;
+   u8 pix[TPG_MAX_PLANES][8];
unsigned pat;
unsigned p;
unsigned x;
@@ -1142,7 +1149,6 @@ static void tpg_precalculate_line(struct tpg_data *tpg)
for (x = 0; x < tpg->scaled_width * 2; x += 2) {
unsigned real_x = src_x;
enum tpg_color color1, color2;
-   u8 pix[TPG_MAX_PLANES][8];
 
real_x = tpg->hflip ? tpg->src_width * 2 - real_x - 2 : 
real_x;
color1 = tpg_get_color(tpg, pat, real_x);
@@ -1170,8 +1176,7 @@ static void tpg_precalculate_line(struct tpg_data *tpg)
for (p = 0; p < tpg->planes; p++) {
unsigned twopixsize = tpg->twopixelsize[p];
unsigned hdiv = tpg->hdownsampling[p];
-   u8 *pos = tpg->lines[pat][p] +
-   (x / hdiv) * twopixsize / 2;
+   u8 *pos = tpg->lines[pat][p] + tpg_hdiv(tpg, p, 
x);
 
memcpy(pos, pix[p], twopixsize / hdiv);
}
@@ -1185,50 +1190,38 @@ static void tpg_precalculate_line(struct tpg_data *tpg)
unsigned next_pat = (pat + 1) % pat_lines;
 
for (p = 1; p < tpg->planes; p++) {
-   unsigned twopixsize = tpg->twopixelsize[p];
-   unsigned hdiv = tpg->hdownsampling[p];
-
-   for (x = 0; x < tpg->scaled_width * 2; x += 2) {
-   unsigned offset = (x / hdiv) * 
twopixsize / 2;
-   u8 *pos1 = tpg->lines[pat][p] + offset;
-   u8 *pos2 = tpg->lines[next_pat][p] + 
offset;
-   u8 *dest = 
tpg->downsampled_lines[pat][p] + offset;
-   unsigned i;
+   unsigned w = tpg_hdiv(tpg, p, tpg->scaled_width 
* 2);
+   u8 *pos1 = tpg->lines[pat][p];
+   u8 *pos2 = tpg->lines[next_pat][p];
+   u8 *dest = tpg->downsampled_lines[pat][p];
 
-   for (i = 0; i < twopixsize / hdiv; i++, 
dest++, pos1++, pos2++)
-   *dest = ((u16)*pos1 + 
(u16)*pos2) / 2;
-   }
+   for (x = 0; x < w; x++, pos1++, pos2++, dest++)
+   *dest = ((u16)*pos1 + (u16)*pos2) / 2;
}
}
}
 
-   for (x = 0; x < tpg->scaled_width; x += 2) {
-   u8 pix[TPG_MAX_PLANES][8];
-
-   gen_twopix(tpg, pix, contrast, 0);
-   gen_twopix(tpg, pix, contrast, 1);
-   for (p = 0; p < tpg->planes; p++) {
-   unsigned twopixsize = tpg-

[PATCH 20/29] vivid-tpg: add a new tpg_draw_params structure

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This is needed to refactor the drawing function which is much too big.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 2f78ccd..acee705 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1510,6 +1510,35 @@ static int tpg_pattern_avg(const struct tpg_data *tpg,
return -1;
 }
 
+/*
+ * This struct contains common parameters used by both the drawing of the
+ * test pattern and the drawing of the extras (borders, square, etc.)
+ */
+struct tpg_draw_params {
+   /* common data */
+   bool is_tv;
+   bool is_60hz;
+   unsigned twopixsize;
+   unsigned img_width;
+   unsigned stride;
+   unsigned hmax;
+   unsigned frame_line;
+   unsigned frame_line_next;
+
+   /* test pattern */
+   unsigned mv_hor_old;
+   unsigned mv_hor_new;
+   unsigned mv_vert_old;
+   unsigned mv_vert_new;
+
+   /* extras */
+   unsigned wss_width;
+   unsigned wss_random_offset;
+   unsigned sav_eav_f;
+   unsigned left_pillar_width;
+   unsigned right_pillar_start;
+};
+
 void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf)
 {
bool is_tv = std;
-- 
2.1.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 21/29] vivid-tpg: move common parameters to tpg_draw_params

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Replace local variables by fields in the tpg_draw_params struct.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 34 +---
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index acee705..1e5eefa 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1541,23 +1541,21 @@ struct tpg_draw_params {
 
 void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf)
 {
-   bool is_tv = std;
-   bool is_60hz = is_tv && (std & V4L2_STD_525_60);
+   struct tpg_draw_params params;
unsigned mv_hor_old = tpg->mv_hor_count % tpg->src_width;
unsigned mv_hor_new = (tpg->mv_hor_count + tpg->mv_hor_step) % 
tpg->src_width;
unsigned mv_vert_old = tpg->mv_vert_count % tpg->src_height;
unsigned mv_vert_new = (tpg->mv_vert_count + tpg->mv_vert_step) % 
tpg->src_height;
unsigned wss_width;
unsigned f;
-   int hmax = (tpg->compose.height * tpg->perc_fill) / 100;
int h;
-   unsigned twopixsize = tpg->twopixelsize[p];
+   unsigned twopixsize;
unsigned vdiv = tpg->vdownsampling[p];
-   unsigned img_width = tpg_hdiv(tpg, p, tpg->compose.width);
+   unsigned img_width;
unsigned line_offset;
unsigned left_pillar_width = 0;
-   unsigned right_pillar_start = img_width;
-   unsigned stride = tpg->bytesperline[p];
+   unsigned right_pillar_start;
+   unsigned stride;
unsigned factor = V4L2_FIELD_HAS_T_OR_B(tpg->field) ? 2 : 1;
u8 *orig_vbuf = vbuf;
 
@@ -1569,6 +1567,17 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
 
tpg_recalc(tpg);
 
+   params.is_tv = std;
+   params.is_60hz = std & V4L2_STD_525_60;
+   params.twopixsize = tpg->twopixelsize[p];
+   params.img_width = tpg_hdiv(tpg, p, tpg->compose.width);
+   params.stride = tpg->bytesperline[p];
+   params.hmax = (tpg->compose.height * tpg->perc_fill) / 100;
+
+   twopixsize = params.twopixsize;
+   img_width = params.img_width;
+   stride = params.stride;
+
mv_hor_old = tpg_hscale_div(tpg, p, mv_hor_old);
mv_hor_new = tpg_hscale_div(tpg, p, mv_hor_new);
wss_width = tpg->crop.left < tpg->src_width / 2 ?
@@ -1585,6 +1594,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
left_pillar_width = tpg->crop.width;
left_pillar_width = tpg_hscale_div(tpg, p, left_pillar_width);
}
+   right_pillar_start = img_width;
if (tpg->crop.left + tpg->crop.width > tpg->border.left + 
tpg->border.width) {
right_pillar_start = tpg->border.left + tpg->border.width - 
tpg->crop.left;
right_pillar_start = tpg_hscale_div(tpg, p, right_pillar_start);
@@ -1592,7 +1602,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
right_pillar_start = img_width;
}
 
-   f = tpg->field == (is_60hz ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
+   f = tpg->field == (params.is_60hz ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
 
for (h = 0; h < tpg->compose.height; h++) {
bool even;
@@ -1636,8 +1646,8 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
buf_line /= vdiv;
}
 
-   if (h >= hmax) {
-   if (hmax == tpg->compose.height)
+   if (h >= params.hmax) {
+   if (params.hmax == tpg->compose.height)
continue;
if (!tpg->perc_fill_blank)
continue;
@@ -1720,7 +1730,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
}
if (tpg->field_alternate) {
linestart_top = linestart_bottom = linestart_older;
-   } else if (is_60hz) {
+   } else if (params.is_60hz) {
linestart_top = linestart_newer;
linestart_bottom = linestart_older;
} else {
@@ -1781,7 +1791,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
buf_line /= vdiv;
}
 
-   if (is_tv && !is_60hz && frame_line == 0 && wss_width) {
+   if (params.is_tv && !params.is_60hz && frame_line == 0 && 
wss_width) {
/*
 * Replace the first half of the top line of a 50 Hz 
frame
 * with random data to simulate a WSS signal.
-- 
2.1.4

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

[PATCH 19/29] vivid-tpg: add const where appropriate

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Added 'const' to several functions where that is possible to do.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 8 
 drivers/media/platform/vivid/vivid-tpg.h | 8 +---
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index a919363..2f78ccd 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1241,8 +1241,8 @@ static void tpg_precalculate_line(struct tpg_data *tpg)
 /* need this to do rgb24 rendering */
 typedef struct { u16 __; u8 _; } __packed x24;
 
-void tpg_gen_text(struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2],
-   int y, int x, char *text)
+void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2],
+ int y, int x, char *text)
 {
int line;
unsigned step = V4L2_FIELD_HAS_T_OR_B(tpg->field) ? 2 : 1;
@@ -1389,7 +1389,7 @@ void tpg_update_mv_step(struct tpg_data *tpg)
 }
 
 /* Map the line number relative to the crop rectangle to a frame line number */
-static unsigned tpg_calc_frameline(struct tpg_data *tpg, unsigned src_y,
+static unsigned tpg_calc_frameline(const struct tpg_data *tpg, unsigned src_y,
unsigned field)
 {
switch (field) {
@@ -1406,7 +1406,7 @@ static unsigned tpg_calc_frameline(struct tpg_data *tpg, 
unsigned src_y,
  * Map the line number relative to the compose rectangle to a destination
  * buffer line number.
  */
-static unsigned tpg_calc_buffer_line(struct tpg_data *tpg, unsigned y,
+static unsigned tpg_calc_buffer_line(const struct tpg_data *tpg, unsigned y,
unsigned field)
 {
y += tpg->compose.top;
diff --git a/drivers/media/platform/vivid/vivid-tpg.h 
b/drivers/media/platform/vivid/vivid-tpg.h
index b62f392..82ce9bf 100644
--- a/drivers/media/platform/vivid/vivid-tpg.h
+++ b/drivers/media/platform/vivid/vivid-tpg.h
@@ -193,12 +193,14 @@ void tpg_reset_source(struct tpg_data *tpg, unsigned 
width, unsigned height,
   u32 field);
 
 void tpg_set_font(const u8 *f);
-void tpg_gen_text(struct tpg_data *tpg,
+void tpg_gen_text(const struct tpg_data *tpg,
u8 *basep[TPG_MAX_PLANES][2], int y, int x, char *text);
 void tpg_calc_text_basep(struct tpg_data *tpg,
u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf);
-void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf);
-void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 
*vbuf);
+void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std,
+  unsigned p, u8 *vbuf);
+void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std,
+   unsigned p, u8 *vbuf);
 bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc);
 void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
const struct v4l2_rect *compose);
-- 
2.1.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 17/29] vivid-tpg: add support for V4L2_PIX_FMT_GREY

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Add monochrome support to the TPG.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 19b5806..766cbf5 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -199,6 +199,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_ARGB32:
case V4L2_PIX_FMT_ABGR32:
+   case V4L2_PIX_FMT_GREY:
tpg->is_yuv = false;
break;
case V4L2_PIX_FMT_YUV420M:
@@ -279,6 +280,9 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_ABGR32:
tpg->twopixelsize[0] = 2 * 4;
break;
+   case V4L2_PIX_FMT_GREY:
+   tpg->twopixelsize[0] = 2;
+   break;
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV12M:
@@ -598,7 +602,7 @@ static void precalculate_color(struct tpg_data *tpg, int k)
g <<= 4;
b <<= 4;
}
-   if (tpg->qual == TPG_QUAL_GRAY) {
+   if (tpg->qual == TPG_QUAL_GRAY || tpg->fourcc == V4L2_PIX_FMT_GREY) {
/* Rec. 709 Luma function */
/* (0.2126, 0.7152, 0.0722) * (255 * 256) */
r = g = b = (13879 * r + 46688 * g + 4713 * b) >> 16;
@@ -739,6 +743,9 @@ static void gen_twopix(struct tpg_data *tpg,
b_v = tpg->colors[color][2]; /* B or precalculated V */
 
switch (tpg->fourcc) {
+   case V4L2_PIX_FMT_GREY:
+   buf[0][offset] = r_y;
+   break;
case V4L2_PIX_FMT_YUV422P:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YUV420M:
-- 
2.1.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 16/29] vivid-tpg: add support for more planar formats

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Now that the support for hor/vert downsampled planar formats is in
place we can add support for such formats to the TPG.

This patch adds support for:

V4L2_PIX_FMT_YUV420M
V4L2_PIX_FMT_YVU420M
V4L2_PIX_FMT_YUV420
V4L2_PIX_FMT_YVU420
V4L2_PIX_FMT_YUV422P
V4L2_PIX_FMT_NV16
V4L2_PIX_FMT_NV61
V4L2_PIX_FMT_NV12
V4L2_PIX_FMT_NV21
V4L2_PIX_FMT_NV12P
V4L2_PIX_FMT_NV21P

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 90 +++-
 1 file changed, 89 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 7d8e87e..19b5806 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -201,13 +201,49 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_ABGR32:
tpg->is_yuv = false;
break;
+   case V4L2_PIX_FMT_YUV420M:
+   case V4L2_PIX_FMT_YVU420M:
+   tpg->buffers = 3;
+   /* fall through */
+   case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_YVU420:
+   tpg->vdownsampling[1] = 2;
+   tpg->vdownsampling[2] = 2;
+   tpg->hdownsampling[1] = 2;
+   tpg->hdownsampling[2] = 2;
+   tpg->planes = 3;
+   tpg->is_yuv = true;
+   break;
+   case V4L2_PIX_FMT_YUV422P:
+   tpg->vdownsampling[1] = 1;
+   tpg->vdownsampling[2] = 1;
+   tpg->hdownsampling[1] = 2;
+   tpg->hdownsampling[2] = 2;
+   tpg->planes = 3;
+   tpg->is_yuv = true;
+   break;
case V4L2_PIX_FMT_NV16M:
case V4L2_PIX_FMT_NV61M:
+   tpg->buffers = 2;
+   /* fall through */
+   case V4L2_PIX_FMT_NV16:
+   case V4L2_PIX_FMT_NV61:
tpg->vdownsampling[1] = 1;
tpg->hdownsampling[1] = 1;
+   tpg->planes = 2;
+   tpg->is_yuv = true;
+   break;
+   case V4L2_PIX_FMT_NV12M:
+   case V4L2_PIX_FMT_NV21M:
tpg->buffers = 2;
+   /* fall through */
+   case V4L2_PIX_FMT_NV12:
+   case V4L2_PIX_FMT_NV21:
+   tpg->vdownsampling[1] = 2;
+   tpg->hdownsampling[1] = 1;
tpg->planes = 2;
-   /* fall-through */
+   tpg->is_yuv = true;
+   break;
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YVYU:
@@ -243,11 +279,29 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_ABGR32:
tpg->twopixelsize[0] = 2 * 4;
break;
+   case V4L2_PIX_FMT_NV12:
+   case V4L2_PIX_FMT_NV21:
+   case V4L2_PIX_FMT_NV12M:
+   case V4L2_PIX_FMT_NV21M:
+   tpg->twopixelsize[0] = 2;
+   tpg->twopixelsize[1] = 2;
+   break;
+   case V4L2_PIX_FMT_NV16:
+   case V4L2_PIX_FMT_NV61:
case V4L2_PIX_FMT_NV16M:
case V4L2_PIX_FMT_NV61M:
tpg->twopixelsize[0] = 2;
tpg->twopixelsize[1] = 2;
break;
+   case V4L2_PIX_FMT_YUV422P:
+   case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_YVU420:
+   case V4L2_PIX_FMT_YUV420M:
+   case V4L2_PIX_FMT_YVU420M:
+   tpg->twopixelsize[0] = 2;
+   tpg->twopixelsize[1] = 2;
+   tpg->twopixelsize[2] = 2;
+   break;
}
return true;
 }
@@ -685,6 +739,37 @@ static void gen_twopix(struct tpg_data *tpg,
b_v = tpg->colors[color][2]; /* B or precalculated V */
 
switch (tpg->fourcc) {
+   case V4L2_PIX_FMT_YUV422P:
+   case V4L2_PIX_FMT_YUV420:
+   case V4L2_PIX_FMT_YUV420M:
+   buf[0][offset] = r_y;
+   if (odd) {
+   buf[1][0] = (buf[1][0] + g_u) / 2;
+   buf[2][0] = (buf[2][0] + b_v) / 2;
+   buf[1][1] = buf[1][0];
+   buf[2][1] = buf[2][0];
+   break;
+   }
+   buf[1][0] = g_u;
+   buf[2][0] = b_v;
+   break;
+   case V4L2_PIX_FMT_YVU420:
+   case V4L2_PIX_FMT_YVU420M:
+   buf[0][offset] = r_y;
+   if (odd) {
+   buf[1][0] = (buf[1][0] + b_v) / 2;
+   buf[2][0] = (buf[2][0] + g_u) / 2;
+   buf[1][1] = buf[1][0];
+   buf[2][1] = buf[2][0];
+   break;
+   }
+   buf[1][0] = b_v;
+   buf[2][0] = g_u;
+   break;
+
+   case V4L2_PIX_FMT_NV12:
+   case V4L2_PIX_FMT_NV12M:
+   case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV16M:
buf[0][offset] = r_y;
if (odd) {
@@ -695,6 +780,9 @@ static void ge

[PATCH 13/29] vivid-tpg: correctly average the two pixels in gen_twopix()

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

gen_twopix() is always called twice: once for the first and once for
the second pixel. Improve the code to properly average the two if the
format requires horizontal downsampling.

This is necessary for patterns like 1x1 red/blue checkers.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 48 
 1 file changed, 42 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index d7531d3..9001b9a 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -687,28 +687,64 @@ static void gen_twopix(struct tpg_data *tpg,
switch (tpg->fourcc) {
case V4L2_PIX_FMT_NV16M:
buf[0][offset] = r_y;
-   buf[1][offset] = odd ? b_v : g_u;
+   if (odd) {
+   buf[1][0] = (buf[1][0] + g_u) / 2;
+   buf[1][1] = (buf[1][1] + b_v) / 2;
+   break;
+   }
+   buf[1][0] = g_u;
+   buf[1][1] = b_v;
break;
case V4L2_PIX_FMT_NV61M:
buf[0][offset] = r_y;
-   buf[1][offset] = odd ? g_u : b_v;
+   if (odd) {
+   buf[1][0] = (buf[1][0] + b_v) / 2;
+   buf[1][1] = (buf[1][1] + g_u) / 2;
+   break;
+   }
+   buf[1][0] = b_v;
+   buf[1][1] = g_u;
break;
 
case V4L2_PIX_FMT_YUYV:
buf[0][offset] = r_y;
-   buf[0][offset + 1] = odd ? b_v : g_u;
+   if (odd) {
+   buf[0][1] = (buf[0][1] + g_u) / 2;
+   buf[0][3] = (buf[0][3] + b_v) / 2;
+   break;
+   }
+   buf[0][1] = g_u;
+   buf[0][3] = b_v;
break;
case V4L2_PIX_FMT_UYVY:
-   buf[0][offset] = odd ? b_v : g_u;
buf[0][offset + 1] = r_y;
+   if (odd) {
+   buf[0][0] = (buf[0][0] + g_u) / 2;
+   buf[0][2] = (buf[0][2] + b_v) / 2;
+   break;
+   }
+   buf[0][0] = g_u;
+   buf[0][2] = b_v;
break;
case V4L2_PIX_FMT_YVYU:
buf[0][offset] = r_y;
-   buf[0][offset + 1] = odd ? g_u : b_v;
+   if (odd) {
+   buf[0][1] = (buf[0][1] + b_v) / 2;
+   buf[0][3] = (buf[0][3] + g_u) / 2;
+   break;
+   }
+   buf[0][1] = b_v;
+   buf[0][3] = g_u;
break;
case V4L2_PIX_FMT_VYUY:
-   buf[0][offset] = odd ? g_u : b_v;
buf[0][offset + 1] = r_y;
+   if (odd) {
+   buf[0][0] = (buf[0][0] + b_v) / 2;
+   buf[0][2] = (buf[0][2] + g_u) / 2;
+   break;
+   }
+   buf[0][0] = b_v;
+   buf[0][2] = g_u;
break;
case V4L2_PIX_FMT_RGB565:
buf[0][offset] = (g_u << 5) | b_v;
-- 
2.1.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 12/29] vivid-tpg: precalculate downsampled lines

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

When dealing with vertical downsampling two successive lines have to be
averaged. In the case of the test pattern generator that only happens
if the two lines are using different patterns. So precalculate the average
between two pattern lines: one of pattern P and one of pattern P + 1.

That way there is no need to do any on-the-fly downsampling: it's all done
in the precalculate phase.

This patch also implements horizontal downsampling in the precalculate phase.
The only thing that needs to be done is to half the width since the actual
downsampling happens when two pixels at a time are generated.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 40 ++--
 drivers/media/platform/vivid/vivid-tpg.h |  1 +
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 9f47387..d7531d3 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -128,6 +128,11 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
tpg->lines[pat][plane] = vzalloc(max_w * 2 * pixelsz);
if (!tpg->lines[pat][plane])
return -ENOMEM;
+   if (plane == 0)
+   continue;
+   tpg->downsampled_lines[pat][plane] = vzalloc(max_w * 2 
* pixelsz);
+   if (!tpg->downsampled_lines[pat][plane])
+   return -ENOMEM;
}
}
for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
@@ -155,6 +160,10 @@ void tpg_free(struct tpg_data *tpg)
for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
vfree(tpg->lines[pat][plane]);
tpg->lines[pat][plane] = NULL;
+   if (plane == 0)
+   continue;
+   vfree(tpg->downsampled_lines[pat][plane]);
+   tpg->downsampled_lines[pat][plane] = NULL;
}
for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
vfree(tpg->contrast_line[plane]);
@@ -1029,12 +1038,39 @@ static void tpg_precalculate_line(struct tpg_data *tpg)
gen_twopix(tpg, pix, tpg->hflip ? color1 : color2, 1);
for (p = 0; p < tpg->planes; p++) {
unsigned twopixsize = tpg->twopixelsize[p];
-   u8 *pos = tpg->lines[pat][p] + x * twopixsize / 
2;
+   unsigned hdiv = tpg->hdownsampling[p];
+   u8 *pos = tpg->lines[pat][p] +
+   (x / hdiv) * twopixsize / 2;
+
+   memcpy(pos, pix[p], twopixsize / hdiv);
+   }
+   }
+   }
+
+   if (tpg->vdownsampling[tpg->planes - 1] > 1) {
+   unsigned pat_lines = tpg_get_pat_lines(tpg);
+
+   for (pat = 0; pat < pat_lines; pat++) {
+   unsigned next_pat = (pat + 1) % pat_lines;
+
+   for (p = 1; p < tpg->planes; p++) {
+   unsigned twopixsize = tpg->twopixelsize[p];
+   unsigned hdiv = tpg->hdownsampling[p];
 
-   memcpy(pos, pix[p], twopixsize);
+   for (x = 0; x < tpg->scaled_width * 2; x += 2) {
+   unsigned offset = (x / hdiv) * 
twopixsize / 2;
+   u8 *pos1 = tpg->lines[pat][p] + offset;
+   u8 *pos2 = tpg->lines[next_pat][p] + 
offset;
+   u8 *dest = 
tpg->downsampled_lines[pat][p] + offset;
+   unsigned i;
+
+   for (i = 0; i < twopixsize / hdiv; i++, 
dest++, pos1++, pos2++)
+   *dest = ((u16)*pos1 + 
(u16)*pos2) / 2;
+   }
}
}
}
+
for (x = 0; x < tpg->scaled_width; x += 2) {
u8 pix[TPG_MAX_PLANES][8];
 
diff --git a/drivers/media/platform/vivid/vivid-tpg.h 
b/drivers/media/platform/vivid/vivid-tpg.h
index cec5bb4..5a53eb9 100644
--- a/drivers/media/platform/vivid/vivid-tpg.h
+++ b/drivers/media/platform/vivid/vivid-tpg.h
@@ -175,6 +175,7 @@ struct tpg_data {
/* Used to store TPG_MAX_PAT_LINES lines, each with up to two planes */
unsignedmax_line_width;
u8  
*lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES];
+   u8  
*downsampled_lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES];
u8  *random_line[TP

[PATCH 10/29] vivid-tpg: add helper functions for single buffer planar formats

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Add helpers functions to determine the line widths and image sizes
for planar formats that are stores in a single buffer.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 18 ++-
 drivers/media/platform/vivid/vivid-tpg.h | 53 +++-
 2 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 7463f78..767879e0 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1317,7 +1317,7 @@ void tpg_calc_text_basep(struct tpg_data *tpg,
basep[p][0] += tpg->buf_height * stride / 2;
 }
 
-void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 
*vbuf)
+void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf)
 {
bool is_tv = std;
bool is_60hz = is_tv && (std & V4L2_STD_525_60);
@@ -1577,3 +1577,19 @@ void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id 
std, unsigned p, u8 *vbuf)
}
}
 }
+
+void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 
*vbuf)
+{
+   unsigned offset = 0;
+   unsigned i;
+
+   if (tpg->buffers > 1) {
+   tpg_fill_plane_buffer(tpg, std, p, vbuf);
+   return;
+   }
+
+   for (i = 0; i < tpg->planes; i++) {
+   tpg_fill_plane_buffer(tpg, std, i, vbuf + offset);
+   offset += tpg_calc_plane_size(tpg, i);
+   }
+}
diff --git a/drivers/media/platform/vivid/vivid-tpg.h 
b/drivers/media/platform/vivid/vivid-tpg.h
index 9ce2d01..b90ce7d 100644
--- a/drivers/media/platform/vivid/vivid-tpg.h
+++ b/drivers/media/platform/vivid/vivid-tpg.h
@@ -189,6 +189,7 @@ void tpg_gen_text(struct tpg_data *tpg,
u8 *basep[TPG_MAX_PLANES][2], int y, int x, char *text);
 void tpg_calc_text_basep(struct tpg_data *tpg,
u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf);
+void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf);
 void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 
*vbuf);
 bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc);
 void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
@@ -350,7 +351,57 @@ static inline unsigned tpg_g_bytesperline(const struct 
tpg_data *tpg, unsigned p
 
 static inline void tpg_s_bytesperline(struct tpg_data *tpg, unsigned plane, 
unsigned bpl)
 {
-   tpg->bytesperline[plane] = bpl;
+   unsigned p;
+
+   if (tpg->buffers > 1) {
+   tpg->bytesperline[plane] = bpl;
+   return;
+   }
+
+   for (p = 0; p < tpg->planes; p++) {
+   unsigned plane_w = bpl * tpg->twopixelsize[p] / 
tpg->twopixelsize[0];
+
+   tpg->bytesperline[p] = plane_w;
+   }
+}
+
+static inline unsigned tpg_g_line_width(const struct tpg_data *tpg, unsigned 
plane)
+{
+   unsigned w = 0;
+   unsigned p;
+
+   if (tpg->buffers > 1)
+   return tpg_g_bytesperline(tpg, plane);
+   for (p = 0; p < tpg->planes; p++) {
+   unsigned plane_w = tpg_g_bytesperline(tpg, p);
+
+   w += plane_w;
+   }
+   return w;
+}
+
+static inline unsigned tpg_calc_line_width(const struct tpg_data *tpg,
+  unsigned plane, unsigned bpl)
+{
+   unsigned w = 0;
+   unsigned p;
+
+   if (tpg->buffers > 1)
+   return bpl;
+   for (p = 0; p < tpg->planes; p++) {
+   unsigned plane_w = bpl * tpg->twopixelsize[p] / 
tpg->twopixelsize[0];
+
+   w += plane_w;
+   }
+   return w;
+}
+
+static inline unsigned tpg_calc_plane_size(const struct tpg_data *tpg, 
unsigned plane)
+{
+   if (plane >= tpg->planes)
+   return 0;
+
+   return tpg_g_bytesperline(tpg, plane) * tpg->buf_height;
 }
 
 static inline void tpg_s_buf_height(struct tpg_data *tpg, unsigned h)
-- 
2.1.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 11/29] vivid-tpg: add hor/vert downsampling fields

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This is step one of supporting horizontal and vertical downsampling.
This just adds support for the h/vdownsampling fields and it increases
the maximum number of planes to 3.

Currently none of the planar formats need horizontal or vertical
downsampling, so this change has no effect at the moment.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c |  7 ++-
 drivers/media/platform/vivid/vivid-tpg.h | 15 ++-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 767879e0..9f47387 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -172,6 +172,8 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
tpg->planes = 1;
tpg->buffers = 1;
tpg->recalc_colors = true;
+   tpg->vdownsampling[0] = 1;
+   tpg->hdownsampling[0] = 1;
 
switch (fourcc) {
case V4L2_PIX_FMT_RGB565:
@@ -192,6 +194,8 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
break;
case V4L2_PIX_FMT_NV16M:
case V4L2_PIX_FMT_NV61M:
+   tpg->vdownsampling[1] = 1;
+   tpg->hdownsampling[1] = 1;
tpg->buffers = 2;
tpg->planes = 2;
/* fall-through */
@@ -273,7 +277,8 @@ void tpg_reset_source(struct tpg_data *tpg, unsigned width, 
unsigned height,
tpg->compose.width = width;
tpg->compose.height = tpg->buf_height;
for (p = 0; p < tpg->planes; p++)
-   tpg->bytesperline[p] = width * tpg->twopixelsize[p] / 2;
+   tpg->bytesperline[p] = (width * tpg->twopixelsize[p]) /
+  (2 * tpg->hdownsampling[p]);
tpg->recalc_square_border = true;
 }
 
diff --git a/drivers/media/platform/vivid/vivid-tpg.h 
b/drivers/media/platform/vivid/vivid-tpg.h
index b90ce7d..cec5bb4 100644
--- a/drivers/media/platform/vivid/vivid-tpg.h
+++ b/drivers/media/platform/vivid/vivid-tpg.h
@@ -90,7 +90,7 @@ enum tpg_move_mode {
 
 extern const char * const tpg_aspect_strings[];
 
-#define TPG_MAX_PLANES 2
+#define TPG_MAX_PLANES 3
 #define TPG_MAX_PAT_LINES 8
 
 struct tpg_data {
@@ -140,6 +140,8 @@ struct tpg_data {
unsignedreal_rgb_range;
unsignedbuffers;
unsignedplanes;
+   u8  vdownsampling[TPG_MAX_PLANES];
+   u8  hdownsampling[TPG_MAX_PLANES];
/* Used to store the colors in native format, either RGB or YUV */
u8  colors[TPG_COLOR_MAX][3];
u8  textfg[TPG_MAX_PLANES][8], 
textbg[TPG_MAX_PLANES][8];
@@ -361,10 +363,11 @@ static inline void tpg_s_bytesperline(struct tpg_data 
*tpg, unsigned plane, unsi
for (p = 0; p < tpg->planes; p++) {
unsigned plane_w = bpl * tpg->twopixelsize[p] / 
tpg->twopixelsize[0];
 
-   tpg->bytesperline[p] = plane_w;
+   tpg->bytesperline[p] = plane_w / tpg->hdownsampling[p];
}
 }
 
+
 static inline unsigned tpg_g_line_width(const struct tpg_data *tpg, unsigned 
plane)
 {
unsigned w = 0;
@@ -375,7 +378,7 @@ static inline unsigned tpg_g_line_width(const struct 
tpg_data *tpg, unsigned pla
for (p = 0; p < tpg->planes; p++) {
unsigned plane_w = tpg_g_bytesperline(tpg, p);
 
-   w += plane_w;
+   w += plane_w / tpg->vdownsampling[p];
}
return w;
 }
@@ -391,7 +394,8 @@ static inline unsigned tpg_calc_line_width(const struct 
tpg_data *tpg,
for (p = 0; p < tpg->planes; p++) {
unsigned plane_w = bpl * tpg->twopixelsize[p] / 
tpg->twopixelsize[0];
 
-   w += plane_w;
+   plane_w /= tpg->hdownsampling[p];
+   w += plane_w / tpg->vdownsampling[p];
}
return w;
 }
@@ -401,7 +405,8 @@ static inline unsigned tpg_calc_plane_size(const struct 
tpg_data *tpg, unsigned
if (plane >= tpg->planes)
return 0;
 
-   return tpg_g_bytesperline(tpg, plane) * tpg->buf_height;
+   return tpg_g_bytesperline(tpg, plane) * tpg->buf_height /
+  tpg->vdownsampling[plane];
 }
 
 static inline void tpg_s_buf_height(struct tpg_data *tpg, unsigned h)
-- 
2.1.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 14/29] vivid-tpg: add hor/vert downsampling support to tpg_gen_text

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This will just skip lines/pixels since color fidelity is not quite
as important here as it is with the test patterns themselves.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 9001b9a..f03289f 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1183,24 +1183,37 @@ void tpg_gen_text(struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
div = 2;
 
for (p = 0; p < tpg->planes; p++) {
-   /* Print stream time */
+   unsigned vdiv = tpg->vdownsampling[p];
+   unsigned hdiv = tpg->hdownsampling[p];
+
+   /* Print text */
 #define PRINTSTR(PIXTYPE) do { \
PIXTYPE fg; \
PIXTYPE bg; \
memcpy(&fg, tpg->textfg[p], sizeof(PIXTYPE));   \
memcpy(&bg, tpg->textbg[p], sizeof(PIXTYPE));   \
\
-   for (line = first; line < 16; line += step) {   \
+   for (line = first; line < 16; line += vdiv * step) {\
int l = tpg->vflip ? 15 - line : line; \
-   PIXTYPE *pos = (PIXTYPE *)(basep[p][line & 1] + \
-  ((y * step + l) / div) * tpg->bytesperline[p] + \
-  x * sizeof(PIXTYPE));\
+   PIXTYPE *pos = (PIXTYPE *)(basep[p][(line / vdiv) & 1] + \
+  ((y * step + l) / (vdiv * div)) * 
tpg->bytesperline[p] + \
+  (x / hdiv) * sizeof(PIXTYPE));   \
unsigned s; \
\
for (s = 0; s < len; s++) { \
u8 chr = font8x16[text[s] * 16 + line]; \
\
-   if (tpg->hflip) { \
+   if (hdiv == 2 && tpg->hflip) { \
+   pos[3] = (chr & (0x01 << 6) ? fg : bg); \
+   pos[2] = (chr & (0x01 << 4) ? fg : bg); \
+   pos[1] = (chr & (0x01 << 2) ? fg : bg); \
+   pos[0] = (chr & (0x01 << 0) ? fg : bg); \
+   } else if (hdiv == 2) { \
+   pos[0] = (chr & (0x01 << 7) ? fg : bg); \
+   pos[1] = (chr & (0x01 << 5) ? fg : bg); \
+   pos[2] = (chr & (0x01 << 3) ? fg : bg); \
+   pos[3] = (chr & (0x01 << 1) ? fg : bg); \
+   } else if (tpg->hflip) { \
pos[7] = (chr & (0x01 << 7) ? fg : bg); \
pos[6] = (chr & (0x01 << 6) ? fg : bg); \
pos[5] = (chr & (0x01 << 5) ? fg : bg); \
@@ -1220,7 +1233,7 @@ void tpg_gen_text(struct tpg_data *tpg, u8 
*basep[TPG_MAX_PLANES][2],
pos[7] = (chr & (0x01 << 0) ? fg : bg); \
} \
\
-   pos += tpg->hflip ? -8 : 8; \
+   pos += (tpg->hflip ? -8 : 8) / hdiv;\
}   \
}   \
 } while (0)
-- 
2.1.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 09/29] vivid-tpg: separate planes and buffers

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Add a new field that contains the number of buffers. This may be
less than the number of planes in case multiple planes are combined
into one buffer.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 3 +++
 drivers/media/platform/vivid/vivid-tpg.h | 6 ++
 2 files changed, 9 insertions(+)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index c1476a2..7463f78 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -170,7 +170,9 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
 {
tpg->fourcc = fourcc;
tpg->planes = 1;
+   tpg->buffers = 1;
tpg->recalc_colors = true;
+
switch (fourcc) {
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_RGB565X:
@@ -190,6 +192,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
break;
case V4L2_PIX_FMT_NV16M:
case V4L2_PIX_FMT_NV61M:
+   tpg->buffers = 2;
tpg->planes = 2;
/* fall-through */
case V4L2_PIX_FMT_YUYV:
diff --git a/drivers/media/platform/vivid/vivid-tpg.h 
b/drivers/media/platform/vivid/vivid-tpg.h
index e796a54..9ce2d01 100644
--- a/drivers/media/platform/vivid/vivid-tpg.h
+++ b/drivers/media/platform/vivid/vivid-tpg.h
@@ -138,6 +138,7 @@ struct tpg_data {
enum tpg_pixel_aspect   pix_aspect;
unsignedrgb_range;
unsignedreal_rgb_range;
+   unsignedbuffers;
unsignedplanes;
/* Used to store the colors in native format, either RGB or YUV */
u8  colors[TPG_COLOR_MAX][3];
@@ -327,6 +328,11 @@ static inline u32 tpg_g_quantization(const struct tpg_data 
*tpg)
return tpg->quantization;
 }
 
+static inline unsigned tpg_g_buffers(const struct tpg_data *tpg)
+{
+   return tpg->buffers;
+}
+
 static inline unsigned tpg_g_planes(const struct tpg_data *tpg)
 {
return tpg->planes;
-- 
2.1.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 05/29] vivid: fix test pattern movement for V4L2_FIELD_ALTERNATE

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The successive TOP/BOTTOM fields did not move as they should: only
every other field actually changed position.

The cause was that the tpg needs to know if it is dealing with a
FIELD_ALTERNATE case since that requires slightly different handling.

So tell the TPG whether or not the field setting is for the ALTERNATE
case or not.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-kthread-cap.c | 3 ++-
 drivers/media/platform/vivid/vivid-tpg.c | 4 +++-
 drivers/media/platform/vivid/vivid-tpg.h | 4 +++-
 drivers/media/platform/vivid/vivid-vid-cap.c | 5 -
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c 
b/drivers/media/platform/vivid/vivid-kthread-cap.c
index 9898072..9976d45 100644
--- a/drivers/media/platform/vivid/vivid-kthread-cap.c
+++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
@@ -436,7 +436,8 @@ static void vivid_fillbuff(struct vivid_dev *dev, struct 
vivid_buffer *buf)
} else {
buf->vb.v4l2_buf.field = dev->field_cap;
}
-   tpg_s_field(&dev->tpg, buf->vb.v4l2_buf.field);
+   tpg_s_field(&dev->tpg, buf->vb.v4l2_buf.field,
+   dev->field_cap == V4L2_FIELD_ALTERNATE);
tpg_s_perc_fill_blank(&dev->tpg, 
dev->must_blank[buf->vb.v4l2_buf.index]);
 
vivid_precalc_copy_rects(dev);
diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 34493f4..8fa2150 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1409,7 +1409,9 @@ void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id 
std, unsigned p, u8 *vbuf)
linestart_older += line_offset;
linestart_newer += line_offset;
}
-   if (is_60hz) {
+   if (tpg->field_alternate) {
+   linestart_top = linestart_bottom = linestart_older;
+   } else if (is_60hz) {
linestart_top = linestart_newer;
linestart_bottom = linestart_older;
} else {
diff --git a/drivers/media/platform/vivid/vivid-tpg.h 
b/drivers/media/platform/vivid/vivid-tpg.h
index bd8b1c7..8100425 100644
--- a/drivers/media/platform/vivid/vivid-tpg.h
+++ b/drivers/media/platform/vivid/vivid-tpg.h
@@ -98,6 +98,7 @@ struct tpg_data {
/* Scaled output frame size */
unsignedscaled_width;
u32 field;
+   boolfield_alternate;
/* crop coordinates are frame-based */
struct v4l2_rectcrop;
/* compose coordinates are format-based */
@@ -348,9 +349,10 @@ static inline void tpg_s_buf_height(struct tpg_data *tpg, 
unsigned h)
tpg->buf_height = h;
 }
 
-static inline void tpg_s_field(struct tpg_data *tpg, unsigned field)
+static inline void tpg_s_field(struct tpg_data *tpg, unsigned field, bool 
alternate)
 {
tpg->field = field;
+   tpg->field_alternate = alternate;
 }
 
 static inline void tpg_s_perc_fill(struct tpg_data *tpg,
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c 
b/drivers/media/platform/vivid/vivid-vid-cap.c
index 49f79a0..d41ac44 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -733,7 +733,10 @@ int vivid_s_fmt_vid_cap(struct file *file, void *priv,
if (tpg_g_planes(&dev->tpg) > 1)
tpg_s_bytesperline(&dev->tpg, 1, mp->plane_fmt[1].bytesperline);
dev->field_cap = mp->field;
-   tpg_s_field(&dev->tpg, dev->field_cap);
+   if (dev->field_cap == V4L2_FIELD_ALTERNATE)
+   tpg_s_field(&dev->tpg, V4L2_FIELD_TOP, true);
+   else
+   tpg_s_field(&dev->tpg, dev->field_cap, false);
tpg_s_crop_compose(&dev->tpg, &dev->crop_cap, &dev->compose_cap);
tpg_s_fourcc(&dev->tpg, dev->fmt_cap->fourcc);
if (vivid_is_sdtv_cap(dev))
-- 
2.1.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 15/29] vivid-tpg: finish hor/vert downsampling support

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Implement horizontal and vertical downsampling when filling in the
plane. The TPG is now ready to support such formats.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 128 ++-
 1 file changed, 110 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index f03289f..7d8e87e 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -1396,15 +1396,29 @@ void tpg_calc_text_basep(struct tpg_data *tpg,
u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf)
 {
unsigned stride = tpg->bytesperline[p];
+   unsigned h = tpg->buf_height;
 
tpg_recalc(tpg);
 
basep[p][0] = vbuf;
basep[p][1] = vbuf;
+   h /= tpg->vdownsampling[p];
if (tpg->field == V4L2_FIELD_SEQ_TB)
-   basep[p][1] += tpg->buf_height * stride / 2;
+   basep[p][1] += h * stride / 2;
else if (tpg->field == V4L2_FIELD_SEQ_BT)
-   basep[p][0] += tpg->buf_height * stride / 2;
+   basep[p][0] += h * stride / 2;
+}
+
+static int tpg_pattern_avg(const struct tpg_data *tpg,
+  unsigned pat1, unsigned pat2)
+{
+   unsigned pat_lines = tpg_get_pat_lines(tpg);
+
+   if (pat1 == (pat2 + 1) % pat_lines)
+   return pat2;
+   if (pat2 == (pat1 + 1) % pat_lines)
+   return pat1;
+   return -1;
 }
 
 void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, 
u8 *vbuf)
@@ -1420,7 +1434,9 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
int hmax = (tpg->compose.height * tpg->perc_fill) / 100;
int h;
unsigned twopixsize = tpg->twopixelsize[p];
-   unsigned img_width = tpg->compose.width * twopixsize / 2;
+   unsigned hdiv = tpg->hdownsampling[p];
+   unsigned vdiv = tpg->vdownsampling[p];
+   unsigned img_width = (tpg->compose.width / hdiv) * twopixsize / 2;
unsigned line_offset;
unsigned left_pillar_width = 0;
unsigned right_pillar_start = img_width;
@@ -1446,18 +1462,18 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
 
vbuf += tpg->compose.left * twopixsize / 2;
line_offset = tpg->crop.left * tpg->scaled_width / tpg->src_width;
-   line_offset = (line_offset & ~1) * twopixsize / 2;
+   line_offset = ((line_offset & ~1) / hdiv) * twopixsize / 2;
if (tpg->crop.left < tpg->border.left) {
left_pillar_width = tpg->border.left - tpg->crop.left;
if (left_pillar_width > tpg->crop.width)
left_pillar_width = tpg->crop.width;
left_pillar_width = (left_pillar_width * tpg->scaled_width) / 
tpg->src_width;
-   left_pillar_width = (left_pillar_width & ~1) * twopixsize / 2;
+   left_pillar_width = ((left_pillar_width & ~1) / hdiv) * 
twopixsize / 2;
}
if (tpg->crop.left + tpg->crop.width > tpg->border.left + 
tpg->border.width) {
right_pillar_start = tpg->border.left + tpg->border.width - 
tpg->crop.left;
right_pillar_start = (right_pillar_start * tpg->scaled_width) / 
tpg->src_width;
-   right_pillar_start = (right_pillar_start & ~1) * twopixsize / 2;
+   right_pillar_start = ((right_pillar_start & ~1) / hdiv) * 
twopixsize / 2;
if (right_pillar_start > img_width)
right_pillar_start = img_width;
}
@@ -1486,6 +1502,26 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
src_y++;
}
 
+   if (vdiv > 1) {
+   /*
+* When doing vertical downsampling the field setting
+* matters: for SEQ_BT/TB we downsample each field
+* separately (i.e. lines 0+2 are combined, as are
+* lines 1+3), for the other field settings we combine
+* odd and even lines. Doing that for SEQ_BT/TB would
+* be really weird.
+*/
+   if (tpg->field == V4L2_FIELD_SEQ_BT ||
+   tpg->field == V4L2_FIELD_SEQ_TB) {
+   if ((h & 3) >= 2)
+   continue;
+   } else if (h & 1) {
+   continue;
+   }
+
+   buf_line /= vdiv;
+   }
+
if (h >= hmax) {
if (hmax == tpg->compose.height)
continue;
@@ -1511,14 +1547,63 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, 
v4l2_std_id std, unsigned p, u8
line

[PATCH 08/29] vivid: do not allow video loopback for SEQ_TB/BT

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Sequential top-bottom/bottom-top fields are not supported as video loopback.
This is too much work to implement for field settings that are rarely used.

Signed-off-by: Hans Verkuil 
---
 Documentation/video4linux/vivid.txt | 5 +
 drivers/media/platform/vivid/vivid-vid-common.c | 7 +++
 2 files changed, 12 insertions(+)

diff --git a/Documentation/video4linux/vivid.txt 
b/Documentation/video4linux/vivid.txt
index 6cfc854..cd4b5a1 100644
--- a/Documentation/video4linux/vivid.txt
+++ b/Documentation/video4linux/vivid.txt
@@ -912,6 +912,11 @@ looped to the video input provided that:
   sequence and field counting in struct v4l2_buffer on the capture side may not
   be 100% accurate.
 
+- field settings V4L2_FIELD_SEQ_TB/BT are not supported. While it is possible 
to
+  implement this, it would mean a lot of work to get this right. Since these
+  field values are rarely used the decision was made not to implement this for
+  now.
+
 - on the input side the "Standard Signal Mode" for the S-Video input or the
   "DV Timings Signal Mode" for the HDMI input should be configured so that a
   valid signal is passed to the video input.
diff --git a/drivers/media/platform/vivid/vivid-vid-common.c 
b/drivers/media/platform/vivid/vivid-vid-common.c
index 6bef1e6..49c9bc6 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -210,6 +210,13 @@ bool vivid_vid_can_loop(struct vivid_dev *dev)
return false;
if (dev->field_cap != dev->field_out)
return false;
+   /*
+* While this can be supported, it is just too much work
+* to actually implement.
+*/
+   if (dev->field_cap == V4L2_FIELD_SEQ_TB ||
+   dev->field_cap == V4L2_FIELD_SEQ_BT)
+   return false;
if (vivid_is_svid_cap(dev) && vivid_is_svid_out(dev)) {
if (!(dev->std_cap & V4L2_STD_525_60) !=
!(dev->std_out & V4L2_STD_525_60))
-- 
2.1.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 06/29] vivid: add new checkboard patterns

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Add a 2x2 checker patterns and 1x1 and 2x2 red/blue checker patterns.

Useful for testing 4:2:2 and 4:2:0 formats.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 26 +++---
 drivers/media/platform/vivid/vivid-tpg.h |  3 +++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index 8fa2150..e2af384 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -35,7 +35,10 @@ const char * const tpg_pattern_strings[] = {
"100% Green",
"100% Blue",
"16x16 Checkers",
+   "2x2 Checkers",
"1x1 Checkers",
+   "2x2 Red/Green Checkers",
+   "1x1 Red/Green Checkers",
"Alternating Hor Lines",
"Alternating Vert Lines",
"One Pixel Wide Cross",
@@ -744,11 +747,14 @@ static void gen_twopix(struct tpg_data *tpg,
 }
 
 /* Return how many pattern lines are used by the current pattern. */
-static unsigned tpg_get_pat_lines(struct tpg_data *tpg)
+static unsigned tpg_get_pat_lines(const struct tpg_data *tpg)
 {
switch (tpg->pattern) {
case TPG_PAT_CHECKERS_16X16:
+   case TPG_PAT_CHECKERS_2X2:
case TPG_PAT_CHECKERS_1X1:
+   case TPG_PAT_COLOR_CHECKERS_2X2:
+   case TPG_PAT_COLOR_CHECKERS_1X1:
case TPG_PAT_ALTERNATING_HLINES:
case TPG_PAT_CROSS_1_PIXEL:
case TPG_PAT_CROSS_2_PIXELS:
@@ -763,14 +769,18 @@ static unsigned tpg_get_pat_lines(struct tpg_data *tpg)
 }
 
 /* Which pattern line should be used for the given frame line. */
-static unsigned tpg_get_pat_line(struct tpg_data *tpg, unsigned line)
+static unsigned tpg_get_pat_line(const struct tpg_data *tpg, unsigned line)
 {
switch (tpg->pattern) {
case TPG_PAT_CHECKERS_16X16:
return (line >> 4) & 1;
case TPG_PAT_CHECKERS_1X1:
+   case TPG_PAT_COLOR_CHECKERS_1X1:
case TPG_PAT_ALTERNATING_HLINES:
return line & 1;
+   case TPG_PAT_CHECKERS_2X2:
+   case TPG_PAT_COLOR_CHECKERS_2X2:
+   return (line & 2) >> 1;
case TPG_PAT_100_COLORSQUARES:
case TPG_PAT_100_HCOLORBAR:
return (line * 8) / tpg->src_height;
@@ -789,7 +799,8 @@ static unsigned tpg_get_pat_line(struct tpg_data *tpg, 
unsigned line)
  * Which color should be used for the given pattern line and X coordinate.
  * Note: x is in the range 0 to 2 * tpg->src_width.
  */
-static enum tpg_color tpg_get_color(struct tpg_data *tpg, unsigned pat_line, 
unsigned x)
+static enum tpg_color tpg_get_color(const struct tpg_data *tpg,
+   unsigned pat_line, unsigned x)
 {
/* Maximum number of bars are TPG_COLOR_MAX - otherwise, the input 
print code
   should be modified */
@@ -836,6 +847,15 @@ static enum tpg_color tpg_get_color(struct tpg_data *tpg, 
unsigned pat_line, uns
case TPG_PAT_CHECKERS_1X1:
return ((x & 1) ^ (pat_line & 1)) ?
TPG_COLOR_100_WHITE : TPG_COLOR_100_BLACK;
+   case TPG_PAT_COLOR_CHECKERS_1X1:
+   return ((x & 1) ^ (pat_line & 1)) ?
+   TPG_COLOR_100_RED : TPG_COLOR_100_BLUE;
+   case TPG_PAT_CHECKERS_2X2:
+   return (((x >> 1) & 1) ^ (pat_line & 1)) ?
+   TPG_COLOR_100_WHITE : TPG_COLOR_100_BLACK;
+   case TPG_PAT_COLOR_CHECKERS_2X2:
+   return (((x >> 1) & 1) ^ (pat_line & 1)) ?
+   TPG_COLOR_100_RED : TPG_COLOR_100_BLUE;
case TPG_PAT_ALTERNATING_HLINES:
return pat_line ? TPG_COLOR_100_WHITE : TPG_COLOR_100_BLACK;
case TPG_PAT_ALTERNATING_VLINES:
diff --git a/drivers/media/platform/vivid/vivid-tpg.h 
b/drivers/media/platform/vivid/vivid-tpg.h
index 8100425..e796a54 100644
--- a/drivers/media/platform/vivid/vivid-tpg.h
+++ b/drivers/media/platform/vivid/vivid-tpg.h
@@ -41,7 +41,10 @@ enum tpg_pattern {
TPG_PAT_GREEN,
TPG_PAT_BLUE,
TPG_PAT_CHECKERS_16X16,
+   TPG_PAT_CHECKERS_2X2,
TPG_PAT_CHECKERS_1X1,
+   TPG_PAT_COLOR_CHECKERS_2X2,
+   TPG_PAT_COLOR_CHECKERS_1X1,
TPG_PAT_ALTERNATING_HLINES,
TPG_PAT_ALTERNATING_VLINES,
TPG_PAT_CROSS_1_PIXEL,
-- 
2.1.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 07/29] vivid-tpg: don't add offset when switching to monochrome

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The grayscale values are still full range sRGB, so don't add the
limited range offset.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-tpg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vivid/vivid-tpg.c 
b/drivers/media/platform/vivid/vivid-tpg.c
index e2af384..c1476a2 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -530,7 +530,7 @@ static void precalculate_color(struct tpg_data *tpg, int k)
if (tpg->qual == TPG_QUAL_GRAY) {
/* Rec. 709 Luma function */
/* (0.2126, 0.7152, 0.0722) * (255 * 256) */
-   r = g = b = ((13879 * r + 46688 * g + 4713 * b) >> 16) + (16 << 
4);
+   r = g = b = (13879 * r + 46688 * g + 4713 * b) >> 16;
}
 
/*
-- 
2.1.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 01/29] vivid: the overlay API wasn't disabled completely for multiplanar

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

If the vivid driver is loaded in multiplanar mode, then the capture overlay
functionality should be disabled. This wasn't fully done, which led to
v4l2-compliance errors.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-vid-cap.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c 
b/drivers/media/platform/vivid/vivid-vid-cap.c
index 867a29a..550945a 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -1012,8 +1012,12 @@ int vivid_vid_cap_cropcap(struct file *file, void *priv,
 int vidioc_enum_fmt_vid_overlay(struct file *file, void  *priv,
struct v4l2_fmtdesc *f)
 {
+   struct vivid_dev *dev = video_drvdata(file);
const struct vivid_fmt *fmt;
 
+   if (dev->multiplanar)
+   return -ENOTTY;
+
if (f->index >= ARRAY_SIZE(formats_ovl))
return -EINVAL;
 
@@ -1032,6 +1036,9 @@ int vidioc_g_fmt_vid_overlay(struct file *file, void 
*priv,
struct v4l2_window *win = &f->fmt.win;
unsigned clipcount = win->clipcount;
 
+   if (dev->multiplanar)
+   return -ENOTTY;
+
win->w.top = dev->overlay_cap_top;
win->w.left = dev->overlay_cap_left;
win->w.width = compose->width;
@@ -1063,6 +1070,9 @@ int vidioc_try_fmt_vid_overlay(struct file *file, void 
*priv,
struct v4l2_window *win = &f->fmt.win;
int i, j;
 
+   if (dev->multiplanar)
+   return -ENOTTY;
+
win->w.left = clamp_t(int, win->w.left,
  -dev->fb_cap.fmt.width, dev->fb_cap.fmt.width);
win->w.top = clamp_t(int, win->w.top,
@@ -1150,6 +1160,9 @@ int vivid_vid_cap_overlay(struct file *file, void *fh, 
unsigned i)
 {
struct vivid_dev *dev = video_drvdata(file);
 
+   if (dev->multiplanar)
+   return -ENOTTY;
+
if (i && dev->fb_vbase_cap == NULL)
return -EINVAL;
 
@@ -1169,6 +1182,9 @@ int vivid_vid_cap_g_fbuf(struct file *file, void *fh,
 {
struct vivid_dev *dev = video_drvdata(file);
 
+   if (dev->multiplanar)
+   return -ENOTTY;
+
*a = dev->fb_cap;
a->capability = V4L2_FBUF_CAP_BITMAP_CLIPPING |
V4L2_FBUF_CAP_LIST_CLIPPING;
@@ -1185,6 +1201,9 @@ int vivid_vid_cap_s_fbuf(struct file *file, void *fh,
struct vivid_dev *dev = video_drvdata(file);
const struct vivid_fmt *fmt;
 
+   if (dev->multiplanar)
+   return -ENOTTY;
+
if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO))
return -EPERM;
 
-- 
2.1.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 03/29] vivid: wrong top/bottom order for FIELD_ALTERNATE

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The condition to decide whether the current field is top or bottom
was inverted. Fix this.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-kthread-cap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vivid/vivid-kthread-cap.c 
b/drivers/media/platform/vivid/vivid-kthread-cap.c
index 39a67cf..9898072 100644
--- a/drivers/media/platform/vivid/vivid-kthread-cap.c
+++ b/drivers/media/platform/vivid/vivid-kthread-cap.c
@@ -427,7 +427,7 @@ static void vivid_fillbuff(struct vivid_dev *dev, struct 
vivid_buffer *buf)
 * standards.
 */
buf->vb.v4l2_buf.field = ((dev->vid_cap_seq_count & 1) ^ 
is_60hz) ?
-   V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM;
+   V4L2_FIELD_BOTTOM : V4L2_FIELD_TOP;
/*
 * The sequence counter counts frames, not fields. So divide
 * by two.
-- 
2.1.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 04/29] vivid: use TPG_MAX_PLANES instead of hardcoding plane-arrays

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

Two arrays of size 'max number of planes' have a hardcoded size instead
of using TPG_MAX_PLANES. Fix that, since TPG_MAX_PLANES will be increased
later on.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-core.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-core.h 
b/drivers/media/platform/vivid/vivid-core.h
index 4b497df..191d9b5 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -84,7 +84,7 @@ struct vivid_fmt {
boolcan_do_overlay;
u32 alpha_mask;
u8  planes;
-   u32 data_offset[2];
+   u32 data_offset[TPG_MAX_PLANES];
 };
 
 extern struct vivid_fmt vivid_formats[];
@@ -332,7 +332,7 @@ struct vivid_dev {
u32 ycbcr_enc_out;
u32 quantization_out;
u32 service_set_out;
-   u32 bytesperline_out[2];
+   u32 bytesperline_out[TPG_MAX_PLANES];
unsignedtv_field_out;
unsignedtv_audio_output;
boolvbi_out_have_wss;
-- 
2.1.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 02/29] vivid: fix typo in plane size checks

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

The plane size check was hardcoded to plane 0 instead of using the plane
index.

This failed when using the NV61M format which has a larger plane size for
the second plane compared to the first plane.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/vivid/vivid-vid-cap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c 
b/drivers/media/platform/vivid/vivid-vid-cap.c
index 550945a..49f79a0 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -188,9 +188,9 @@ static int vid_cap_buf_prepare(struct vb2_buffer *vb)
size = tpg_g_bytesperline(&dev->tpg, p) * 
dev->fmt_cap_rect.height +
dev->fmt_cap->data_offset[p];
 
-   if (vb2_plane_size(vb, 0) < size) {
+   if (vb2_plane_size(vb, p) < size) {
dprintk(dev, 1, "%s data will not fit into plane %u 
(%lu < %lu)\n",
-   __func__, p, vb2_plane_size(vb, 0), 
size);
+   __func__, p, vb2_plane_size(vb, p), 
size);
return -EINVAL;
}
 
-- 
2.1.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 00/29] vivid: add support for 4:2:0 formats

2015-03-09 Thread Hans Verkuil
From: Hans Verkuil 

This patch series adds support for most of the 4:2:0 formats that V4L2 has.
In addition, it fixes various bugs, adds some new features and refactors
the test pattern generation code.

The first 8 patches fix bugs and add support for new red/blue checkerboard
patterns.

Patches 9-19 add 4:2:0 support to the test pattern generator code.

Patches 20-25 refactors the test pattern generation function which become
much, much too large.

Patches 26-28 add vivid driver support for the 4:2:0 formats and the last
patch finally enables support for the new formats.

Besides the new 4:2:0 formats support was also added for PIX_FMT_GREY and
some missing 4:2:2 formats.

Regards,

Hans

Hans Verkuil (29):
  vivid: the overlay API wasn't disabled completely for multiplanar
  vivid: fix typo in plane size checks
  vivid: wrong top/bottom order for FIELD_ALTERNATE
  vivid: use TPG_MAX_PLANES instead of hardcoding plane-arrays
  vivid: fix test pattern movement for V4L2_FIELD_ALTERNATE
  vivid: add new checkboard patterns
  vivid-tpg: don't add offset when switching to monochrome
  vivid: do not allow video loopback for SEQ_TB/BT
  vivid-tpg: separate planes and buffers
  vivid-tpg: add helper functions for single buffer planar formats
  vivid-tpg: add hor/vert downsampling fields
  vivid-tpg: precalculate downsampled lines
  vivid-tpg: correctly average the two pixels in gen_twopix()
  vivid-tpg: add hor/vert downsampling support to tpg_gen_text
  vivid-tpg: finish hor/vert downsampling support
  vivid-tpg: add support for more planar formats
  vivid-tpg: add support for V4L2_PIX_FMT_GREY
  vivid-tpg: add helper functions to simplify common calculations
  vivid-tpg: add const where appropriate
  vivid-tpg: add a new tpg_draw_params structure
  vivid-tpg: move common parameters to tpg_draw_params
  vivid-tpg: move pattern-related fields to struct tpg_draw_params
  vivid-tpg: move 'extras' parameters to tpg_draw_params
  vivid-tpg: move the 'extras' drawing to a separate function
  vivid-tpg: split off the pattern drawing code.
  vivid: add new format fields
  vivid: add support for single buffer planar formats
  vivid: add downsampling support
  vivid: add the new planar and monochrome formats

 Documentation/video4linux/vivid.txt  |   5 +
 drivers/media/platform/vivid/vivid-core.h|   8 +-
 drivers/media/platform/vivid/vivid-kthread-cap.c | 125 ++--
 drivers/media/platform/vivid/vivid-tpg.c | 903 ---
 drivers/media/platform/vivid/vivid-tpg.h | 103 ++-
 drivers/media/platform/vivid/vivid-vid-cap.c | 100 ++-
 drivers/media/platform/vivid/vivid-vid-common.c  | 207 +-
 drivers/media/platform/vivid/vivid-vid-out.c |  75 +-
 8 files changed, 1109 insertions(+), 417 deletions(-)

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


Re: [RFC 11/18] omap3isp: Replace many MMIO regions by two

2015-03-09 Thread Tony Lindgren
* Laurent Pinchart  [150307 15:43]:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> (CC'ing linux-omap and Tony)
> 
> On Saturday 07 March 2015 23:41:08 Sakari Ailus wrote:
> > The omap3isp MMIO register block is contiguous in the MMIO register space
> > apart from the fact that the ISP IOMMU register block is in the middle of
> > the area. Ioremap it at two occasions, and keep the rest of the layout of
> > the register space internal to the omap3isp driver.
> > 
> > Signed-off-by: Sakari Ailus 
> 
> Acked-by: Laurent Pinchart 
> 
> > ---
> >  arch/arm/mach-omap2/devices.c |   66 +--
> >  arch/arm/mach-omap2/omap34xx.h|   36 +--
> 
> Once again you might be asked to split this. However, it would be pretty 
> painful, so it would be nice if we could merge everything through the Linux 
> media tree. You will need an ack from Tony.

These changes look fine to me and should not conflict with anything
I'm planning to queue, so please feel free to take them along with
the other isp changes:

Acked-by: Tony Lindgren 
 
> >  drivers/media/platform/omap3isp/isp.c |  113 --
> >  drivers/media/platform/omap3isp/isp.h |4 +-
> >  4 files changed, 66 insertions(+), 153 deletions(-)
> > 
> > diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> > index e945957..990338f 100644
> > --- a/arch/arm/mach-omap2/devices.c
> > +++ b/arch/arm/mach-omap2/devices.c
> > @@ -74,72 +74,12 @@ omap_postcore_initcall(omap3_l3_init);
> >  static struct resource omap3isp_resources[] = {
> > {
> > .start  = OMAP3430_ISP_BASE,
> > -   .end= OMAP3430_ISP_END,
> > +   .end= OMAP3430_ISP_BASE + 0x12fc,
> > .flags  = IORESOURCE_MEM,
> > },
> > {
> > -   .start  = OMAP3430_ISP_CCP2_BASE,
> > -   .end= OMAP3430_ISP_CCP2_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3430_ISP_CCDC_BASE,
> > -   .end= OMAP3430_ISP_CCDC_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3430_ISP_HIST_BASE,
> > -   .end= OMAP3430_ISP_HIST_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3430_ISP_H3A_BASE,
> > -   .end= OMAP3430_ISP_H3A_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3430_ISP_PREV_BASE,
> > -   .end= OMAP3430_ISP_PREV_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3430_ISP_RESZ_BASE,
> > -   .end= OMAP3430_ISP_RESZ_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3430_ISP_SBL_BASE,
> > -   .end= OMAP3430_ISP_SBL_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3430_ISP_CSI2A_REGS1_BASE,
> > -   .end= OMAP3430_ISP_CSI2A_REGS1_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3430_ISP_CSIPHY2_BASE,
> > -   .end= OMAP3430_ISP_CSIPHY2_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3630_ISP_CSI2A_REGS2_BASE,
> > -   .end= OMAP3630_ISP_CSI2A_REGS2_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3630_ISP_CSI2C_REGS1_BASE,
> > -   .end= OMAP3630_ISP_CSI2C_REGS1_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3630_ISP_CSIPHY1_BASE,
> > -   .end= OMAP3630_ISP_CSIPHY1_END,
> > -   .flags  = IORESOURCE_MEM,
> > -   },
> > -   {
> > -   .start  = OMAP3630_ISP_CSI2C_REGS2_BASE,
> > -   .end= OMAP3630_ISP_CSI2C_REGS2_END,
> > +   .start  = OMAP3430_ISP_BASE2,
> > +   .end= OMAP3430_ISP_BASE2 + 0x0600,
> > .flags  = IORESOURCE_MEM,
> > },
> > {
> > diff --git a/arch/arm/mach-omap2/omap34xx.h b/arch/arm/mach-omap2/omap34xx.h
> > index c0d1b4b..ed0024d 100644
> > --- a/arch/arm/mach-omap2/omap34xx.h
> > +++ b/arch/arm/mach-omap2/omap34xx.h
> > @@ -46,39 +46,9 @@
> > 
> >  #define OMAP34XX_IC_BASE   0x4820
> > 
> > -#define OMAP3430_ISP_BASE  (L4_34XX_BASE + 0xBC000)
> > -#define OMAP3430_ISP_CBUFF_BASE(OMAP3430_ISP_BASE + 0x0100)
> > -#define OMAP3430_ISP_CCP2_BASE (OMAP3430_ISP_BASE + 0x0400)
> > -#define OMAP3430_ISP_CCDC_BASE (OMAP3430_ISP_BASE + 0x0600)
> > -#defi

Re: [RFC 10/18] omap3isp: Move the syscon register out of the ISP register maps

2015-03-09 Thread Tony Lindgren
* Sakari Ailus  [150307 15:44]:
> Hi Laurent,
> 
> On Sun, Mar 08, 2015 at 01:34:17AM +0200, Laurent Pinchart wrote:
> > Hi Sakari,
> > 
> > Thank you for the patch.
> > 
> > (CC'ing linux-omap and Tony)
> 
> Thanks.
> 
> > On Saturday 07 March 2015 23:41:07 Sakari Ailus wrote:
> > > The syscon register isn't part of the ISP, use it through the syscom 
> > > driver
> > > regmap instead. The syscom block is considered to be from 343x on ISP
> > > revision 2.0 whereas 15.0 is assumed to have 3630 syscon.
> > > 
> > > Signed-off-by: Sakari Ailus 
> > > ---
> > >  arch/arm/boot/dts/omap3.dtsi|2 +-
> > >  arch/arm/mach-omap2/devices.c   |   10 --
> > >  drivers/media/platform/omap3isp/isp.c   |   19 +++
> > >  drivers/media/platform/omap3isp/isp.h   |   19 +--
> > >  drivers/media/platform/omap3isp/ispcsiphy.c |   20 +---
> > 
> > You might be asked to split the patch into two, let's see what Tony says.
> > 
> > >  5 files changed, 42 insertions(+), 28 deletions(-)
> > > 
> > > diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> > > index 01b7111..fe0b293 100644
> > > --- a/arch/arm/boot/dts/omap3.dtsi
> > > +++ b/arch/arm/boot/dts/omap3.dtsi
> > > @@ -183,7 +183,7 @@
> > > 
> > >   omap3_scm_general: tisyscon@48002270 {
> > >   compatible = "syscon";
> > > - reg = <0x48002270 0x2f0>;
> > > + reg = <0x48002270 0x2f4>;
> > >   };
> > > 
> > >   pbias_regulator: pbias_regulator {

Can you please send the above dts change separately as a fix describing
what goes wrong? Let's get that out of the way for the -rc, otherwise
we're going to probably get conflicts with Tero's dts changes.

> > > diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> > > index 1afb50d..e945957 100644
> > > --- a/arch/arm/mach-omap2/devices.c
> > > +++ b/arch/arm/mach-omap2/devices.c
> > > @@ -143,16 +143,6 @@ static struct resource omap3isp_resources[] = {
> > >   .flags  = IORESOURCE_MEM,
> > >   },
> > >   {
> > > - .start  = OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE,
> > > - .end= OMAP343X_CTRL_BASE + OMAP343X_CONTROL_CSIRXFE 
> > > + 3,
> > > - .flags  = IORESOURCE_MEM,
> > > - },
> > > - {
> > > - .start  = OMAP343X_CTRL_BASE + 
> > > OMAP3630_CONTROL_CAMERA_PHY_CTRL,
> > > - .end= OMAP343X_CTRL_BASE + 
> > > OMAP3630_CONTROL_CAMERA_PHY_CTRL + 3,
> > > - .flags  = IORESOURCE_MEM,
> > > - },
> > > - {
> > >   .start  = 24 + OMAP_INTC_START,
> > >   .flags  = IORESOURCE_IRQ,
> > >   }

Looks good to me, teel free to merge this part along with the other
isp changes:

Acked-by: Tony Lindgren 


> > > diff --git a/drivers/media/platform/omap3isp/isp.c
> > > b/drivers/media/platform/omap3isp/isp.c index 68d7edfc..4ff4bbd 100644
> > > --- a/drivers/media/platform/omap3isp/isp.c
> > > +++ b/drivers/media/platform/omap3isp/isp.c
> > > @@ -51,6 +51,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -94,8 +95,9 @@ static const struct isp_res_mapping isp_res_maps[] = {
> > >  1 << OMAP3_ISP_IOMEM_RESZ |
> > >  1 << OMAP3_ISP_IOMEM_SBL |
> > >  1 << OMAP3_ISP_IOMEM_CSI2A_REGS1 |
> > > -1 << OMAP3_ISP_IOMEM_CSIPHY2 |
> > > -1 << OMAP3_ISP_IOMEM_343X_CONTROL_CSIRXFE,
> > > +1 << OMAP3_ISP_IOMEM_CSIPHY2,
> > > + .syscon_offset = 0xdc,
> > > + .phy_type = ISP_PHY_TYPE_3430,
> > >   },
> > >   {
> > >   .isp_rev = ISP_REVISION_15_0,
> > > @@ -112,8 +114,9 @@ static const struct isp_res_mapping isp_res_maps[] = {
> > >  1 << OMAP3_ISP_IOMEM_CSI2A_REGS2 |
> > >  1 << OMAP3_ISP_IOMEM_CSI2C_REGS1 |
> > >  1 << OMAP3_ISP_IOMEM_CSIPHY1 |
> > > -1 << OMAP3_ISP_IOMEM_CSI2C_REGS2 |
> > > -1 << OMAP3_ISP_IOMEM_3630_CONTROL_CAMERA_PHY_CTRL,
> > > +1 << OMAP3_ISP_IOMEM_CSI2C_REGS2,
> > > + .syscon_offset = 0x2f0,
> > > + .phy_type = ISP_PHY_TYPE_3630,
> > >   },
> > >  };
> > > 
> > > @@ -2352,6 +2355,14 @@ static int isp_probe(struct platform_device *pdev)
> > >   }
> > >   }
> > > 
> > > + isp->syscon = syscon_regmap_lookup_by_pdevname("syscon.0");
> > > + isp->syscon_offset = isp_res_maps[m].syscon_offset;
> > > + isp->phy_type = isp_res_maps[m].phy_type;
> > 
> > You could move those two lines after the error check to keep the check 
> > closer 
> > to the source of error.
> 
> Ack.
> 
> > Apart from that,
> > 
> > Acked-by: Laurent Pinchart 
> 
> Thanks for the acks!
> 
> -- 
> Kind regards,
> 
> Sakari Ailus
> e-mail: sakari.ai...@iki.fi   XMPP: sai...@retiisi.org.uk
--
To unsub

Re: [PATCH v3][RFC] add raw video stream support for Samsung SUR40

2015-03-09 Thread Hans Verkuil
On 03/09/2015 02:45 PM, Florian Echtler wrote:
> On 09.03.2015 11:09, Hans Verkuil wrote:
>> Hi Florian,
>>
>> OK, the cause of this failure is this message:
>>
>> Mar  9 10:39:08 sur40 kernel: [ 1093.200960] sur40 2-1:1.0: error in 
>> usb_sg_wait
>>
>> So you need to print the error message here (sgr.status) so that I can see 
>> what
>> it is.
> I've amended the dev_debug call, the error returned from usb_sg_wait is
> also -22 (EINVAL).
> 
>> The error almost certainly comes from usb_submit_urb(). That function does 
>> some
>> checks on the sgl:
>>
>> I wonder it the code gets there. Perhaps a printk just before the return 
>> -EINVAL
>> might help here (also print the 'max' value).
>>
>> So you will have to debug a bit here, trying to figure out which test in the 
>> usb
>> code causes the usb_sg_wait error.
> I'll do my best to track this down. Do you think this is an error in my
> code, one in the USB subsystem, or some combination of both?

If the USB core indeed requires scatter-gather segments of specific lengths
(modulo max), then that explains the problems.

So as suggested try to see if the usb core bails out in that check and what the
'max' value is. It looks like only XHCI allows SG segments of any size, so I 
really
suspect that's the problem. But I also need to know the 'max' value to fully
understand the implications.

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: [PATCH/RFC v12 10/19] DT: Add documentation for the mfd Maxim max77693

2015-03-09 Thread Jacek Anaszewski

On 03/09/2015 01:37 PM, Sakari Ailus wrote:

Hi Jacek,

On Mon, Mar 09, 2015 at 01:19:32PM +0100, Jacek Anaszewski wrote:

Hi Sakari,

Thanks for the review.

On 03/09/2015 11:54 AM, Sakari Ailus wrote:

Hi Jacek,

On Wed, Mar 04, 2015 at 05:14:31PM +0100, Jacek Anaszewski wrote:

This patch adds device tree binding documentation for
the flash cell of the Maxim max77693 multifunctional device.

Signed-off-by: Jacek Anaszewski 
Signed-off-by: Andrzej Hajda 
Acked-by: Kyungmin Park 
Cc: Lee Jones 
Cc: Chanwoo Choi 
Cc: Bryan Wu 
Cc: Richard Purdie 
---
  Documentation/devicetree/bindings/mfd/max77693.txt |   61 
  1 file changed, 61 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/max77693.txt 
b/Documentation/devicetree/bindings/mfd/max77693.txt
index 38e6440..ab8fbd5 100644
--- a/Documentation/devicetree/bindings/mfd/max77693.txt
+++ b/Documentation/devicetree/bindings/mfd/max77693.txt
@@ -76,7 +76,53 @@ Optional properties:
  Valid values: 430, 470, 480, 490
  Default: 430

+- led : the LED submodule device node
+
+There are two LED outputs available - FLED1 and FLED2. Each of them can
+control a separate LED or they can be connected together to double
+the maximum current for a single connected LED. One LED is represented
+by one child node.
+
+Required properties:
+- compatible : Must be "maxim,max77693-led".
+
+Optional properties:
+- maxim,trigger-type : Flash trigger type.
+   Possible trigger types:
+   LEDS_TRIG_TYPE_EDGE (0) - Rising edge of the signal triggers
+   the flash,
+   LEDS_TRIG_TYPE_LEVEL (1) - Strobe pulse length controls duration
+   of the flash.
+- maxim,boost-mode :
+   In boost mode the device can produce up to 1.2A of total current
+   on both outputs. The maximum current on each output is reduced
+   to 625mA then. If not enabled explicitly, boost setting defaults to
+   LEDS_BOOST_FIXED in case both current sources are used.
+   Possible values:
+   LEDS_BOOST_OFF (0) - no boost,
+   LEDS_BOOST_ADAPTIVE (1) - adaptive mode,
+   LEDS_BOOST_FIXED (2) - fixed mode.
+- maxim,boost-mvout : Output voltage of the boost module in millivolts.
+- maxim,mvsys-min : Low input voltage level in millivolts. Flash is not fired
+   if chip estimates that system voltage could drop below this level due
+   to flash power consumption.
+
+Required properties of the LED child node:
+- label : see Documentation/devicetree/bindings/leds/common.txt


According to ePAPR, label is "a human readable string describing a device".
There's no requirement that this would be unique, for instance. If you have
a camera flash LED, there's necessarily no meaningful label for it, as it
doesn't really tell the user anything (vs. HDD activity LED, for instance).

I think I'd make this optional.


OK.


What comes to entity naming in Media controller, the label isn't enough. As
we haven't yet fully agreed on how to name the entities in the future, I'd
propose sticking to current practices: chip name (and optional numerical LED
ID) followed by the I2C address. The name should be specified by the driver.

Do you have other than I2C busses required by the current drivers?


I have AAT1290 device driven through GPIOs. There was also other driver,
for a similar device, submitted few days ago to linux-leds list.


The problem indeed is defining a stable and unique identifier for a device
in a system. In context of your patchset, I think this mostly matters in the
V4L2 flash API wrapper patch.


It would be good if LED Flash class device name would match V4L2 Flash
sub-device name. LED class devices are assigned names on the basis of
'name' property of struct led-classdev, which is passed to the
device_create_with_groups function. Some LED class drivers use hardcoded
strings for 'name' and other ones use the value of DT 'label' property
as the first choice, if it is available.


GPIO controlled devices are little bit more troublesome, as GPIO numbers
alone aren't necessarily stable, but depend on the probing order. Well, i2c
controllers could also be registered dynamically. The same goes for PCI
devices, too, for instance.


For LED Flash devices we must also keep in mind that a device is created
per discrete LED component connected to one or more current outputs of 
the flash LED controller. There can be more than one LED Flash class

device created per flash LED controller. This problem seems to be
even harder than the case with more than one device of a kind in the
system, as the devices are controlled with the same hardware interface.


Most i2c adapters have a static id, and PCI devices have a stable bus
address (unless system configuration is modified by e.g. adding or removing
OTHER devices).

I wonder if this could be resolved on OF-based systems by adding a string
property, say, device name, whenever where are more than o

rt-mutex usage in i2c

2015-03-09 Thread Sebastian Andrzej Siewior
I have two questions:

- em28xx_i2c_xfer() in drivers/media/usb/em28xx/em28xx-i2c.c takes a
  rt_mutex lock. This struct i2c_algorithm's ->master_xfer callback.
  Why does it take an extra lock since it looks to me that it is
  protected by struct i2c_adapter's bus_lock already.

- i2c_transfer() has this piece:
  2091 if (in_atomic() || irqs_disabled()) {
  2092 ret = i2c_trylock_adapter(adap);

  is this irqs_disabled() is what bothers me and should not be there.
  pxa does a spin_lock_irq() which would enable interrupts on return /
  too early.
  mxs has a wait_for_completion() which needs irqs enabled _and_ makes
  in_atomic() problematic, too. I have't checked other drivers but the
  commit, that introduced it, does not explain why it is required.
  So _should_ this be invoked from an interrupt handler (for instance),
  then it would record the wrong process as the lock owner. This isn't
  problematic unless on SMP the owner gets boosted because a process
  with a higher priority needs the lock.

Sebastian

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


  1   2   >