Re: [PATCH 03/21] media: davinci_vpfe: fix vpfe_ipipe_init() error handling

2018-10-08 Thread Joel Fernandes
On Fri, Apr 06, 2018 at 10:23:04AM -0400, Mauro Carvalho Chehab wrote:
> As warned:
>   drivers/staging/media/davinci_vpfe/dm365_ipipe.c:1834 vpfe_ipipe_init() 
> error: we previously assumed 'res' could be null (see line 1797)
> 
> There's something wrong at vpfe_ipipe_init():
> 
> 1) it caches the resourse_size() from from the first region
>and reuses to the second region;
> 
> 2) the "res" var is overriden 3 times;
> 
> 3) at free logic, it assumes that "res->start" is not
>overriden by platform_get_resource(pdev, IORESOURCE_MEM, 6),
>but that's not true, as it can even be NULL there.
> 
> This patch fixes the above issues by:
> 
> a) store the resources used by release_mem_region() on
>a separate var;
> 
> b) stop caching resource_size(), using the function where
>needed.
> 
> Signed-off-by: Mauro Carvalho Chehab 

I ran coccicheck on a 4.14.74 stable kernel and noticed that 'res' can be
NULL in vpfe_ipipe_init. It looks like this patch is not included in the 4.14
stable series. Can this patch be applied? I applied it myself and it applies
cleanly, but I have no way to test it.

That 'res->start' error_release could end up a NULL pointer deref.

 - Joel

 


cron job: media_tree daily build: ERRORS

2018-10-08 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 Oct  9 05:00:10 CEST 2018
media-tree git hash:9e5b5081fa117ae34eca94b63b1cb6d43dc28f10
media_build git hash:   4a8374a6ed1110f19ddda30b6bc94d0a37af43cb
v4l-utils git hash: 06ad469e966aafaf39c1cc76e6e0953ec7d4f9c9
edid-decode git hash:   5eeb151a748788666534d6ea3da07f90400d24c2
gcc version:i686-linux-gcc (GCC) 8.2.0
sparse version: 0.5.2
smatch version: 0.5.1
host hardware:  x86_64
host os:4.18.11-marune

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: OK
linux-git-arm-stm32: OK
linux-git-arm64: OK
linux-git-i686: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
Check COMPILE_TEST: OK
linux-3.10.108-i686: ERRORS
linux-3.10.108-x86_64: ERRORS
linux-3.11.10-i686: ERRORS
linux-3.11.10-x86_64: ERRORS
linux-3.12.74-i686: ERRORS
linux-3.12.74-x86_64: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.79-i686: ERRORS
linux-3.14.79-x86_64: ERRORS
linux-3.15.10-i686: ERRORS
linux-3.15.10-x86_64: ERRORS
linux-3.16.57-i686: ERRORS
linux-3.16.57-x86_64: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.123-i686: ERRORS
linux-3.18.123-x86_64: ERRORS
linux-3.19.8-i686: ERRORS
linux-3.19.8-x86_64: ERRORS
linux-4.0.9-i686: ERRORS
linux-4.0.9-x86_64: ERRORS
linux-4.1.52-i686: ERRORS
linux-4.1.52-x86_64: ERRORS
linux-4.2.8-i686: ERRORS
linux-4.2.8-x86_64: ERRORS
linux-4.3.6-i686: ERRORS
linux-4.3.6-x86_64: ERRORS
linux-4.4.159-i686: ERRORS
linux-4.4.159-x86_64: ERRORS
linux-4.5.7-i686: ERRORS
linux-4.5.7-x86_64: ERRORS
linux-4.6.7-i686: ERRORS
linux-4.6.7-x86_64: ERRORS
linux-4.7.10-i686: ERRORS
linux-4.7.10-x86_64: ERRORS
linux-4.8.17-i686: ERRORS
linux-4.8.17-x86_64: ERRORS
linux-4.9.131-i686: ERRORS
linux-4.9.131-x86_64: ERRORS
linux-4.10.17-i686: OK
linux-4.10.17-x86_64: OK
linux-4.11.12-i686: OK
linux-4.11.12-x86_64: OK
linux-4.12.14-i686: OK
linux-4.12.14-x86_64: OK
linux-4.13.16-i686: OK
linux-4.13.16-x86_64: OK
linux-4.14.74-i686: OK
linux-4.14.74-x86_64: OK
linux-4.15.18-i686: OK
linux-4.15.18-x86_64: OK
linux-4.16.18-i686: OK
linux-4.16.18-x86_64: OK
linux-4.17.19-i686: OK
linux-4.17.19-x86_64: OK
linux-4.18.12-i686: OK
linux-4.18.12-x86_64: OK
linux-4.19-rc6-i686: OK
linux-4.19-rc6-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS

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/index.html


Re: [PATCH] vivid: fix kernel oops when enabling HFLIP and OSD

2018-10-08 Thread Hans Verkuil
On 10/08/2018 09:08 PM, Hans Verkuil wrote:
> When the OSD is on (i.e. vivid displays text on top of the test pattern), and
> you enable hflip, then the driver crashes.
> 
> The cause turned out to be a division of a negative number by an unsigned 
> value.
> You expect that -8 / 2 would be -4, but in reality it is 2147483644 :-(
> 
> Signed-off-by: Hans Verkuil 
> Reported-by: Mauro Carvalho Chehab 
> ---
> diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c 
> b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> index f3d9c1140ffa..e76f87dc4368 100644
> --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> @@ -1773,7 +1773,7 @@ typedef struct { u16 __; u8 _; } __packed x24;
>   pos[7] = (chr & (0x01 << 0) ? fg : bg); \
>   } \
>   \
> - pos += (tpg->hflip ? -8 : 8) / hdiv;\
> + pos += (tpg->hflip ? -8 : 8) / (int)hdiv;   \
>   }   \
>   }   \
>  } while (0)
> 

Fixes: 3e14e7a82c1ef ("vivid-tpg: add hor/vert downsampling support to 
tpg_gen_text")

Regards,

Hans


Re: [PATCHv2] media: rc: add driver for Xbox DVD Movie Playback Kit

2018-10-08 Thread Sean Young
Hi Benjamin,

Thanks for your driver, I have some comments below.

On Thu, Oct 04, 2018 at 01:52:54PM +0200, Benjamin Valentin wrote:
> The Xbox DVD Movie Playback Kit is a USB dongle with an IR remote for the
> Original Xbox.
> 
> Historically it has been supported by the out-of-tree lirc_xbox driver,
> but this one has fallen out of favour and was just dropped from popular
> Kodi (formerly XBMC) distributions.
> 
> This driver is heaviely based on the ati_remote driver where all the
> boilerplate was taken from - I was mostly just removing code.
> 
> Signed-off-by: Benjamin Valentin 
> ---
> Changes since v1:
> 
> I discovered some more dead code leftover from the ati_remote driver.
> I also removed the open_mutex which I think is not needed here since
> this driver, unlike ati_remote, doesn't register both a rc and an input
> device.
> This also allowed me to collapse some functions.
> 
>  MAINTAINERS|   6 +
>  drivers/media/rc/Kconfig   |  11 +
>  drivers/media/rc/Makefile  |   1 +
>  drivers/media/rc/keymaps/Makefile  |   1 +
>  drivers/media/rc/keymaps/rc-xbox-dvd.c |  63 +
>  drivers/media/rc/xbox_remote.c | 342 +
>  include/media/rc-map.h |   1 +
>  7 files changed, 425 insertions(+)
>  create mode 100644 drivers/media/rc/keymaps/rc-xbox-dvd.c
>  create mode 100644 drivers/media/rc/xbox_remote.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 22065048d89d..712a51a1a955 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -15973,6 +15973,12 @@ T:   git 
> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/vdso
>  S:   Maintained
>  F:   arch/x86/entry/vdso/
>  
> +XBOX DVD IR REMOTE
> +M:   Benjamin Valentin 
> +S:   Maintained
> +F:   drivers/media/rc/xbox_remote.c
> +F:   drivers/media/rc/keymaps/rc-xbox-dvd.c
> +
>  XC2028/3028 TUNER DRIVER
>  M:   Mauro Carvalho Chehab 
>  L:   linux-media@vger.kernel.org
> diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
> index 1021c08a9ba4..05489294ebbc 100644
> --- a/drivers/media/rc/Kconfig
> +++ b/drivers/media/rc/Kconfig
> @@ -493,6 +493,17 @@ config IR_TANGO
>  The HW decoder supports NEC, RC-5, RC-6 IR protocols.
>  When compiled as a module, look for tango-ir.
>  
> +config CONFIG_RC_XBOX_DVD

The config option should not include the leading CONFIG_ in Kconfig,
so this is broken.

> + tristate "Xbox DVD Movie Playback Kit"
> + depends on RC_CORE

I think you need:

depends on USB_ARCH_HAS_HCD

As well here.

> + select USB
> + help
> +Say Y here if you want to use the Xbox DVD Movie Playback Kit.
> +These are IR remotes with USB receivers for the Original Xbox (2001).
> +
> +To compile this driver as a module, choose M here: the module will be
> +called xbox_remote.
> +
>  config IR_ZX
>   tristate "ZTE ZX IR remote control"
>   depends on RC_CORE
> diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
> index e0340d043fe8..92c163816849 100644
> --- a/drivers/media/rc/Makefile
> +++ b/drivers/media/rc/Makefile
> @@ -48,3 +48,4 @@ obj-$(CONFIG_IR_SIR) += sir_ir.o
>  obj-$(CONFIG_IR_MTK) += mtk-cir.o
>  obj-$(CONFIG_IR_ZX) += zx-irdec.o
>  obj-$(CONFIG_IR_TANGO) += tango-ir.o
> +obj-$(CONFIG_RC_XBOX_DVD) += xbox_remote.o
> diff --git a/drivers/media/rc/keymaps/Makefile 
> b/drivers/media/rc/keymaps/Makefile
> index d6b913a3032d..5b1399af6b3a 100644
> --- a/drivers/media/rc/keymaps/Makefile
> +++ b/drivers/media/rc/keymaps/Makefile
> @@ -116,4 +116,5 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
>   rc-winfast.o \
>   rc-winfast-usbii-deluxe.o \
>   rc-su3000.o \
> + rc-xbox-dvd.o \
>   rc-zx-irdec.o
> diff --git a/drivers/media/rc/keymaps/rc-xbox-dvd.c 
> b/drivers/media/rc/keymaps/rc-xbox-dvd.c
> new file mode 100644
> index ..61da6706715c
> --- /dev/null
> +++ b/drivers/media/rc/keymaps/rc-xbox-dvd.c
> @@ -0,0 +1,63 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +// Keytable for Xbox DVD remote
> +// Copyright (c) 2018 by Benjamin Valentin 
> +
> +#include 
> +#include 
> +
> +/* based on lircd.conf.xbox */
> +static struct rc_map_table xbox_dvd[] = {
> + {0x0b, KEY_OK},
> + {0xa6, KEY_UP},
> + {0xa7, KEY_DOWN},
> + {0xa8, KEY_RIGHT},
> + {0xa9, KEY_LEFT},
> + {0xc3, KEY_INFO},
> +
> + {0xc6, KEY_9},
> + {0xc7, KEY_8},
> + {0xc8, KEY_7},
> + {0xc9, KEY_6},
> + {0xca, KEY_5},
> + {0xcb, KEY_4},
> + {0xcc, KEY_3},
> + {0xcd, KEY_2},
> + {0xce, KEY_1},
> + {0xcf, KEY_0},
> +
> + {0xd5, KEY_ANGLE},
> + {0xd8, KEY_BACK},
> + {0xdd, KEY_PREVIOUSSONG},
> + {0xdf, KEY_NEXTSONG},
> + {0xe0, KEY_STOP},
> + {0xe2, KEY_REWIND},
> + {0xe3, KEY_FASTFORWARD},
> + {0xe5, KEY_TITLE},
> + {0xe6, KEY_PAUSE},
> + {0xea, 

Re: [RFC] Informal meeting during ELCE to discuss userspace support for stateless codecs

2018-10-08 Thread Kieran Bingham
Hi Hans

On 08/10/18 12:53, Hans Verkuil wrote:
> Hi all,
> 
> I would like to meet up somewhere during the ELCE to discuss userspace support
> for stateless (and perhaps stateful as well?) codecs.
> 
> It is also planned as a topic during the summit, but I would prefer to prepare
> for that in advance, esp. since I myself do not have any experience writing
> userspace SW for such devices.
> 
> Nicolas, it would be really great if you can participate in this meeting
> since you probably have the most experience with this by far.
> 
> Looking through the ELCE program I found two timeslots that are likely to work
> for most of us (because the topics in the program appear to be boring for us
> media types!):
> 
> Tuesday from 10:50-15:50
> 
> or:
> 
> Monday from 15:45 onward
> 
> My guess is that we need 2-3 hours or so. Hard to predict.
> 
> The basic question that I would like to have answered is what the userspace
> component should look like? libv4l-like plugin or a library that userspace can
> link with? Do we want more general support for stateful codecs as well that 
> deals
> with resolution changes and the more complex parts of the codec API?
> 
> I've mailed this directly to those that I expect are most interested in this,
> but if someone want to join in let me know.

Depending on time and availability I might like to join in on this.
Consider me non-essential however and if I'm not around don't wait for me.

I have a desire to work on the codecs for Renesas (although it seems
unlikely to be possible due to licensing issues)


> I want to keep the group small though, so you need to bring relevant 
> experience
> to the table.

I can offer outdated experience managing the codec firmwares, and
decode/encode stacks for the ST SDK2 player implementation.

However that was 4 or 5 years ago - so I now deny all knowledge of
knowing anything from back then :-)

--
Regards

Kieran


Re: [PATCH] vivid: fix kernel oops when enabling HFLIP and OSD

2018-10-08 Thread Hans Verkuil
On 10/08/2018 09:08 PM, Hans Verkuil wrote:
> When the OSD is on (i.e. vivid displays text on top of the test pattern), and
> you enable hflip, then the driver crashes.
> 
> The cause turned out to be a division of a negative number by an unsigned 
> value.
> You expect that -8 / 2 would be -4, but in reality it is 2147483644 :-(
> 
> Signed-off-by: Hans Verkuil 
> Reported-by: Mauro Carvalho Chehab 
> ---
> diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c 
> b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> index f3d9c1140ffa..e76f87dc4368 100644
> --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
> @@ -1773,7 +1773,7 @@ typedef struct { u16 __; u8 _; } __packed x24;
>   pos[7] = (chr & (0x01 << 0) ? fg : bg); \
>   } \
>   \
> - pos += (tpg->hflip ? -8 : 8) / hdiv;\
> + pos += (tpg->hflip ? -8 : 8) / (int)hdiv;   \
>   }   \
>   }   \
>  } while (0)
> 

This can be CC-ed to stable for 4.7 and up.

It actually broke in 4.1, but it was called vivid-tpg.c at that time.

Regards,

Hans


[PATCH] vivid: fix kernel oops when enabling HFLIP and OSD

2018-10-08 Thread Hans Verkuil
When the OSD is on (i.e. vivid displays text on top of the test pattern), and
you enable hflip, then the driver crashes.

The cause turned out to be a division of a negative number by an unsigned value.
You expect that -8 / 2 would be -4, but in reality it is 2147483644 :-(

Signed-off-by: Hans Verkuil 
Reported-by: Mauro Carvalho Chehab 
---
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c 
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index f3d9c1140ffa..e76f87dc4368 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -1773,7 +1773,7 @@ typedef struct { u16 __; u8 _; } __packed x24;
pos[7] = (chr & (0x01 << 0) ? fg : bg); \
} \
\
-   pos += (tpg->hflip ? -8 : 8) / hdiv;\
+   pos += (tpg->hflip ? -8 : 8) / (int)hdiv;   \
}   \
}   \
 } while (0)


RE: [PATCH v1 2/2] v4l: Document Intel IPU3 meta data uAPI

2018-10-08 Thread Mani, Rajmohan
Hi Sakari,

> -Original Message-
> From: sakari.ai...@linux.intel.com [mailto:sakari.ai...@linux.intel.com]
> Sent: Thursday, October 04, 2018 12:09 AM
> To: Mani, Rajmohan 
> Cc: Mauro Carvalho Chehab ; Hans Verkuil
> ; Zhi, Yong ; linux-
> me...@vger.kernel.org; tf...@chromium.org; mche...@kernel.org;
> hans.verk...@cisco.com; laurent.pinch...@ideasonboard.com; Zheng, Jian Xu
> ; Hu, Jerry W ; Li, Chao C
> ; Qiu, Tian Shu 
> Subject: Re: [PATCH v1 2/2] v4l: Document Intel IPU3 meta data uAPI
> 
> Hi Raj,
> 
> On Wed, Oct 03, 2018 at 10:56:19PM +, Mani, Rajmohan wrote:
> ...
> > > From some comment you had later,
> > > I guess you're meaning that only 3 or 7 are the valid values.
> > >
> > > Yet, you're listing from 2^3 to 2^7, and that's confusing. Perhaps
> > > you want to say, instead, that the valid values are at the 3..7 range?
> > > If so, please use something like "values at the [3..7] range".
> > >
> >
> > As Sakari pointed / preferred in the other thread, we will use the
> > format [3, 7] to represent all integers between 3 and 7, including 3 and 7.
> 
> Feel free to add a reference to this in the format documentation:
> 
> https://en.wikipedia.org/wiki/Interval_(mathematics)>
> 
> I guess the right place would be the top parameter format ReST document.
> 

Ack

> ...
> 
> > > > > + * All above has precision u0.4, range [0..0xF].
> > >
> > > again, what do you mean by u0.4?
> >
> > unsigned integer with 0 bits used for representing whole number, with
> > 4 least significant bits used to represent the fractional part.
> 
> You could refer to this:
> 
> https://en.wikipedia.org/wiki/Q_(number_format)>
> 
> The ux.y notation is more common in the context of software but I couldn't
> find any decent document to refer to.
> 

Ack.
Will stick with ux.y notation with the relevant documentation (unless there
Is a preference for Q format).

> --
> Regards,
> 
> Sakari Ailus
> sakari.ai...@linux.intel.com


Re: [GIT PULL for 4.20] Lens driver fixes, imx214 sensor driver

2018-10-08 Thread Sakari Ailus
Hi Mauro,

On Mon, Oct 08, 2018 at 12:57:22PM -0300, Mauro Carvalho Chehab wrote:
> Em Sun, 7 Oct 2018 16:05:57 +0300
> Sakari Ailus  escreveu:
> 
> > Hi Mauro,
> > 
> > This last pull for 4.20 contains dw9714 and dw9807 lens driver probe error
> > handling fixes and the Sony imx214 sensor driver. In other words, patches
> > that have roughly nil changes of breaking something.
> > 
> > Compile tested with and without both subdev uAPI and MC on x86-64, plus on
> > arm as well.
> > 
> > Please pull.
> > 
> > 
> > The following changes since commit 557c97b5133669297be561e6091da9ab6e488e65:
> > 
> >   media: cec: name for RC passthrough device does not need 'RC for' 
> > (2018-10-05 11:28:13 -0400)
> > 
> > are available in the git repository at:
> > 
> >   ssh://linuxtv.org/git/sailus/media_tree.git tags/for-4.20-11-sign
> > 
> > for you to fetch changes up to a8f772a119afcc1dfabf4d8b7e258b9f90d2c561:
> > 
> >   imx214: Add imx214 camera sensor driver (2018-10-06 21:20:40 +0300)
> > 
> > 
> > dw9714 and dw9807 fixes; imx214 driver
> > 
> > 
> > Rajmohan Mani (1):
> >   media: dw9714: Fix error handling in probe function
> > 
> > Ricardo Ribalda Delgado (2):
> >   imx214: device tree binding
> >   imx214: Add imx214 camera sensor driver
> 
> I'm missing the ack from Rob on the DT patch. Will apply the
> remaining ones from this series as they're independent.

Oops. I somehow thought Rob acked the patch but you're right. I think it
must have been another patch... Thanks for catching this one.

-- 
Regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [GIT PULL for 4.20] Lens driver fixes, imx214 sensor driver

2018-10-08 Thread Mauro Carvalho Chehab
Em Sun, 7 Oct 2018 16:05:57 +0300
Sakari Ailus  escreveu:

> Hi Mauro,
> 
> This last pull for 4.20 contains dw9714 and dw9807 lens driver probe error
> handling fixes and the Sony imx214 sensor driver. In other words, patches
> that have roughly nil changes of breaking something.
> 
> Compile tested with and without both subdev uAPI and MC on x86-64, plus on
> arm as well.
> 
> Please pull.
> 
> 
> The following changes since commit 557c97b5133669297be561e6091da9ab6e488e65:
> 
>   media: cec: name for RC passthrough device does not need 'RC for' 
> (2018-10-05 11:28:13 -0400)
> 
> are available in the git repository at:
> 
>   ssh://linuxtv.org/git/sailus/media_tree.git tags/for-4.20-11-sign
> 
> for you to fetch changes up to a8f772a119afcc1dfabf4d8b7e258b9f90d2c561:
> 
>   imx214: Add imx214 camera sensor driver (2018-10-06 21:20:40 +0300)
> 
> 
> dw9714 and dw9807 fixes; imx214 driver
> 
> 
> Rajmohan Mani (1):
>   media: dw9714: Fix error handling in probe function
> 
> Ricardo Ribalda Delgado (2):
>   imx214: device tree binding
>   imx214: Add imx214 camera sensor driver

I'm missing the ack from Rob on the DT patch. Will apply the
remaining ones from this series as they're independent.


> 
> Sakari Ailus (2):
>   dw9714: Remove useless error message
>   dw9807-vcm: Fix probe error handling

> 
>  .../devicetree/bindings/media/i2c/sony,imx214.txt  |   53 +
>  MAINTAINERS|8 +
>  drivers/media/i2c/Kconfig  |   12 +
>  drivers/media/i2c/Makefile |1 +
>  drivers/media/i2c/dw9714.c |5 +-
>  drivers/media/i2c/dw9807-vcm.c |3 +-
>  drivers/media/i2c/imx214.c | 1118 
> 
>  7 files changed, 1197 insertions(+), 3 deletions(-)
>  create mode 100644 
> Documentation/devicetree/bindings/media/i2c/sony,imx214.txt
>  create mode 100644 drivers/media/i2c/imx214.c
> 

Thanks,
Mauro


Re: [RFC PATCH 00/11] Convert last remaining g/s_crop/cropcap drivers

2018-10-08 Thread Sakari Ailus
Hi Hans,

On Fri, Oct 05, 2018 at 09:49:00AM +0200, Hans Verkuil wrote:
> From: Hans Verkuil 
> 
> This patch series converts the last remaining drivers that use g/s_crop and
> cropcap to g/s_selection.
> 
> The first two patches do some minor code cleanup.
> 
> The third patch adds a new video_device flag to indicate that the driver
> inverts the normal usage of g/s_crop/cropcap. This applies to the old
> Samsung drivers that predate the Selection API and that abused the existing
> crop API.
> 
> The next three patches do some code cleanup and prepare drivers for the
> removal of g/s_crop and ensure that cropcap only returns the pixelaspect.
> 
> The next three patches convert the remaining Samsung drivers and set the
> QUIRK flag for all three.
> 
> The final two patches remove vidioc_g/s_crop and rename vidioc_cropcap
> to vidioc_g_pixelaspect.

Nice one; thanks!

For patches 1, 2, 3, 10 and 11:

Acked-by: Sakari Ailus 

I didn't read through the driver changes but I assume they would be fine.
:-)

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi


[GIT PULL FOR v4.20] Various fixes

2018-10-08 Thread Hans Verkuil
Hi Mauro,

Final pull request for 4.20 with odd 'n ends.

Regards,

Hans

The following changes since commit 557c97b5133669297be561e6091da9ab6e488e65:

  media: cec: name for RC passthrough device does not need 'RC for' (2018-10-05 
11:28:13 -0400)

are available in the Git repository at:

  git://linuxtv.org/hverkuil/media_tree.git tags/br2-for-v4.20f

for you to fetch changes up to 295c6b7abc1beca6a3897e7aa4283f68a2d890d7:

  media: vivid: Add 16-bit bayer to format list (2018-10-08 17:20:41 +0200)


Tag branch


Biju Das (1):
  media: dt-bindings: media: rcar_vin: add device tree support for r8a7744

Bård Eirik Winther (2):
  media: v4l2-tpg-core: Add 16-bit bayer
  media: vivid: Add 16-bit bayer to format list

Colin Ian King (5):
  media: bttv-input: make const array addr_list static
  media: ivtv: make const array addr_list static
  media: cx23885: make const array addr_list static
  media: exynos4-is: make const array config_ids static
  media: cx231xx: fix potential sign-extension overflow on large shift

Dafna Hirschfeld (1):
  pvrusb2: replace `printk` with `pr_*`

Keiichi Watanabe (1):
  media: vivid: Support 480p for webcam capture

Nathan Chancellor (1):
  media: cx18: Don't check for address of video_dev

Vikash Garodia (1):
  venus: vdec: fix decoded data size

Wenwen Wang (1):
  media: isif: fix a NULL pointer dereference bug

 Documentation/devicetree/bindings/media/rcar_vin.txt |  1 +
 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c| 28 

 drivers/media/pci/bt8xx/bttv-input.c |  2 +-
 drivers/media/pci/cx18/cx18-driver.c |  2 +-
 drivers/media/pci/cx23885/cx23885-i2c.c  |  2 +-
 drivers/media/pci/ivtv/ivtv-i2c.c|  2 +-
 drivers/media/platform/davinci/isif.c|  3 ++-
 drivers/media/platform/exynos4-is/fimc-is.c  |  2 +-
 drivers/media/platform/qcom/venus/vdec.c |  3 +--
 drivers/media/platform/vivid/vivid-vid-cap.c |  5 -
 drivers/media/platform/vivid/vivid-vid-common.c  | 28 

 drivers/media/usb/cx231xx/cx231xx-video.c|  2 +-
 drivers/media/usb/pvrusb2/pvrusb2-debug.h|  2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c  |  8 
 drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | 28 
+---
 drivers/media/usb/pvrusb2/pvrusb2-main.c |  4 ++--
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c |  4 ++--
 17 files changed, 92 insertions(+), 34 deletions(-)


Re: [PATCH v2 1/6] media: video-i2c: avoid accessing released memory area when removing driver

2018-10-08 Thread Akinobu Mita
2018年10月8日(月) 20:21 Hans Verkuil :
>
> On 10/05/2018 04:59 PM, Akinobu Mita wrote:
> > 2018年10月5日(金) 18:36 Sakari Ailus :
> >>
> >> Hi Hans,
> >>
> >> On Mon, Oct 01, 2018 at 11:40:00AM +0200, Hans Verkuil wrote:
> >>> On 09/23/2018 06:34 PM, Akinobu Mita wrote:
>  The video_i2c_data is allocated by kzalloc and released by the video
>  device's release callback.  The release callback is called when
>  video_unregister_device() is called, but it will still be accessed after
>  calling video_unregister_device().
> 
>  Fix the use after free by allocating video_i2c_data by devm_kzalloc() 
>  with
>  i2c_client->dev so that it will automatically be released when the i2c
>  driver is removed.
> >>>
> >>> Hmm. The patch is right, but the explanation isn't. The core problem is
> >>> that vdev.release was set to video_i2c_release, but that should only be
> >>> used if struct video_device was kzalloc'ed. But in this case it is 
> >>> embedded
> >>> in a larger struct, and then vdev.release should always be set to
> >>> video_device_release_empty.
> >>
> >> When the driver is unbound, what's acquired using the devm_() family of
> >> functions is released. At the same time, the user still holds a file
> >> handle, and can issue IOCTLs --- but the device's data structures no longer
> >> exist.
> >>
> >> That's not ok, and also the reason why we have the release callback.
> >>
> >> While there are issues elsewhere, this bit of the V4L2 / MC frameworks is
> >> fine.
> >>
> >> Or am I missing something?
> >
> > How about moving the lines causing use-after-free to release callback
> > like below?
> >
> > static void video_i2c_release(struct video_device *vdev)
> > {
> > struct video_i2c_data *data = video_get_drvdata(vdev);
> >
> > v4l2_device_unregister(>v4l2_dev);
> > mutex_destroy(>lock);
> > mutex_destroy(>queue_lock);
> > kfree(data);
> > }
> >
>
> You can test this with v4l2-ctl:
>
> v4l2-ctl --sleep 10
>
> This sleeps 10s, then calls QUERYCAP and closes the file handle.
>
> In another shell you can unbind the driver while v4l2-ctl is sleeping.
>
> Hopefully this works without crashing anything :-)

I tried that and the command finished without crash.

$ v4l2-ctl --sleep 10 -d /dev/video2
Test VIDIOC_QUERYCAP:
VIDIOC_QUERYCAP returned -1 (No such device)
VIDIOC_QUERYCAP: No such device

This -ENODEV should be ok as V4L2_FL_REGISTERED flag has already been
cleared by video_unregister_device().


Re: [Outreachy kernel] [PATCH vicodec] media: pvrusb2: replace `printk` with `pr_*`

2018-10-08 Thread Greg KH
On Mon, Oct 08, 2018 at 03:29:03PM +0200, Hans Verkuil wrote:
> On 10/08/2018 03:07 PM, Greg KH wrote:
> > On Mon, Oct 08, 2018 at 03:06:47PM +0300, Dafna Hirschfeld wrote:
> >> Replace calls to `printk` with the appropriate `pr_*`
> >> macro.
> >>
> >> Signed-off-by: Dafna Hirschfeld 
> >> ---
> >>  drivers/media/usb/pvrusb2/pvrusb2-debug.h|  2 +-
> >>  drivers/media/usb/pvrusb2/pvrusb2-hdw.c  |  8 +++---
> >>  drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | 28 +---
> >>  drivers/media/usb/pvrusb2/pvrusb2-main.c |  4 +--
> >>  drivers/media/usb/pvrusb2/pvrusb2-v4l2.c |  4 +--
> >>  5 files changed, 22 insertions(+), 24 deletions(-)
> >>
> >> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debug.h 
> >> b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
> >> index 5cd16292e2fa..1323f949f454 100644
> >> --- a/drivers/media/usb/pvrusb2/pvrusb2-debug.h
> >> +++ b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
> >> @@ -17,7 +17,7 @@
> >>  
> >>  extern int pvrusb2_debug;
> >>  
> >> -#define pvr2_trace(msk, fmt, arg...) do {if(msk & pvrusb2_debug) 
> >> printk(KERN_INFO "pvrusb2: " fmt "\n", ##arg); } while (0)
> >> +#define pvr2_trace(msk, fmt, arg...) do {if (msk & pvrusb2_debug) 
> >> pr_info("pvrusb2: " fmt "\n", ##arg); } while (0)
> > 
> > You should not need prefixes for pr_info() calls.
> > 
> >>  
> >>  /* These are listed in *rough* order of decreasing usefulness and
> >> increasing noise level. */
> >> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
> >> b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> >> index a8519da0020b..7702285c1519 100644
> >> --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> >> +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> >> @@ -3293,12 +3293,12 @@ void pvr2_hdw_trigger_module_log(struct pvr2_hdw 
> >> *hdw)
> >>int nr = pvr2_hdw_get_unit_number(hdw);
> >>LOCK_TAKE(hdw->big_lock);
> >>do {
> >> -  printk(KERN_INFO "pvrusb2: =  START STATUS CARD 
> >> #%d  =\n", nr);
> >> +  pr_info("pvrusb2: =  START STATUS CARD #%d  
> >> =\n", nr);
> > 
> > A driver should be using dev_info(), not pr_*.
> 
> pvrusb2 is an exception due to historical reasons. I'd rather not switch
> over to dev_*.

Why should a historical reason be needed to fix up code to be correct?

Why not use the correct functions?  You will just constantly be
rejecting patches like this for the next 20+ years :(

thanks,

greg k-h


Re: [Outreachy kernel] [PATCH vicodec] media: pvrusb2: replace `printk` with `pr_*`

2018-10-08 Thread Hans Verkuil
On 10/08/2018 03:07 PM, Greg KH wrote:
> On Mon, Oct 08, 2018 at 03:06:47PM +0300, Dafna Hirschfeld wrote:
>> Replace calls to `printk` with the appropriate `pr_*`
>> macro.
>>
>> Signed-off-by: Dafna Hirschfeld 
>> ---
>>  drivers/media/usb/pvrusb2/pvrusb2-debug.h|  2 +-
>>  drivers/media/usb/pvrusb2/pvrusb2-hdw.c  |  8 +++---
>>  drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | 28 +---
>>  drivers/media/usb/pvrusb2/pvrusb2-main.c |  4 +--
>>  drivers/media/usb/pvrusb2/pvrusb2-v4l2.c |  4 +--
>>  5 files changed, 22 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debug.h 
>> b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
>> index 5cd16292e2fa..1323f949f454 100644
>> --- a/drivers/media/usb/pvrusb2/pvrusb2-debug.h
>> +++ b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
>> @@ -17,7 +17,7 @@
>>  
>>  extern int pvrusb2_debug;
>>  
>> -#define pvr2_trace(msk, fmt, arg...) do {if(msk & pvrusb2_debug) 
>> printk(KERN_INFO "pvrusb2: " fmt "\n", ##arg); } while (0)
>> +#define pvr2_trace(msk, fmt, arg...) do {if (msk & pvrusb2_debug) 
>> pr_info("pvrusb2: " fmt "\n", ##arg); } while (0)
> 
> You should not need prefixes for pr_info() calls.
> 
>>  
>>  /* These are listed in *rough* order of decreasing usefulness and
>> increasing noise level. */
>> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
>> b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
>> index a8519da0020b..7702285c1519 100644
>> --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
>> +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
>> @@ -3293,12 +3293,12 @@ void pvr2_hdw_trigger_module_log(struct pvr2_hdw 
>> *hdw)
>>  int nr = pvr2_hdw_get_unit_number(hdw);
>>  LOCK_TAKE(hdw->big_lock);
>>  do {
>> -printk(KERN_INFO "pvrusb2: =  START STATUS CARD 
>> #%d  =\n", nr);
>> +pr_info("pvrusb2: =  START STATUS CARD #%d  
>> =\n", nr);
> 
> A driver should be using dev_info(), not pr_*.

pvrusb2 is an exception due to historical reasons. I'd rather not switch
over to dev_*.

> 
> Also, for the outreachy application process, I can not accept patches
> outside of drivers/staging/.

Hmm, that means media drivers are out of bounds since drivers in staging/media
are either high-quality drivers waiting for missing core features or that need 
maturing,
or they are deprecated drivers that will be removed in the not-too-distant 
future and
we're not accepting patches for those.

Whereas there are loads of old media drivers in driver/media that could use 
some TLC.
Although pvrusb2 was an unfortunate driver to pick, but Dafna had no way of 
knowing that.

There might be the odd checkpatch issue in staging/media, but I expect that 
that will be
slim pickings...

Sorry Dafna, I wasn't aware of this restriction. It looks like you will need to 
look
elsewhere in staging.

Regards,

Hans

> 
> sorry,
> 
> greg k-h
> 



Re: [Outreachy kernel] [PATCH vicodec] media: pvrusb2: replace `printk` with `pr_*`

2018-10-08 Thread Greg KH
On Mon, Oct 08, 2018 at 03:06:47PM +0300, Dafna Hirschfeld wrote:
> Replace calls to `printk` with the appropriate `pr_*`
> macro.
> 
> Signed-off-by: Dafna Hirschfeld 
> ---
>  drivers/media/usb/pvrusb2/pvrusb2-debug.h|  2 +-
>  drivers/media/usb/pvrusb2/pvrusb2-hdw.c  |  8 +++---
>  drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | 28 +---
>  drivers/media/usb/pvrusb2/pvrusb2-main.c |  4 +--
>  drivers/media/usb/pvrusb2/pvrusb2-v4l2.c |  4 +--
>  5 files changed, 22 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debug.h 
> b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
> index 5cd16292e2fa..1323f949f454 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-debug.h
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
> @@ -17,7 +17,7 @@
>  
>  extern int pvrusb2_debug;
>  
> -#define pvr2_trace(msk, fmt, arg...) do {if(msk & pvrusb2_debug) 
> printk(KERN_INFO "pvrusb2: " fmt "\n", ##arg); } while (0)
> +#define pvr2_trace(msk, fmt, arg...) do {if (msk & pvrusb2_debug) 
> pr_info("pvrusb2: " fmt "\n", ##arg); } while (0)

You should not need prefixes for pr_info() calls.

>  
>  /* These are listed in *rough* order of decreasing usefulness and
> increasing noise level. */
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
> b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> index a8519da0020b..7702285c1519 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> @@ -3293,12 +3293,12 @@ void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw)
>   int nr = pvr2_hdw_get_unit_number(hdw);
>   LOCK_TAKE(hdw->big_lock);
>   do {
> - printk(KERN_INFO "pvrusb2: =  START STATUS CARD 
> #%d  =\n", nr);
> + pr_info("pvrusb2: =  START STATUS CARD #%d  
> =\n", nr);

A driver should be using dev_info(), not pr_*.

Also, for the outreachy application process, I can not accept patches
outside of drivers/staging/.

sorry,

greg k-h


[PATCH 2/2] media: vivid: Add 16-bit bayer to format list

2018-10-08 Thread bwinther
From: Bård Eirik Winther 

New 16-bit bayer options are available in tpg so enable them in vivid.

Signed-off-by: Bård Eirik Winther 
---
 .../media/platform/vivid/vivid-vid-common.c   | 28 +++
 1 file changed, 28 insertions(+)

diff --git a/drivers/media/platform/vivid/vivid-vid-common.c 
b/drivers/media/platform/vivid/vivid-vid-common.c
index 27aa5973..9645a91b8782 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -449,6 +449,34 @@ struct vivid_fmt vivid_formats[] = {
.planes   = 1,
.buffers = 1,
},
+   {
+   .fourcc   = V4L2_PIX_FMT_SBGGR16, /* Bayer BG/GR */
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
+   .planes   = 1,
+   .buffers = 1,
+   },
+   {
+   .fourcc   = V4L2_PIX_FMT_SGBRG16, /* Bayer GB/RG */
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
+   .planes   = 1,
+   .buffers = 1,
+   },
+   {
+   .fourcc   = V4L2_PIX_FMT_SGRBG16, /* Bayer GR/BG */
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
+   .planes   = 1,
+   .buffers = 1,
+   },
+   {
+   .fourcc   = V4L2_PIX_FMT_SRGGB16, /* Bayer RG/GB */
+   .vdownsampling = { 1 },
+   .bit_depth = { 16 },
+   .planes   = 1,
+   .buffers = 1,
+   },
{
.fourcc   = V4L2_PIX_FMT_HSV24, /* HSV 24bits */
.color_enc = TGP_COLOR_ENC_HSV,
-- 
2.17.1



[PATCH 1/2] media: v4l2-tpg-core: Add 16-bit bayer

2018-10-08 Thread bwinther
From: Bård Eirik Winther 

Add 16-bit bayer formats to the test pattern generator, namely
  V4L2_PIX_FMT_SRGGB16
  V4L2_PIX_FMT_SGRBG16
  V4L2_PIX_FMT_SGBRG16
  V4L2_PIX_FMT_SBGGR16

Signed-off-by: Bård Eirik Winther 
---
 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 28 +++
 1 file changed, 28 insertions(+)

diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c 
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index f3d9c1140ffa..76b125ebee6d 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -202,6 +202,10 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
tpg->interleaved = true;
tpg->vdownsampling[1] = 1;
tpg->hdownsampling[1] = 1;
@@ -394,6 +398,10 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SBGGR12:
+   case V4L2_PIX_FMT_SRGGB16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SBGGR16:
tpg->twopixelsize[0] = 4;
tpg->twopixelsize[1] = 4;
break;
@@ -1358,6 +1366,22 @@ static void gen_twopix(struct tpg_data *tpg,
buf[0][offset] |= (buf[0][offset] >> 4) & 0xf;
buf[1][offset] |= (buf[1][offset] >> 4) & 0xf;
break;
+   case V4L2_PIX_FMT_SBGGR16:
+   buf[0][offset] = buf[0][offset + 1] = odd ? g_u_s : b_v;
+   buf[1][offset] = buf[1][offset + 1] = odd ? r_y_h : g_u_s;
+   break;
+   case V4L2_PIX_FMT_SGBRG16:
+   buf[0][offset] = buf[0][offset + 1] = odd ? b_v : g_u_s;
+   buf[1][offset] = buf[1][offset + 1] = odd ? g_u_s : r_y_h;
+   break;
+   case V4L2_PIX_FMT_SGRBG16:
+   buf[0][offset] = buf[0][offset + 1] = odd ? r_y_h : g_u_s;
+   buf[1][offset] = buf[1][offset + 1] = odd ? g_u_s : b_v;
+   break;
+   case V4L2_PIX_FMT_SRGGB16:
+   buf[0][offset] = buf[0][offset + 1] = odd ? g_u_s : r_y_h;
+   buf[1][offset] = buf[1][offset + 1] = odd ? b_v : g_u_s;
+   break;
}
 }
 
@@ -1376,6 +1400,10 @@ unsigned tpg_g_interleaved_plane(const struct tpg_data 
*tpg, unsigned buf_line)
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
return buf_line & 1;
default:
return 0;
-- 
2.17.1



[PATCH 3/4] qv4l2: Add 16-bit bayer rendering

2018-10-08 Thread bwinther
From: Bård Eirik Winther 

Add OpenGL support to render all v4l2 16-bit bayer formats

Signed-off-by: Bård Eirik Winther 
---
 utils/qv4l2/capture-win-gl.cpp | 24 
 1 file changed, 24 insertions(+)

diff --git a/utils/qv4l2/capture-win-gl.cpp b/utils/qv4l2/capture-win-gl.cpp
index f7f83326..0adb08b1 100644
--- a/utils/qv4l2/capture-win-gl.cpp
+++ b/utils/qv4l2/capture-win-gl.cpp
@@ -369,6 +369,10 @@ bool CaptureWinGLEngine::hasNativeFormat(__u32 format)
V4L2_PIX_FMT_SGBRG12,
V4L2_PIX_FMT_SGRBG12,
V4L2_PIX_FMT_SRGGB12,
+   V4L2_PIX_FMT_SBGGR16,
+   V4L2_PIX_FMT_SGBRG16,
+   V4L2_PIX_FMT_SGRBG16,
+   V4L2_PIX_FMT_SRGGB16,
V4L2_PIX_FMT_YUYV,
V4L2_PIX_FMT_YVYU,
V4L2_PIX_FMT_UYVY,
@@ -487,6 +491,10 @@ void CaptureWinGLEngine::changeShader()
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
shader_Bayer(m_frameFormat);
break;
 
@@ -635,6 +643,10 @@ void CaptureWinGLEngine::paintGL()
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
render_Bayer(m_frameFormat);
break;
 
@@ -1874,6 +1886,10 @@ void CaptureWinGLEngine::shader_Bayer(__u32 format)
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
glTexImage2D(GL_TEXTURE_2D, 0, m_glRed16, m_frameWidth, 
m_frameHeight, 0,
 m_glRed, GL_UNSIGNED_SHORT, NULL);
break;
@@ -1908,6 +1924,7 @@ void CaptureWinGLEngine::shader_Bayer(__u32 format)
case V4L2_PIX_FMT_SBGGR8:
case V4L2_PIX_FMT_SBGGR10:
case V4L2_PIX_FMT_SBGGR12:
+   case V4L2_PIX_FMT_SBGGR16:
codeHead +="   r = texture2D(tex, vec2(cell.x + texl_w, 
cell.y + texl_h)).r;"
   "   g = texture2D(tex, vec2((cell.y == xy.y) 
? cell.x + texl_w : cell.x, xy.y)).r;"
   "   b = texture2D(tex, cell).r;";
@@ -1915,6 +1932,7 @@ void CaptureWinGLEngine::shader_Bayer(__u32 format)
case V4L2_PIX_FMT_SGBRG8:
case V4L2_PIX_FMT_SGBRG10:
case V4L2_PIX_FMT_SGBRG12:
+   case V4L2_PIX_FMT_SGBRG16:
codeHead +="   r = texture2D(tex, vec2(cell.x, cell.y + 
texl_h)).r;"
   "   g = texture2D(tex, vec2((cell.y == xy.y) 
? cell.x : cell.x + texl_w, xy.y)).r;"
   "   b = texture2D(tex, vec2(cell.x + texl_w, 
cell.y)).r;";
@@ -1922,6 +1940,7 @@ void CaptureWinGLEngine::shader_Bayer(__u32 format)
case V4L2_PIX_FMT_SGRBG8:
case V4L2_PIX_FMT_SGRBG10:
case V4L2_PIX_FMT_SGRBG12:
+   case V4L2_PIX_FMT_SGRBG16:
codeHead +="   r = texture2D(tex, vec2(cell.x + texl_w, 
cell.y)).r;"
   "   g = texture2D(tex, vec2((cell.y == xy.y) 
? cell.x : cell.x + texl_w, xy.y)).r;"
   "   b = texture2D(tex, vec2(cell.x, cell.y + 
texl_h)).r;";
@@ -1929,6 +1948,7 @@ void CaptureWinGLEngine::shader_Bayer(__u32 format)
case V4L2_PIX_FMT_SRGGB8:
case V4L2_PIX_FMT_SRGGB10:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SRGGB16:
codeHead +="   b = texture2D(tex, vec2(cell.x + texl_w, 
cell.y + texl_h)).r;"
   "   g = texture2D(tex, vec2((cell.y == xy.y) 
? cell.x + texl_w : cell.x, xy.y)).r;"
   "   r = texture2D(tex, cell).r;";
@@ -2005,6 +2025,10 @@ void CaptureWinGLEngine::render_Bayer(__u32 format)
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, 
m_frameHeight,
m_glRed, GL_UNSIGNED_SHORT, m_frameData);
break;
-- 
2.17.1



[PATCH 2/4] qvidcap: Add 16-bit bayer rendering

2018-10-08 Thread bwinther
From: Bård Eirik Winther 

Add OpenGL support to render all v4l2 16-bit bayer formats

Signed-off-by: Bård Eirik Winther 
---
 utils/qvidcap/capture-win-gl.cpp | 28 
 utils/qvidcap/v4l2-convert.glsl  | 13 +
 2 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/utils/qvidcap/capture-win-gl.cpp b/utils/qvidcap/capture-win-gl.cpp
index 224c1340..04271e4c 100644
--- a/utils/qvidcap/capture-win-gl.cpp
+++ b/utils/qvidcap/capture-win-gl.cpp
@@ -86,6 +86,10 @@ const __u32 formats[] = {
V4L2_PIX_FMT_SGBRG12,
V4L2_PIX_FMT_SGRBG12,
V4L2_PIX_FMT_SRGGB12,
+   V4L2_PIX_FMT_SBGGR16,
+   V4L2_PIX_FMT_SGBRG16,
+   V4L2_PIX_FMT_SGRBG16,
+   V4L2_PIX_FMT_SRGGB16,
V4L2_PIX_FMT_HSV24,
V4L2_PIX_FMT_HSV32,
V4L2_PIX_FMT_GREY,
@@ -842,6 +846,10 @@ bool CaptureGLWin::updateV4LFormat(const cv4l_fmt )
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
m_is_bayer = true;
/* fall through */
case V4L2_PIX_FMT_GREY:
@@ -1625,6 +1633,10 @@ void CaptureGLWin::paintGL()
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
render_Bayer(m_v4l_fmt.g_pixelformat());
break;
 
@@ -1815,6 +1827,10 @@ static const struct define defines[] = {
DEF(V4L2_PIX_FMT_SGBRG12),
DEF(V4L2_PIX_FMT_SGRBG12),
DEF(V4L2_PIX_FMT_SRGGB12),
+   DEF(V4L2_PIX_FMT_SBGGR16),
+   DEF(V4L2_PIX_FMT_SGBRG16),
+   DEF(V4L2_PIX_FMT_SGRBG16),
+   DEF(V4L2_PIX_FMT_SRGGB16),
DEF(V4L2_PIX_FMT_HSV24),
DEF(V4L2_PIX_FMT_HSV32),
DEF(V4L2_PIX_FMT_GREY),
@@ -2025,6 +2041,10 @@ void CaptureGLWin::changeShader()
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
shader_Bayer();
break;
 
@@ -2272,6 +2292,10 @@ void CaptureGLWin::shader_Bayer()
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
glTexImage2D(GL_TEXTURE_2D, 0, GL_R16UI, m_v4l_fmt.g_width(), 
m_v4l_fmt.g_height(), 0,
 GL_RED_INTEGER, GL_UNSIGNED_SHORT, NULL);
break;
@@ -2611,6 +2635,10 @@ void CaptureGLWin::render_Bayer(__u32 format)
case V4L2_PIX_FMT_SGBRG12:
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
+   case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_v4l_fmt.g_width(), 
m_v4l_fmt.g_height(),
GL_RED_INTEGER, GL_UNSIGNED_SHORT, 
m_curData[0]);
break;
diff --git a/utils/qvidcap/v4l2-convert.glsl b/utils/qvidcap/v4l2-convert.glsl
index 6ca12d8d..81879562 100644
--- a/utils/qvidcap/v4l2-convert.glsl
+++ b/utils/qvidcap/v4l2-convert.glsl
@@ -5,6 +5,8 @@
 PIXFMT == V4L2_PIX_FMT_SGRBG10 || PIXFMT == V4L2_PIX_FMT_SRGGB10 || \
 PIXFMT == V4L2_PIX_FMT_SBGGR12 || PIXFMT == V4L2_PIX_FMT_SGBRG12 || \
 PIXFMT == V4L2_PIX_FMT_SGRBG12 || PIXFMT == V4L2_PIX_FMT_SRGGB12 || \
+PIXFMT == V4L2_PIX_FMT_SBGGR16 || PIXFMT == V4L2_PIX_FMT_SGBRG16 || \
+PIXFMT == V4L2_PIX_FMT_SGRBG16 || PIXFMT == V4L2_PIX_FMT_SRGGB16 || \
 PIXFMT == V4L2_PIX_FMT_GREY || PIXFMT == V4L2_PIX_FMT_Y16 || \
 PIXFMT == V4L2_PIX_FMT_Y16_BE || PIXFMT == V4L2_PIX_FMT_Z16 || \
 PIXFMT == V4L2_PIX_FMT_Y10 || PIXFMT == V4L2_PIX_FMT_Y12
@@ -112,25 +114,25 @@ void main()
 #if IS_RGB
 
 // Bayer pixel formats
-#if PIXFMT == V4L2_PIX_FMT_SBGGR8 || PIXFMT == V4L2_PIX_FMT_SBGGR10 || PIXFMT 
== V4L2_PIX_FMT_SBGGR12
+#if PIXFMT == V4L2_PIX_FMT_SBGGR8 || PIXFMT == V4L2_PIX_FMT_SBGGR10 || PIXFMT 
== V4L2_PIX_FMT_SBGGR12 || PIXFMT == V4L2_PIX_FMT_SBGGR16
uvec4 urgb;
vec2 cell = vec2(xeven ? xy.x : xy.x - texl_w, yeven ? xy.y : xy.y - 
texl_h);
urgb.r = texture(tex, vec2(cell.x + texl_w, cell.y + texl_h)).r;
urgb.g = texture(tex, vec2((cell.y == xy.y) ? cell.x + texl_w : cell.x, 
xy.y)).r;
urgb.b = texture(tex, cell).r;
-#elif PIXFMT == V4L2_PIX_FMT_SGBRG8 || PIXFMT == V4L2_PIX_FMT_SGBRG10 || 
PIXFMT == V4L2_PIX_FMT_SGBRG12
+#elif PIXFMT == V4L2_PIX_FMT_SGBRG8 || PIXFMT == V4L2_PIX_FMT_SGBRG10 || 

[PATCH 4/4] utils: Add qvidcap to configure status report

2018-10-08 Thread bwinther
From: Bård Eirik Winther 

Add missing build status flag for qvidcap to the configuration report

Signed-off-by: Bård Eirik Winther 
---
 configure.ac | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure.ac b/configure.ac
index 2765fbfc..90ef10aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -518,6 +518,7 @@ AM_COND_IF([WITH_DVBV5_REMOTE], [USE_DVBV5_REMOTE="yes"
 AM_COND_IF([WITH_DYN_LIBV4L], [USE_DYN_LIBV4L="yes"], [USE_DYN_LIBV4L="no"])
 AM_COND_IF([WITH_V4LUTILS], [USE_V4LUTILS="yes"], [USE_V4LUTILS="no"])
 AM_COND_IF([WITH_QV4L2], [USE_QV4L2="yes"], [USE_QV4L2="no"])
+AM_COND_IF([WITH_QVIDCAP], [USE_QVIDCAP="yes"], [USE_QVIDCAP="no"])
 AM_COND_IF([WITH_V4L_PLUGINS], [USE_V4L_PLUGINS="yes"
AC_DEFINE([HAVE_V4L_PLUGINS], [1], [V4L plugin 
support enabled])],
[USE_V4L_PLUGINS="no"])
@@ -566,6 +567,7 @@ compile time options summary
 dvbv5-daemon   : $USE_DVBV5_REMOTE
 v4lutils   : $USE_V4LUTILS
 qv4l2  : $USE_QV4L2
+qvidcap: $USE_QVIDCAP
 v4l2-ctl uses libv4l   : $USE_V4L2_CTL_LIBV4L
 v4l2-compliance uses libv4l: $USE_V4L2_COMPLIANCE_LIBV4L
 EOF
-- 
2.17.1



[PATCH 1/4] common: utils: Add last 3 16-bit bayer formats

2018-10-08 Thread bwinther
From: Bård Eirik Winther 

Add the remaining 16-bit bayer formats to rle_calc_bpl, namely:
  V4L2_PIX_FMT_SGBRG16
  V4L2_PIX_FMT_SGRBG16
  V4L2_PIX_FMT_SRGGB16

Signed-off-by: Bård Eirik Winther 
---
 utils/common/v4l-stream.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/utils/common/v4l-stream.c b/utils/common/v4l-stream.c
index 772de727..89f57379 100644
--- a/utils/common/v4l-stream.c
+++ b/utils/common/v4l-stream.c
@@ -51,6 +51,9 @@ unsigned rle_calc_bpl(unsigned bpl, __u32 pixelformat)
case V4L2_PIX_FMT_SGRBG12:
case V4L2_PIX_FMT_SRGGB12:
case V4L2_PIX_FMT_SBGGR16:
+   case V4L2_PIX_FMT_SGBRG16:
+   case V4L2_PIX_FMT_SGRBG16:
+   case V4L2_PIX_FMT_SRGGB16:
return 2 * bpl;
default:
return bpl;
-- 
2.17.1



[PATCH vicodec] media: pvrusb2: replace `printk` with `pr_*`

2018-10-08 Thread Dafna Hirschfeld
Replace calls to `printk` with the appropriate `pr_*`
macro.

Signed-off-by: Dafna Hirschfeld 
---
 drivers/media/usb/pvrusb2/pvrusb2-debug.h|  2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c  |  8 +++---
 drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c | 28 +---
 drivers/media/usb/pvrusb2/pvrusb2-main.c |  4 +--
 drivers/media/usb/pvrusb2/pvrusb2-v4l2.c |  4 +--
 5 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-debug.h 
b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
index 5cd16292e2fa..1323f949f454 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-debug.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-debug.h
@@ -17,7 +17,7 @@
 
 extern int pvrusb2_debug;
 
-#define pvr2_trace(msk, fmt, arg...) do {if(msk & pvrusb2_debug) 
printk(KERN_INFO "pvrusb2: " fmt "\n", ##arg); } while (0)
+#define pvr2_trace(msk, fmt, arg...) do {if (msk & pvrusb2_debug) 
pr_info("pvrusb2: " fmt "\n", ##arg); } while (0)
 
 /* These are listed in *rough* order of decreasing usefulness and
increasing noise level. */
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index a8519da0020b..7702285c1519 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -3293,12 +3293,12 @@ void pvr2_hdw_trigger_module_log(struct pvr2_hdw *hdw)
int nr = pvr2_hdw_get_unit_number(hdw);
LOCK_TAKE(hdw->big_lock);
do {
-   printk(KERN_INFO "pvrusb2: =  START STATUS CARD 
#%d  =\n", nr);
+   pr_info("pvrusb2: =  START STATUS CARD #%d  
=\n", nr);
v4l2_device_call_all(>v4l2_dev, 0, core, log_status);
pvr2_trace(PVR2_TRACE_INFO,"cx2341x config:");
cx2341x_log_status(>enc_ctl_state, "pvrusb2");
pvr2_hdw_state_log_state(hdw);
-   printk(KERN_INFO "pvrusb2: ==  END STATUS CARD 
#%d  ==\n", nr);
+   pr_info("pvrusb2: ==  END STATUS CARD #%d  
==\n", nr);
} while (0);
LOCK_GIVE(hdw->big_lock);
 }
@@ -4851,7 +4851,7 @@ static void pvr2_hdw_state_log_state(struct pvr2_hdw *hdw)
for (idx = 0; ; idx++) {
ccnt = pvr2_hdw_report_unlocked(hdw,idx,buf,sizeof(buf));
if (!ccnt) break;
-   printk(KERN_INFO "%s %.*s\n",hdw->name,ccnt,buf);
+   pr_info("%s %.*s\n", hdw->name, ccnt, buf);
}
ccnt = pvr2_hdw_report_clients(hdw, buf, sizeof(buf));
if (ccnt >= sizeof(buf))
@@ -4863,7 +4863,7 @@ static void pvr2_hdw_state_log_state(struct pvr2_hdw *hdw)
while ((lcnt + ucnt < ccnt) && (buf[lcnt + ucnt] != '\n')) {
lcnt++;
}
-   printk(KERN_INFO "%s %.*s\n", hdw->name, lcnt, buf + ucnt);
+   pr_info("%s %.*s\n", hdw->name, lcnt, buf + ucnt);
ucnt += lcnt + 1;
}
 }
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c 
b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
index ec7d32759e39..8f023085c2d9 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-i2c-core.c
@@ -478,8 +478,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
unsigned int idx,offs,cnt;
for (idx = 0; idx < num; idx++) {
cnt = msgs[idx].len;
-   printk(KERN_INFO
-  "pvrusb2 i2c xfer %u/%u: addr=0x%x len=%d %s",
+   pr_info("pvrusb2 i2c xfer %u/%u: addr=0x%x len=%d %s",
   idx+1,num,
   msgs[idx].addr,
   cnt,
@@ -487,22 +486,21 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
"read" : "write"));
if ((ret > 0) || !(msgs[idx].flags & I2C_M_RD)) {
if (cnt > 8) cnt = 8;
-   printk(KERN_CONT " [");
+   pr_cont(" [");
for (offs = 0; offs < cnt; offs++) {
-   if (offs) printk(KERN_CONT " ");
-   printk(KERN_CONT 
"%02x",msgs[idx].buf[offs]);
+   if (offs) pr_cont(" ");
+   pr_cont("%02x", msgs[idx].buf[offs]);
}
-   if (offs < cnt) printk(KERN_CONT " ...");
-   printk(KERN_CONT "]");
+   if (offs < cnt) pr_cont(" ...");
+   pr_cont("]");
}
if (idx+1 == num) {
-   printk(KERN_CONT " result=%d",ret);
+   

[RFC] Informal meeting during ELCE to discuss userspace support for stateless codecs

2018-10-08 Thread Hans Verkuil
Hi all,

I would like to meet up somewhere during the ELCE to discuss userspace support
for stateless (and perhaps stateful as well?) codecs.

It is also planned as a topic during the summit, but I would prefer to prepare
for that in advance, esp. since I myself do not have any experience writing
userspace SW for such devices.

Nicolas, it would be really great if you can participate in this meeting
since you probably have the most experience with this by far.

Looking through the ELCE program I found two timeslots that are likely to work
for most of us (because the topics in the program appear to be boring for us
media types!):

Tuesday from 10:50-15:50

or:

Monday from 15:45 onward

My guess is that we need 2-3 hours or so. Hard to predict.

The basic question that I would like to have answered is what the userspace
component should look like? libv4l-like plugin or a library that userspace can
link with? Do we want more general support for stateful codecs as well that 
deals
with resolution changes and the more complex parts of the codec API?

I've mailed this directly to those that I expect are most interested in this,
but if someone want to join in let me know.

I want to keep the group small though, so you need to bring relevant experience
to the table.

Regards,

Hans


Re: [PATCH v2 1/6] media: video-i2c: avoid accessing released memory area when removing driver

2018-10-08 Thread Hans Verkuil
On 10/05/2018 04:59 PM, Akinobu Mita wrote:
> 2018年10月5日(金) 18:36 Sakari Ailus :
>>
>> Hi Hans,
>>
>> On Mon, Oct 01, 2018 at 11:40:00AM +0200, Hans Verkuil wrote:
>>> On 09/23/2018 06:34 PM, Akinobu Mita wrote:
 The video_i2c_data is allocated by kzalloc and released by the video
 device's release callback.  The release callback is called when
 video_unregister_device() is called, but it will still be accessed after
 calling video_unregister_device().

 Fix the use after free by allocating video_i2c_data by devm_kzalloc() with
 i2c_client->dev so that it will automatically be released when the i2c
 driver is removed.
>>>
>>> Hmm. The patch is right, but the explanation isn't. The core problem is
>>> that vdev.release was set to video_i2c_release, but that should only be
>>> used if struct video_device was kzalloc'ed. But in this case it is embedded
>>> in a larger struct, and then vdev.release should always be set to
>>> video_device_release_empty.
>>
>> When the driver is unbound, what's acquired using the devm_() family of
>> functions is released. At the same time, the user still holds a file
>> handle, and can issue IOCTLs --- but the device's data structures no longer
>> exist.
>>
>> That's not ok, and also the reason why we have the release callback.
>>
>> While there are issues elsewhere, this bit of the V4L2 / MC frameworks is
>> fine.
>>
>> Or am I missing something?
> 
> How about moving the lines causing use-after-free to release callback
> like below?
> 
> static void video_i2c_release(struct video_device *vdev)
> {
> struct video_i2c_data *data = video_get_drvdata(vdev);
> 
> v4l2_device_unregister(>v4l2_dev);
> mutex_destroy(>lock);
> mutex_destroy(>queue_lock);
> kfree(data);
> }
> 

You can test this with v4l2-ctl:

v4l2-ctl --sleep 10

This sleeps 10s, then calls QUERYCAP and closes the file handle.

In another shell you can unbind the driver while v4l2-ctl is sleeping.

Hopefully this works without crashing anything :-)

Regards,

Hans


Re: [PATCH v5] media: docs: add glossary.rst with common terms used at V4L2 spec

2018-10-08 Thread Hans Verkuil
On 10/04/2018 05:03 PM, Mauro Carvalho Chehab wrote:
> From: Mauro Carvalho Chehab 
> 
> Add a glossary of terms used within the media userspace API
> documentation, as several concepts are complex enough to cause
> misunderstandings.
> 
> Signed-off-by: Mauro Carvalho Chehab 

With the understanding that this is a work in progress:

Acked-by: Hans Verkuil 

There are always things that can be improved/added, but let's not postpone
this any longer. A glossary is useful to have, even if incomplete/imperfect.

Regards,

Hans

> ---
>  Documentation/media/media_uapi.rst|   3 +
>  Documentation/media/uapi/glossary.rst | 185 ++
>  2 files changed, 188 insertions(+)
>  create mode 100644 Documentation/media/uapi/glossary.rst
> 
> diff --git a/Documentation/media/media_uapi.rst 
> b/Documentation/media/media_uapi.rst
> index 28eb35a1f965..41f091a26003 100644
> --- a/Documentation/media/media_uapi.rst
> +++ b/Documentation/media/media_uapi.rst
> @@ -2,6 +2,8 @@
>  
>  .. include:: 
>  
> +.. _media_uapi:
> +
>  
>  Linux Media Infrastructure userspace API
>  
> @@ -31,3 +33,4 @@ License".
>  uapi/cec/cec-api
>  uapi/gen-errors
>  uapi/fdl-appendix
> +uapi/glossary
> diff --git a/Documentation/media/uapi/glossary.rst 
> b/Documentation/media/uapi/glossary.rst
> new file mode 100644
> index ..1dce36707509
> --- /dev/null
> +++ b/Documentation/media/uapi/glossary.rst
> @@ -0,0 +1,185 @@
> +.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-or-later
> +
> +.. For GPL-2.0, see LICENSES/preferred/GPL-2.0
> +..
> +.. For GFDL-1.1-or-later, see:
> +..
> +.. Permission is granted to copy, distribute and/or modify this document
> +.. under the terms of the GNU Free Documentation License, Version 1.1 or
> +.. any later version published by the Free Software Foundation, with no
> +.. Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.
> +.. A copy of the license is included at
> +.. Documentation/media/uapi/fdl-appendix.rst.
> +
> +
> +Glossary
> +
> +
> +.. note::
> +
> +   This goal of this section is to standardize the terms used within the 
> media
> +   userspace API documentation. It is written incrementally as they are
> +   standardized in the media documentation.
> +
> +   So, it is a Work In Progress.
> +
> +.. Please keep the glossary entries in alphabetical order
> +
> +.. glossary::
> +
> +Bridge Driver
> + A :term:`device driver` that implements the main logic to talk with
> + media hardware.
> +
> +CEC API
> + **Consumer Electronics Control API**
> +
> + An API designed to receive and transmit data via an HDMI
> + CEC interface.
> +
> + See :ref:`cec`.
> +
> +Device Driver
> + Part of the Linux Kernel that implements support for a hardware
> + component.
> +
> +Device Node
> + A character device node in the file system used to control and
> + ransfer data in and out of a Kernel driver.
> +
> +Digital TV API
> + **Previously known as DVB API**
> +
> + An API designed to control a subset of the :term:`Media Hardware`
> + that implements digital TV.
> +
> + See :ref:`dvbapi`.
> +
> +DSP
> +**Digital Signal Processor**
> +
> + A specialized :term:`Microprocessor`, with its architecture
> + optimized for the operational needs of digital signal processing.
> +
> +FPGA
> + **Field-programmable Gate Array**
> +
> + An :term:`IC` circuit designed to be configured by a customer or
> + a designer after manufacturing.
> +
> + See https://en.wikipedia.org/wiki/Field-programmable_gate_array.
> +
> +I²C
> + **Inter-Integrated Circuit**
> +
> + A  multi-master, multi-slave, packet switched, single-ended,
> + serial computer bus used to control some hardware components
> + like sub-device hardware components.
> +
> + See http://www.nxp.com/docs/en/user-guide/UM10204.pdf.
> +
> +IC
> + **Integrated circuit**
> +
> + A set of electronic circuits on one small flat piece of
> + semiconductor material, normally silicon.
> +
> + Also known as chip.
> +
> +IP Block
> + **Intellectual property core**
> +
> + In electronic design a semiconductor intellectual property core,
> + is a reusable unit of logic, cell, or integrated circuit layout
> + design that is the intellectual property of one party.
> + IP Blocks may be licensed to another party or can be owned
> + and used by a single party alone.
> +
> + See 
> https://en.wikipedia.org/wiki/Semiconductor_intellectual_property_core).
> +
> +ISP
> + **Image Signal Processor**
> +
> + A specialized processor that implements a set of algorithms for
> + processing image data. ISPs may implement algorithms for lens
> + shading correction, demosaicing, scaling and pixel format conversion
> + as well as produce 

Re: [PATCH -next] media: imx-pxp: remove duplicated include from imx-pxp.c

2018-10-08 Thread Philipp Zabel
On Sat, 2018-10-06 at 07:36 +, YueHaibing wrote:
> Remove duplicated include.
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/media/platform/imx-pxp.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/platform/imx-pxp.c 
> b/drivers/media/platform/imx-pxp.c
> index b76cd0e..229c23a 100644
> --- a/drivers/media/platform/imx-pxp.c
> +++ b/drivers/media/platform/imx-pxp.c
> @@ -16,7 +16,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 

This reverts a41d203a1d34, which was a duplicate of already applied
b4fbf423cef9: https://patchwork.linuxtv.org/patch/52243/

Acked-by: Philipp Zabel 

regards
Philipp