cron job: media_tree daily build: ERRORS

2017-08-27 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:   Mon Aug 28 05:00:16 CEST 2017
media-tree git hash:9a45bf28bc39ff6ed45a008f7201289c8e9e60a6
media_build git hash:   96c1c79a9847387da3e8f51c1230b3118eed3ea6
v4l-utils git hash: 5a6e0c38468c629f3f6f4fb988acebb9e66e2917
gcc version:i686-linux-gcc (GCC) 7.1.0
sparse version: v0.5.0
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.12.0-164

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-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-3.0.60-i686: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.12.67-i686: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.7-i686: ERRORS
linux-3.19-i686: ERRORS
linux-4.0.9-i686: ERRORS
linux-4.1.33-i686: ERRORS
linux-4.2.8-i686: ERRORS
linux-4.3.6-i686: ERRORS
linux-4.4.22-i686: ERRORS
linux-4.5.7-i686: ERRORS
linux-4.6.7-i686: ERRORS
linux-4.7.5-i686: ERRORS
linux-4.8-i686: ERRORS
linux-4.9.26-i686: ERRORS
linux-4.10.14-i686: OK
linux-4.11-i686: OK
linux-4.12.1-i686: OK
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.60-x86_64: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.12.67-x86_64: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.7-x86_64: ERRORS
linux-3.19-x86_64: ERRORS
linux-4.0.9-x86_64: ERRORS
linux-4.1.33-x86_64: ERRORS
linux-4.2.8-x86_64: ERRORS
linux-4.3.6-x86_64: ERRORS
linux-4.4.22-x86_64: ERRORS
linux-4.5.7-x86_64: ERRORS
linux-4.6.7-x86_64: ERRORS
linux-4.7.5-x86_64: ERRORS
linux-4.8-x86_64: ERRORS
linux-4.9.26-x86_64: ERRORS
linux-4.10.14-x86_64: WARNINGS
linux-4.11-x86_64: WARNINGS
linux-4.12.1-x86_64: WARNINGS
apps: WARNINGS
spec-git: OK

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/index.html


Re: [PATCH v2] device property: preserve usecount for node passed to of_fwnode_graph_get_port_parent()

2017-08-27 Thread Sakari Ailus
Hi Rob,

On Tue, Aug 22, 2017 at 02:42:10PM -0500, Rob Herring wrote:
> On Tue, Aug 22, 2017 at 10:00 AM, Niklas Söderlund
>  wrote:
> > Hi Rob,
> >
> > On 2017-08-22 09:49:35 -0500, Rob Herring wrote:
> >> On Mon, Aug 21, 2017 at 7:19 PM, Niklas Söderlund
> >>  wrote:
> >> > Using CONFIG_OF_DYNAMIC=y uncovered an imbalance in the usecount of the
> >> > node being passed to of_fwnode_graph_get_port_parent(). Preserve the
> >> > usecount by using of_get_parent() instead of of_get_next_parent() which
> >> > don't decrement the usecount of the node passed to it.
> >> >
> >> > Fixes: 3b27d00e7b6d7c88 ("device property: Move fwnode graph ops to 
> >> > firmware specific locations")
> >> > Signed-off-by: Niklas Söderlund 
> >> > Acked-by: Sakari Ailus 
> >> > ---
> >> >  drivers/of/property.c | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> Isn't this already fixed with this fix:
> >>
> >> commit c0a480d1acf7dc184f9f3e7cf724483b0d28dc2e
> >> Author: Tony Lindgren 
> >> Date:   Fri Jul 28 01:23:15 2017 -0700
> >>
> >> device property: Fix usecount for of_graph_get_port_parent()
> >
> > No, that commit fixes it for of_graph_get_port_parent() while this
> > commit fixes it for of_fwnode_graph_get_port_parent(). But in essence it
> > is the same issue but needs two separate fixes.
> 
> Ah, because one takes the port node and one takes the endpoint node.
> That won't confuse anyone.

Yes, I think we've had this for some time in naming of a few graph
functions and increasingly so lately. It began with
of_graph_get_remote_port_parent(), which likely was named so to avoid the
name getting really long. The function itself gets a remove of the endpoint
given as an argument, then the port related to the entpoint and finally the
parent node of the port node (which is not the "ports" node). That's a lot
of work for a single interface function.

What comes to of_fwnode_graph_get_port_parent() --- it's the OF callback
function for the fwnode graph API that, as the name suggests, gets the
parent of the port node, no more, no less. The function is used in the
fwnode graph API implementation and is not available in the API as such.
The fwnode graph API itself only implements functionality already available
in the OF graph API under the corresponding name.

> 
> Can we please align this mess. I've tried to make the graph parsing
> not a free for all, open coded mess. There's no reason to have the
> port node handle and then need the parent device. Either you started
> with the parent device to parse local ports and endpoints or you got
> the remote endpoint with .graph_get_remote_endpoint(). Most of the
> time you don't even need the endpoint node handles. You really just
> need to know what is the remote device connected to port X, endpoint Y
> of my local device.

Perhaps most of the time, yes. V4L2 devices store bus (e.g. MIPI CSI-2)
specific information in the endpoint nodes.

The current OF graph API is geared towards providing convenience functions
to the extent that a single function performs actions a driver would
typically need. More recently functions implementing a single operation has
been added; the primitives that just perform a single operation would
likely be easier to manage.

The convenience functions have been, well, convenient as getting and
putting nodes could have been somewhat ignored in drivers. If the OF graph
API usage can be moved out of the drivers we'll likely have way fewer users
and thus there's no real need for convenience functions. That has other
benefits, too, such as parsing the graph correctly: most V4L2 drivers have
issues in this area.

The OF graph API (or the fwnode equivalent) is used effectively in all V4L2
drivers that support OF (there are about 20 of them); we're moving these to
the V4L2 framework but it'll take some time. That should make it easier for
cleaning things up. Based on a quick look V4L2 and V4L2 drivers together
represent a large proportion of all users in the kernel.

What do you think?

-- 
Kind regards,

Sakari Ailus
sakari.ai...@linux.intel.com


Re: [PATCH] v4l: use struct v4l2_buffer explicitly instead of void *

2017-08-27 Thread Mauro Carvalho Chehab
Em Fri, 28 Jul 2017 14:45:37 +0200 (CEST)
Guennadi Liakhovetski  escreveu:

> A number of functions use void * for a struct v4l2_buffer parameter.
> Avoid that to improve compile-time checking.

Nack.

The videbuf2-core should be be independent of videobuf2-v4l2. The
plan is to use it for DVB too. There's a patch floating around,
lacking people to take a look.

I intend to review and merge it when I have some time along
the year.

> 
> Signed-off-by: Guennadi Liakhovetski 
> ---
> 
> This probably was done on purpose, maybe to reuse the video buffers by 
> other than V4L2 users, but I haven't found any, and the code doesn't seem 
> very new...
> 
>  drivers/media/v4l2-core/videobuf2-core.c | 17 +
>  drivers/media/v4l2-core/videobuf2-v4l2.c | 15 +++
>  include/media/videobuf2-core.h   | 19 ---
>  3 files changed, 28 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
> b/drivers/media/v4l2-core/videobuf2-core.c
> index 14f83cec..170a416 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -958,7 +958,7 @@ void vb2_discard_done(struct vb2_queue *q)
>  /**
>   * __prepare_mmap() - prepare an MMAP buffer
>   */
> -static int __prepare_mmap(struct vb2_buffer *vb, const void *pb)
> +static int __prepare_mmap(struct vb2_buffer *vb, const struct v4l2_buffer 
> *pb)
>  {
>   int ret = 0;
>  
> @@ -971,7 +971,7 @@ static int __prepare_mmap(struct vb2_buffer *vb, const 
> void *pb)
>  /**
>   * __prepare_userptr() - prepare a USERPTR buffer
>   */
> -static int __prepare_userptr(struct vb2_buffer *vb, const void *pb)
> +static int __prepare_userptr(struct vb2_buffer *vb, const struct v4l2_buffer 
> *pb)
>  {
>   struct vb2_plane planes[VB2_MAX_PLANES];
>   struct vb2_queue *q = vb->vb2_queue;
> @@ -1089,7 +1089,7 @@ static int __prepare_userptr(struct vb2_buffer *vb, 
> const void *pb)
>  /**
>   * __prepare_dmabuf() - prepare a DMABUF buffer
>   */
> -static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb)
> +static int __prepare_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer 
> *pb)
>  {
>   struct vb2_plane planes[VB2_MAX_PLANES];
>   struct vb2_queue *q = vb->vb2_queue;
> @@ -1236,7 +1236,7 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
>   call_void_vb_qop(vb, buf_queue, vb);
>  }
>  
> -static int __buf_prepare(struct vb2_buffer *vb, const void *pb)
> +static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *pb)
>  {
>   struct vb2_queue *q = vb->vb2_queue;
>   unsigned int plane;
> @@ -1279,7 +1279,8 @@ static int __buf_prepare(struct vb2_buffer *vb, const 
> void *pb)
>   return 0;
>  }
>  
> -int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)
> +int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index,
> +  struct v4l2_buffer *pb)
>  {
>   struct vb2_buffer *vb;
>   int ret;
> @@ -1514,7 +1515,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, 
> int nonblocking)
>   * Will sleep if required for nonblocking == false.
>   */
>  static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb,
> -  void *pb, int nonblocking)
> +  struct v4l2_buffer *pb, int nonblocking)
>  {
>   unsigned long flags;
>   int ret = 0;
> @@ -1583,8 +1584,8 @@ static void __vb2_dqbuf(struct vb2_buffer *vb)
>   }
>  }
>  
> -int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex, void *pb,
> -bool nonblocking)
> +int vb2_core_dqbuf(struct vb2_queue *q, unsigned int *pindex,
> +struct v4l2_buffer *pb, bool nonblocking)
>  {
>   struct vb2_buffer *vb = NULL;
>   int ret;
> diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c 
> b/drivers/media/v4l2-core/videobuf2-v4l2.c
> index 0c06699..3c425ea 100644
> --- a/drivers/media/v4l2-core/videobuf2-v4l2.c
> +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c
> @@ -53,7 +53,8 @@
>   * __verify_planes_array() - verify that the planes array passed in struct
>   * v4l2_buffer from userspace can be safely used
>   */
> -static int __verify_planes_array(struct vb2_buffer *vb, const struct 
> v4l2_buffer *b)
> +static int __verify_planes_array(struct vb2_buffer *vb,
> +  const struct v4l2_buffer *b)
>  {
>   if (!V4L2_TYPE_IS_MULTIPLANAR(b->type))
>   return 0;
> @@ -73,7 +74,8 @@ static int __verify_planes_array(struct vb2_buffer *vb, 
> const struct v4l2_buffer
>   return 0;
>  }
>  
> -static int __verify_planes_array_core(struct vb2_buffer *vb, const void *pb)
> +static int __verify_planes_array_core(struct vb2_buffer *vb,
> +   const struct v4l2_buffer *pb)
>  {
>   return __verify_planes_array(vb, pb);
>  }
> @@ -118,9 +120,8 @@ static int 

Re: [PATCH] staging: atomisp: constify v4l2_subdev_sensor_ops

2017-08-27 Thread Sakari Ailus
Hi Arvind,

On Sun, Aug 27, 2017 at 11:26:39AM +0530, Arvind Yadav wrote:
> v4l2_subdev_sensor_ops are not supposed to change at runtime.
> v4l2_subdev_sensor_ops are working with const 'sensor' field of
> sturct v4l2_subdev_ops. So mark the non-const v4l2_subdev_sensor_ops
> structs as const.
> 
> Signed-off-by: Arvind Yadav 

Thanks for the patch. The change has already been made by this patch:

commit 65058214f5c2ebe844916b92d1bece64fd00206e
Author: Julia Lawall 
Date:   Tue Aug 8 06:58:29 2017 -0400

media: staging: media: atomisp: constify video_subdev structures

These structures are both stored in fields of v4l2_subdev_ops
structures, all of which are const, so these structures can be
const as well.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall 
Signed-off-by: Mauro Carvalho Chehab 

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


[PATCH 1/4] [media] max2175: Propagate the real error on devm_clk_get() failure

2017-08-27 Thread Fabio Estevam
From: Fabio Estevam 

When devm_clk_get() fails we should return the real error code
instead of always returning -ENODEV.

This allows defer probe to happen in the case the clock provider has
not been enabled by the time max2175 driver gets probed.

Signed-off-by: Fabio Estevam 
---
 drivers/media/i2c/max2175.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/max2175.c b/drivers/media/i2c/max2175.c
index a4736a8..bf0e821 100644
--- a/drivers/media/i2c/max2175.c
+++ b/drivers/media/i2c/max2175.c
@@ -1319,7 +1319,7 @@ static int max2175_probe(struct i2c_client *client,
if (IS_ERR(clk)) {
ret = PTR_ERR(clk);
dev_err(>dev, "cannot get clock %d\n", ret);
-   return -ENODEV;
+   return ret;
}
 
regmap = devm_regmap_init_i2c(client, _regmap_config);
-- 
2.7.4



[PATCH 3/4] [media] ov2640: Propagate the real error on devm_clk_get() failure

2017-08-27 Thread Fabio Estevam
From: Fabio Estevam 

devm_clk_get() may return different error codes other than -EPROBE_DEFER,
so it is better to return the real error code instead.

Signed-off-by: Fabio Estevam 
---
 drivers/media/i2c/ov2640.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c
index e6d0c1f..e6cbe01 100644
--- a/drivers/media/i2c/ov2640.c
+++ b/drivers/media/i2c/ov2640.c
@@ -1107,7 +1107,7 @@ static int ov2640_probe(struct i2c_client *client,
if (client->dev.of_node) {
priv->clk = devm_clk_get(>dev, "xvclk");
if (IS_ERR(priv->clk))
-   return -EPROBE_DEFER;
+   return PTR_ERR(priv->clk);
clk_prepare_enable(priv->clk);
}
 
-- 
2.7.4



[PATCH 2/4] [media] mt9m111: Propagate the real error on v4l2_clk_get() failure

2017-08-27 Thread Fabio Estevam
From: Fabio Estevam 

v4l2_clk_get() may return different error codes other than -EPROBE_DEFER,
so it is better to return the real error code instead.

Signed-off-by: Fabio Estevam 
---
 drivers/media/i2c/mt9m111.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 99b992e..b1665d9 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -945,7 +945,7 @@ static int mt9m111_probe(struct i2c_client *client,
 
mt9m111->clk = v4l2_clk_get(>dev, "mclk");
if (IS_ERR(mt9m111->clk))
-   return -EPROBE_DEFER;
+   return PTR_ERR(mt9m111->clk);
 
/* Default HIGHPOWER context */
mt9m111->ctx = _b;
-- 
2.7.4



[PATCH 4/4] [media] ov2640: Check the return value from clk_prepare_enable()

2017-08-27 Thread Fabio Estevam
From: Fabio Estevam 

clk_prepare_enable() may fail, so we should better check its return value
and propagate it in the case of error.

Signed-off-by: Fabio Estevam 
---
 drivers/media/i2c/ov2640.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c
index e6cbe01..5f013c8 100644
--- a/drivers/media/i2c/ov2640.c
+++ b/drivers/media/i2c/ov2640.c
@@ -1108,7 +1108,9 @@ static int ov2640_probe(struct i2c_client *client,
priv->clk = devm_clk_get(>dev, "xvclk");
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
-   clk_prepare_enable(priv->clk);
+   ret = clk_prepare_enable(priv->clk);
+   if (ret)
+   return ret;
}
 
ret = ov2640_probe_dt(client, priv);
-- 
2.7.4



Re: [PATCH v3 14/14] [media] cxd2880 : Update MAINTAINERS file for CXD2880 driver

2017-08-27 Thread Mauro Carvalho Chehab
Em Wed, 16 Aug 2017 17:02:05 +0900
"Takiguchi, Yasunari"  escreveu:

> From: Yasunari Takiguchi 
> 
> I add an e-mail address and re-send this mail again.
> 
> This is MAINTAINERS file update about the driver for
> the Sony CXD2880 DVB-T2/T tuner + demodulator.

Patches 12-14 look OK to me (although I didn't try to compile).

You can likely fold them into a single patch adding an entry to 
MAINTAINERS and the driver to Kconfig/Makefile.

Regards,
Mauro

> 
> [Change list]
> Changes in V3
>MAINTAINERS
>   -no change
> 
> Signed-off-by: Yasunari Takiguchi 
> Signed-off-by: Masayuki Yamamoto 
> Signed-off-by: Hideki Nozawa 
> Signed-off-by: Kota Yonezawa 
> Signed-off-by: Toshihiko Matsumoto 
> Signed-off-by: Satoshi Watanabe 
> ---
>  MAINTAINERS | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6f7721d1634c..12a80c33c194 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8302,6 +8302,15 @@ T: git git://linuxtv.org/media_tree.git
>  S:   Supported
>  F:   drivers/media/dvb-frontends/cxd2841er*
>  
> +MEDIA DRIVERS FOR CXD2880
> +M:   Yasunari Takiguchi 
> +L:   linux-media@vger.kernel.org
> +W:   http://linuxtv.org/
> +T:   git git://linuxtv.org/media_tree.git
> +S:   Supported
> +F:   drivers/media/dvb-frontends/cxd2880/*
> +F:   drivers/media/spi/cxd2880*
> +
>  MEDIA DRIVERS FOR FREESCALE IMX
>  M:   Steve Longerbeam 
>  M:   Philipp Zabel 



Thanks,
Mauro


Re: [PATCH v3 11/14] [media] cxd2880: Add DVB-T2 monitor and integration layer functions

2017-08-27 Thread Mauro Carvalho Chehab
Em Wed, 16 Aug 2017 13:43:41 +0900
 escreveu:

> From: Yasunari Takiguchi 
> 
> Provide monitor and integration layer functions (DVB-T2)
> for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.
> 
> [Change list]
> Changes in V3
>drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
>   -changed CXD2880_SLEEP to usleep_range
>   -replaced cxd2880_atomic_set to atomic_set
>   -modified return code
>   -modified coding style of if()  
>drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h
>   -modified return code
>   -changed hexadecimal code to lower case. 
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.c
>   -removed unnecessary cast
>   -changed cxd2880_math_log to intlog10
>   -modified return code
>   -modified coding style of if() 
>   -changed hexadecimal code to lower case. 
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.h
>   -modified return code
> 
> Signed-off-by: Yasunari Takiguchi 
> Signed-off-by: Masayuki Yamamoto 
> Signed-off-by: Hideki Nozawa 
> Signed-off-by: Kota Yonezawa 
> Signed-off-by: Toshihiko Matsumoto 
> Signed-off-by: Satoshi Watanabe 
> ---
>  .../dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c|  312 +++
>  .../dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h|   64 +
>  .../cxd2880/cxd2880_tnrdmd_dvbt2_mon.c | 2622 
> 
>  .../cxd2880/cxd2880_tnrdmd_dvbt2_mon.h |  170 ++
>  4 files changed, 3168 insertions(+)
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.h
>  create mode 100644 
> drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.c
>  create mode 100644 
> drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2_mon.h
> 
> diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c 
> b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
> new file mode 100644
> index ..ac049820d797
> --- /dev/null
> +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt2.c
> @@ -0,0 +1,312 @@
> +/*
> + * cxd2880_integ_dvbt2.c
> + * Sony CXD2880 DVB-T2/T tuner + demodulator driver
> + * integration layer functions for DVB-T2
> + *
> + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
> + *
> + * 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; version 2 of the License.
> + *
> + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
> + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see .
> + */
> +
> +#include "cxd2880_tnrdmd_dvbt2.h"
> +#include "cxd2880_tnrdmd_dvbt2_mon.h"
> +#include "cxd2880_integ_dvbt2.h"
> +
> +static int dvbt2_wait_demod_lock(struct cxd2880_tnrdmd *tnr_dmd,
> +  enum cxd2880_dvbt2_profile
> +  profile);
> +
> +static int dvbt2_wait_l1_post_lock(struct cxd2880_tnrdmd *tnr_dmd);
> +
> +int cxd2880_integ_dvbt2_tune(struct cxd2880_tnrdmd *tnr_dmd,
> +  struct cxd2880_dvbt2_tune_param
> +  *tune_param)
> +{
> + int ret = 0;
> +
> + if ((!tnr_dmd) || (!tune_param))
> + return -EINVAL;
> +
> + if (tnr_dmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
> + return -EINVAL;
> +
> + if ((tnr_dmd->state != CXD2880_TNRDMD_STATE_SLEEP) &&
> + (tnr_dmd->state != CXD2880_TNRDMD_STATE_ACTIVE))
> + return -EPERM;
> +
> + atomic_set(_dmd->cancel, 0);
> +
> + if ((tune_param->bandwidth != CXD2880_DTV_BW_1_7_MHZ) &&
> + (tune_param->bandwidth != CXD2880_DTV_BW_5_MHZ) &&
> + (tune_param->bandwidth != CXD2880_DTV_BW_6_MHZ) &&
> + (tune_param->bandwidth != CXD2880_DTV_BW_7_MHZ) &&
> + (tune_param->bandwidth != CXD2880_DTV_BW_8_MHZ)) {
> + return 

Re: [PATCH v3 10/14] [media] cxd2880: Add DVB-T2 control functions for the driver

2017-08-27 Thread Mauro Carvalho Chehab
Em Wed, 16 Aug 2017 13:42:32 +0900
 escreveu:

> From: Yasunari Takiguchi 
> 
> Provide definitions, interfaces and functions needed for DVB-T2
> of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.
> 
> [Change list]
> Changes in V3
>drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
>   -changed hexadecimal code to lower case. 
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c
>   -modified return code
>   -modified coding style of if() 
>   -changed hexadecimal code to lower case. 
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h
>   -modified return code
> 
> Signed-off-by: Yasunari Takiguchi 
> Signed-off-by: Masayuki Yamamoto 
> Signed-off-by: Hideki Nozawa 
> Signed-off-by: Kota Yonezawa 
> Signed-off-by: Toshihiko Matsumoto 
> Signed-off-by: Satoshi Watanabe 
> ---
>  .../media/dvb-frontends/cxd2880/cxd2880_dvbt2.h|  402 ++
>  .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c   | 1359 
> 
>  .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h   |   82 ++
>  3 files changed, 1843 insertions(+)
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.c
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt2.h
> 
> diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h 
> b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
> new file mode 100644
> index ..674ed17deef5
> --- /dev/null
> +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt2.h
> @@ -0,0 +1,402 @@
> +/*
> + * cxd2880_dvbt2.h
> + * Sony CXD2880 DVB-T2/T tuner + demodulator driver
> + * DVB-T2 related definitions
> + *
> + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
> + *
> + * 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; version 2 of the License.
> + *
> + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
> + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see .
> + */
> +
> +#ifndef CXD2880_DVBT2_H
> +#define CXD2880_DVBT2_H
> +
> +#include "cxd2880_common.h"
> +
> +enum cxd2880_dvbt2_profile {
> + CXD2880_DVBT2_PROFILE_BASE,
> + CXD2880_DVBT2_PROFILE_LITE,
> + CXD2880_DVBT2_PROFILE_ANY
> +};
> +
> +enum cxd2880_dvbt2_version {
> + CXD2880_DVBT2_V111,
> + CXD2880_DVBT2_V121,
> + CXD2880_DVBT2_V131
> +};
> +
> +enum cxd2880_dvbt2_s1 {
> + CXD2880_DVBT2_S1_BASE_SISO = 0x00,
> + CXD2880_DVBT2_S1_BASE_MISO = 0x01,
> + CXD2880_DVBT2_S1_NON_DVBT2 = 0x02,
> + CXD2880_DVBT2_S1_LITE_SISO = 0x03,
> + CXD2880_DVBT2_S1_LITE_MISO = 0x04,
> + CXD2880_DVBT2_S1_RSVD3 = 0x05,
> + CXD2880_DVBT2_S1_RSVD4 = 0x06,
> + CXD2880_DVBT2_S1_RSVD5 = 0x07,
> + CXD2880_DVBT2_S1_UNKNOWN = 0xff
> +};
> +
> +enum cxd2880_dvbt2_base_s2 {
> + CXD2880_DVBT2_BASE_S2_M2K_G_ANY = 0x00,
> + CXD2880_DVBT2_BASE_S2_M8K_G_DVBT = 0x01,
> + CXD2880_DVBT2_BASE_S2_M4K_G_ANY = 0x02,
> + CXD2880_DVBT2_BASE_S2_M1K_G_ANY = 0x03,
> + CXD2880_DVBT2_BASE_S2_M16K_G_ANY = 0x04,
> + CXD2880_DVBT2_BASE_S2_M32K_G_DVBT = 0x05,
> + CXD2880_DVBT2_BASE_S2_M8K_G_DVBT2 = 0x06,
> + CXD2880_DVBT2_BASE_S2_M32K_G_DVBT2 = 0x07,
> + CXD2880_DVBT2_BASE_S2_UNKNOWN = 0xff
> +};
> +
> +enum cxd2880_dvbt2_lite_s2 {
> + CXD2880_DVBT2_LITE_S2_M2K_G_ANY = 0x00,
> + CXD2880_DVBT2_LITE_S2_M8K_G_DVBT = 0x01,
> + CXD2880_DVBT2_LITE_S2_M4K_G_ANY = 0x02,
> + CXD2880_DVBT2_LITE_S2_M16K_G_DVBT2 = 0x03,
> + CXD2880_DVBT2_LITE_S2_M16K_G_DVBT = 0x04,
> + CXD2880_DVBT2_LITE_S2_RSVD1 = 0x05,
> + CXD2880_DVBT2_LITE_S2_M8K_G_DVBT2 = 0x06,
> + CXD2880_DVBT2_LITE_S2_RSVD2 = 0x07,
> + CXD2880_DVBT2_LITE_S2_UNKNOWN = 0xff
> +};
> +
> +enum cxd2880_dvbt2_guard {
> + CXD2880_DVBT2_G1_32 = 0x00,
> + CXD2880_DVBT2_G1_16 = 0x01,
> 

Re: [PATCH v3 09/14] [media] cxd2880: Add DVB-T monitor and integration layer functions

2017-08-27 Thread Mauro Carvalho Chehab
Em Wed, 16 Aug 2017 13:41:42 +0900
 escreveu:

> From: Yasunari Takiguchi 
> 
> Provide monitor and integration layer functions (DVB-T)
> for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.
> 
> [Change list]
> Changes in V3
>drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
>   -changed CXD2880_SLEEP to usleep_range
>   -chnaged cxd2880_atomic_set to atomic_set
>   -modified return code
>   -modified coding style of if() 
>drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.h
>   -modified return code
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.c
>   -removed unnecessary cast
>   -changed cxd2880_math_log to intlog10
>   -changed hexadecimal code to lower case. 
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.h
>   -modified return code
> 
> Signed-off-by: Yasunari Takiguchi 
> Signed-off-by: Masayuki Yamamoto 
> Signed-off-by: Hideki Nozawa 
> Signed-off-by: Kota Yonezawa 
> Signed-off-by: Toshihiko Matsumoto 
> Signed-off-by: Satoshi Watanabe 
> ---
>  .../dvb-frontends/cxd2880/cxd2880_integ_dvbt.c |  198 
>  .../dvb-frontends/cxd2880/cxd2880_integ_dvbt.h |   58 +
>  .../cxd2880/cxd2880_tnrdmd_dvbt_mon.c  | 1227 
> 
>  .../cxd2880/cxd2880_tnrdmd_dvbt_mon.h  |  106 ++
>  4 files changed, 1589 insertions(+)
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.h
>  create mode 100644 
> drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.c
>  create mode 100644 
> drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt_mon.h
> 
> diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c 
> b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
> new file mode 100644
> index ..729cb0939203
> --- /dev/null
> +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_integ_dvbt.c
> @@ -0,0 +1,198 @@
> +/*
> + * cxd2880_integ_dvbt.c
> + * Sony CXD2880 DVB-T2/T tuner + demodulator driver
> + * integration layer functions for DVB-T
> + *
> + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
> + *
> + * 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; version 2 of the License.
> + *
> + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
> + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see .
> + */
> +
> +#include "cxd2880_tnrdmd_dvbt.h"
> +#include "cxd2880_integ_dvbt.h"
> +
> +static int dvbt_wait_demod_lock(struct cxd2880_tnrdmd *tnr_dmd);
> +
> +int cxd2880_integ_dvbt_tune(struct cxd2880_tnrdmd *tnr_dmd,
> + struct cxd2880_dvbt_tune_param
> + *tune_param)
> +{
> + int ret = 0;
> +
> + if ((!tnr_dmd) || (!tune_param))
> + return -EINVAL;
> +
> + if (tnr_dmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
> + return -EINVAL;
> +
> + if ((tnr_dmd->state != CXD2880_TNRDMD_STATE_SLEEP) &&
> + (tnr_dmd->state != CXD2880_TNRDMD_STATE_ACTIVE))
> + return -EPERM;
> +
> + atomic_set(_dmd->cancel, 0);
> +
> + if ((tune_param->bandwidth != CXD2880_DTV_BW_5_MHZ) &&
> + (tune_param->bandwidth != CXD2880_DTV_BW_6_MHZ) &&
> + (tune_param->bandwidth != CXD2880_DTV_BW_7_MHZ) &&
> + (tune_param->bandwidth != CXD2880_DTV_BW_8_MHZ)) {
> + return -EOPNOTSUPP;
> + }
> +
> + ret = cxd2880_tnrdmd_dvbt_tune1(tnr_dmd, tune_param);
> + if (ret)
> + return ret;
> +
> + usleep_range(CXD2880_TNRDMD_WAIT_AGC_STABLE * 1,
> +  CXD2880_TNRDMD_WAIT_AGC_STABLE * 1 + 1000);
> +
> + ret = cxd2880_tnrdmd_dvbt_tune2(tnr_dmd, tune_param);
> + if (ret)
> + return ret;
> +
> + ret = 

Re: [PATCH v3 08/14] [media] cxd2880: Add DVB-T control functions the driver

2017-08-27 Thread Mauro Carvalho Chehab
Em Wed, 16 Aug 2017 13:40:37 +0900
 escreveu:

> From: Yasunari Takiguchi 
> 
> Provide definitions, interfaces and functions needed for DVB-T
> of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.
> 
> [Change list]
> Changes in V3
>drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
>   -no change
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
>   -modified return code
>   -modified coding style of if() 
>   -changed hexadecimal code to lower case. 
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h
>   -modified return code
> 
> Signed-off-by: Yasunari Takiguchi 
> Signed-off-by: Masayuki Yamamoto 
> Signed-off-by: Hideki Nozawa 
> Signed-off-by: Kota Yonezawa 
> Signed-off-by: Toshihiko Matsumoto 
> Signed-off-by: Satoshi Watanabe 
> ---
>  drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h |   91 ++
>  .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c| 1115 
> 
>  .../dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h|   62 ++
>  3 files changed, 1268 insertions(+)
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.h
> 
> diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h 
> b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
> new file mode 100644
> index ..345c094760d2
> --- /dev/null
> +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dvbt.h
> @@ -0,0 +1,91 @@
> +/*
> + * cxd2880_dvbt.h
> + * Sony CXD2880 DVB-T2/T tuner + demodulator driver
> + * DVB-T related definitions
> + *
> + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
> + *
> + * 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; version 2 of the License.
> + *
> + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
> + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see .
> + */
> +
> +#ifndef CXD2880_DVBT_H
> +#define CXD2880_DVBT_H
> +
> +#include "cxd2880_common.h"
> +
> +enum cxd2880_dvbt_constellation {
> + CXD2880_DVBT_CONSTELLATION_QPSK,
> + CXD2880_DVBT_CONSTELLATION_16QAM,
> + CXD2880_DVBT_CONSTELLATION_64QAM,
> + CXD2880_DVBT_CONSTELLATION_RESERVED_3
> +};
> +
> +enum cxd2880_dvbt_hierarchy {
> + CXD2880_DVBT_HIERARCHY_NON,
> + CXD2880_DVBT_HIERARCHY_1,
> + CXD2880_DVBT_HIERARCHY_2,
> + CXD2880_DVBT_HIERARCHY_4
> +};
> +
> +enum cxd2880_dvbt_coderate {
> + CXD2880_DVBT_CODERATE_1_2,
> + CXD2880_DVBT_CODERATE_2_3,
> + CXD2880_DVBT_CODERATE_3_4,
> + CXD2880_DVBT_CODERATE_5_6,
> + CXD2880_DVBT_CODERATE_7_8,
> + CXD2880_DVBT_CODERATE_RESERVED_5,
> + CXD2880_DVBT_CODERATE_RESERVED_6,
> + CXD2880_DVBT_CODERATE_RESERVED_7
> +};
> +
> +enum cxd2880_dvbt_guard {
> + CXD2880_DVBT_GUARD_1_32,
> + CXD2880_DVBT_GUARD_1_16,
> + CXD2880_DVBT_GUARD_1_8,
> + CXD2880_DVBT_GUARD_1_4
> +};
> +
> +enum cxd2880_dvbt_mode {
> + CXD2880_DVBT_MODE_2K,
> + CXD2880_DVBT_MODE_8K,
> + CXD2880_DVBT_MODE_RESERVED_2,
> + CXD2880_DVBT_MODE_RESERVED_3
> +};
> +
> +enum cxd2880_dvbt_profile {
> + CXD2880_DVBT_PROFILE_HP = 0,
> + CXD2880_DVBT_PROFILE_LP
> +};
> +
> +struct cxd2880_dvbt_tpsinfo {
> + enum cxd2880_dvbt_constellation constellation;
> + enum cxd2880_dvbt_hierarchy hierarchy;
> + enum cxd2880_dvbt_coderate rate_hp;
> + enum cxd2880_dvbt_coderate rate_lp;
> + enum cxd2880_dvbt_guard guard;
> + enum cxd2880_dvbt_mode mode;
> + u8 fnum;
> + u8 length_indicator;
> + u16 cell_id;
> + u8 cell_id_ok;
> + u8 reserved_even;
> + u8 reserved_odd;
> +};
> +
> +#endif
> diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c 
> b/drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_dvbt.c

Re: [PATCH v3 07/14] [media] cxd2880: Add top level of the driver

2017-08-27 Thread Mauro Carvalho Chehab
Em Wed, 16 Aug 2017 13:39:45 +0900
 escreveu:

> From: Yasunari Takiguchi 
> 
> This provides the main dvb frontend operation functions
> for the Sony CXD2880 DVB-T2/T tuner + demodulator driver.
> 
> [Change list]
> Changes in V3
>drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
>   -adjusted indent spaces
>   -modified debugging code
>   -removed unnecessary cast
>   -modified return code
>   -modified coding style of if() 
>   -modified about measurement period of PER/BER.
>   -changed hexadecimal code to lower case. 
> 
> Signed-off-by: Yasunari Takiguchi 
> Signed-off-by: Masayuki Yamamoto 
> Signed-off-by: Hideki Nozawa 
> Signed-off-by: Kota Yonezawa 
> Signed-off-by: Toshihiko Matsumoto 
> Signed-off-by: Satoshi Watanabe 
> ---
>  drivers/media/dvb-frontends/cxd2880/cxd2880_top.c | 1879 
> +
>  1 file changed, 1879 insertions(+)
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
> 
> diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c 
> b/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
> new file mode 100644
> index ..306966dd186b
> --- /dev/null
> +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_top.c
> @@ -0,0 +1,1879 @@
> +/*
> + * cxd2880_top.c
> + * Sony CXD2880 DVB-T2/T tuner + demodulator driver
> + *
> + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
> + *
> + * 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; version 2 of the License.
> + *
> + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
> + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see .
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
> +
> +#include 
> +
> +#include "dvb_frontend.h"
> +#include "dvb_math.h"
> +
> +#include "cxd2880.h"
> +#include "cxd2880_tnrdmd_mon.h"
> +#include "cxd2880_tnrdmd_dvbt2_mon.h"
> +#include "cxd2880_tnrdmd_dvbt_mon.h"
> +#include "cxd2880_integ_dvbt2.h"
> +#include "cxd2880_integ_dvbt.h"
> +#include "cxd2880_devio_spi.h"
> +#include "cxd2880_spi_device.h"
> +#include "cxd2880_tnrdmd_driver_version.h"
> +
> +struct cxd2880_priv {
> + struct cxd2880_tnrdmd tnrdmd;
> + struct spi_device *spi;
> + struct cxd2880_io regio;
> + struct cxd2880_spi_device spi_device;
> + struct cxd2880_spi cxd2880_spi;
> + struct cxd2880_dvbt_tune_param dvbt_tune_param;
> + struct cxd2880_dvbt2_tune_param dvbt2_tune_param;
> + struct mutex *spi_mutex; /* For SPI access exclusive control */
> + unsigned long pre_ber_update;
> + unsigned long pre_ber_interval;
> + unsigned long post_ber_update;
> + unsigned long post_ber_interval;
> + unsigned long ucblock_update;
> + unsigned long ucblock_interval;
> +};
> +
> +static int cxd2880_pre_bit_err_t(
> + struct cxd2880_tnrdmd *tnrdmd, u32 *pre_bit_err,
> + u32 *pre_bit_count)
> +{
> + u8 rdata[2];
> + int ret = 0;
> +
> + if ((!tnrdmd) || (!pre_bit_err) || (!pre_bit_count))
> + return -EINVAL;
> +
> + if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB)
> + return -EINVAL;
> +
> + if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE)
> + return -EPERM;
> +
> + if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT)
> + return -EPERM;
> +
> + ret = slvt_freeze_reg(tnrdmd);
> + if (ret)
> + return ret;
> +
> + ret = tnrdmd->io->write_reg(tnrdmd->io,
> + CXD2880_IO_TGT_DMD,
> + 0x00, 0x10);
> + if (ret) {
> + slvt_unfreeze_reg(tnrdmd);
> + return ret;
> + }
> +
> + ret = tnrdmd->io->read_regs(tnrdmd->io,
> + CXD2880_IO_TGT_DMD,
> + 0x39, rdata, 1);
> + if (ret) {
> + 

Re: [PATCH v3 05/14] [media] cxd2880: Add tuner part of the driver

2017-08-27 Thread Mauro Carvalho Chehab
Em Sun, 27 Aug 2017 11:45:44 -0300
Mauro Carvalho Chehab  escreveu:

> Em Wed, 16 Aug 2017 13:37:14 +0900
>  escreveu:
> 
> > From: Yasunari Takiguchi 
> > 
> > This part of the driver has the main routines to handle
> > the tuner and demodulator functionality.  The tnrdmd_mon.* files
> > have monitor functions for the driver.
> > This is part of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.
> 
> This series is on a much better state. Thanks!
> 
> Patches 1-4 sound ok to me.
> 
> Still, there are a few issues on this patch. See below.
> 
> > 
> > [Change list]
> > Changes in V3
> >drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
> >   -removed code relevant to ISDB-T

Forgot to mention... Just a small detail: the change list is important for
us to understand the differences between submitted versions, but it makes
no sense to track them when patches get merged upstream, as the previous
versions of the patches won't be there at the git history.

So, please put change lists after a blank line with just "---", e. g.:


From: Yasunari Takiguchi 

This part of the driver has the main routines to handle
the tuner and demodulator functionality.  The tnrdmd_mon.* files
have monitor functions for the driver.
This is part of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

---

(change list and whatever other notes that are relevant to the
 patch reviewers but won't be merged upstream)

The reason is simple: Kernel maintainers' scripts will just remove
everything after the "---" line when applying the series ;-)

Thanks,
Mauro


Re: [PATCH v3 05/14] [media] cxd2880: Add tuner part of the driver

2017-08-27 Thread Mauro Carvalho Chehab
Em Wed, 16 Aug 2017 13:37:14 +0900
 escreveu:

> From: Yasunari Takiguchi 
> 
> This part of the driver has the main routines to handle
> the tuner and demodulator functionality.  The tnrdmd_mon.* files
> have monitor functions for the driver.
> This is part of the Sony CXD2880 DVB-T2/T tuner + demodulator driver.

This series is on a much better state. Thanks!

Patches 1-4 sound ok to me.

Still, there are a few issues on this patch. See below.

> 
> [Change list]
> Changes in V3
>drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
>   -removed code relevant to ISDB-T

Just curiosity here: why is it removed?

>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
>   -removed unnecessary cast
>   -removed code relevant to ISDB-T
>   -changed CXD2880_SLEEP to usleep_range
>   -changed cxd2880_memset to memset 
>   -changed cxd2880_atomic_set to atomic_set
>   -modified return code
>   -modified coding style of if()
>   -changed to use const values at writing a lot of registers 
>with a command. 
>   -changed hexadecimal code to lower case. 
>   -adjusted of indent spaces
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
>   -removed code relevant to ISDB-T
>   -changed cxd2880_atomic struct to atomic_t
>   -modified return code
>   -changed hexadecimal code to lower case. 
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
>   -updated version information
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
>   -changed CXD2880_SLEEP to usleep_range
>   -removed unnecessary cast
>   -modified return code
>   -modified coding style of if() 
>   -changed hexadecimal code to lower case. 
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h
>   -modified return code
> 
> Changes in V2
>drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
>   -updated version information
> 
> Signed-off-by: Yasunari Takiguchi 
> Signed-off-by: Masayuki Yamamoto 
> Signed-off-by: Hideki Nozawa 
> Signed-off-by: Kota Yonezawa 
> Signed-off-by: Toshihiko Matsumoto 
> Signed-off-by: Satoshi Watanabe 
> ---
>  drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h  |   46 +
>  .../media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c   | 4030 
> 
>  .../media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h   |  391 ++
>  .../cxd2880/cxd2880_tnrdmd_driver_version.h|   29 +
>  .../dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c |  221 ++
>  .../dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h |   52 +
>  6 files changed, 4769 insertions(+)
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.c
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd.h
>  create mode 100644 
> drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_driver_version.h
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.c
>  create mode 100644 drivers/media/dvb-frontends/cxd2880/cxd2880_tnrdmd_mon.h
> 
> diff --git a/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h 
> b/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
> new file mode 100644
> index ..2d35d3990060
> --- /dev/null
> +++ b/drivers/media/dvb-frontends/cxd2880/cxd2880_dtv.h
> @@ -0,0 +1,46 @@
> +/*
> + * cxd2880_dtv.h
> + * Sony CXD2880 DVB-T2/T tuner + demodulator driver
> + * DTV related definitions
> + *
> + * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
> + *
> + * 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; version 2 of the License.
> + *
> + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
> + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
> + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see .
> + */
> +
> +#ifndef CXD2880_DTV_H
> +#define CXD2880_DTV_H
> +
> +enum 

Re: [PATCH] [media] dvb-frontends/mxl5xx: fix lock check order

2017-08-27 Thread Daniel Scheller
Am Sun, 27 Aug 2017 09:18:07 -0300
schrieb Mauro Carvalho Chehab :

Thanks for looking at this.

> Em Sun, 20 Aug 2017 12:45:45 +0200
> Daniel Scheller  escreveu:
> 
> > From: Daniel Scheller 
> >   
> 
> Always add a description at the patch.

Sorry. Will remember to do so even for these rather self-explanatory
changes.

> > Signed-off-by: Daniel Scheller 
> > ---
> > When the mxl5xx driver together with the ddbridge glue gets merged
> > ([1]), this one should go in aswell - this fix is part of the
> > dddvb-0.9.31 release.
> > 
> >  drivers/media/dvb-frontends/mxl5xx.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/dvb-frontends/mxl5xx.c
> > b/drivers/media/dvb-frontends/mxl5xx.c index
> > 676c96c216c3..d9136d67f5d4 100644 ---
> > a/drivers/media/dvb-frontends/mxl5xx.c +++
> > b/drivers/media/dvb-frontends/mxl5xx.c @@ -638,13 +638,14 @@ static
> > int tune(struct dvb_frontend *fe, bool re_tune, state->tune_time =
> > jiffies; return 0;
> > }
> > -   if (*status & FE_HAS_LOCK)
> > -   return 0;
> >  
> > r = read_status(fe, status);
> > if (r)
> > return r;
> >  
> > +   if (*status & FE_HAS_LOCK)
> > +   return 0;
> > +
> > return 0;  
> 
> That's stupid! it will return 0 on all situations, no matter if
> FE_HAS_LOCK or not. So, no need for the if.
> 
> Anyway, IMHO, either the original code is right and it needs to
> use a previously cached value (with sounds weird to me, although
> it is possible), or the logic is utterly broken, and we should,
> instead, apply the enclosed patch.

Well, in fact, this change was straight picked from upstream ([1]), but
I honestly didn't take into account that during cleanup the
#if-0/#endif was removed (which will in turn result in the same
behaviour though - return 0 in all cases; some leftovers?).

[1]
https://github.com/DigitalDevices/dddvb/commit/a44dbc889b7030a100599d2bd2c93c976c011a03

> 
> > if (r)
> > return r;  
> 
> >  }
> >
> 
> Thanks,
> Mauro
> 
> [PATCH RFC] media: mxl5xx: fix tuning logic
> 
> The tuning logic is broken with regards to status report:
> it relies on a previously-cached value that may not be valid
> if retuned.
> 
> Change the logic to always read the status.
> 
> Signed-off-by: Mauro Carvalho Chehab 
> 
> 
> diff --git a/drivers/media/dvb-frontends/mxl5xx.c
> b/drivers/media/dvb-frontends/mxl5xx.c index
> 676c96c216c3..4b449a6943c5 100644 ---
> a/drivers/media/dvb-frontends/mxl5xx.c +++
> b/drivers/media/dvb-frontends/mxl5xx.c @@ -636,16 +636,9 @@ static
> int tune(struct dvb_frontend *fe, bool re_tune, if (r)
>   return r;
>   state->tune_time = jiffies;
> - return 0;
>   }
> - if (*status & FE_HAS_LOCK)
> - return 0;
>  
> - r = read_status(fe, status);
> - if (r)
> - return r;
> -
> - return 0;
> + return read_status(fe, status);
>  }
>  
>  static enum fe_code_rate conv_fec(enum MXL_HYDRA_FEC_E fec)
> 

Indeed that makes more sense in this context (compared to dddvb
upstream), albeit on re_tune=1 read_status() will now also be called,
which I guess is totally fine. Let's do it this way. So:

Acked-by: Daniel Scheller 

Thanks & best regards,
Daniel Scheller
-- 
https://github.com/herrnst


Re: [PATCH v4] drm/bridge/sii8620: add remote control support

2017-08-27 Thread Hans Verkuil
Hi Maciej,

On 24/08/17 10:58, Maciej Purski wrote:
> MHL specification defines Remote Control Protocol(RCP) to
> send input events between MHL devices.
> The driver now recognizes RCP messages and reacts to them
> by reporting key events to input subsystem, allowing
> a user to control a device using TV remote control.

Before I Ack this I would like to know how this behaves w.r.t. autorepeat.

If you keep pressing a remote key, what RCP messages do you receive and
at what time intervals? If that's similar to what CEC does, then it is
very likely that the same rules apply and I will have to review this patch
again with that in mind.

See the commit log for the patching fixing the CEC 'Press and Hold' behavior:

https://git.linuxtv.org/media_tree.git/commit/drivers/media/cec/cec-adap.c?id=a9a249a2c997506a64eaee22f1458fda893f62a8

If you have access to the HDMI 2.0 specification, then that spec describes the 
CEC
'Press and Hold' behavior in detail.

Regards,

Hans

> 
> Signed-off-by: Maciej Purski 
> ---
> 
> Changes in v2:
> - use RC subsystem (including CEC keymap)
> - RC device initialized in attach drm_bridge callback and
>   removed in detach callback. This is necessary, because RC_CORE,
>   which is needed during rc_dev init, is loaded after sii8620.
>   DRM bridge is binded later which solves the problem.
> - add RC_CORE dependency
> 
> Changes in v3:
> - fix error handling in init_rcp and in attach callback
> 
> Changes in v4:
> - usage of rc-core API compatible with upcoming changes
> - fix error handling in init_rcp
> - fix commit message
> ---
>  drivers/gpu/drm/bridge/Kconfig   |  2 +-
>  drivers/gpu/drm/bridge/sil-sii8620.c | 96 
> ++--
>  include/drm/bridge/mhl.h |  4 ++
>  3 files changed, 96 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index adf9ae0..6ef901c 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -71,7 +71,7 @@ config DRM_PARADE_PS8622
>  
>  config DRM_SIL_SII8620
>   tristate "Silicon Image SII8620 HDMI/MHL bridge"
> - depends on OF
> + depends on OF && RC_CORE
>   select DRM_KMS_HELPER
>   help
> Silicon Image SII8620 HDMI/MHL bridge chip driver.
> diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c 
> b/drivers/gpu/drm/bridge/sil-sii8620.c
> index 2d51a22..ecb26c4 100644
> --- a/drivers/gpu/drm/bridge/sil-sii8620.c
> +++ b/drivers/gpu/drm/bridge/sil-sii8620.c
> @@ -28,6 +28,8 @@
>  #include 
>  #include 
>  
> +#include 
> +
>  #include "sil-sii8620.h"
>  
>  #define SII8620_BURST_BUF_LEN 288
> @@ -58,6 +60,7 @@ enum sii8620_mt_state {
>  struct sii8620 {
>   struct drm_bridge bridge;
>   struct device *dev;
> + struct rc_dev *rc_dev;
>   struct clk *clk_xtal;
>   struct gpio_desc *gpio_reset;
>   struct gpio_desc *gpio_int;
> @@ -431,6 +434,16 @@ static void sii8620_mt_rap(struct sii8620 *ctx, u8 code)
>   sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RAP, code);
>  }
>  
> +static void sii8620_mt_rcpk(struct sii8620 *ctx, u8 code)
> +{
> + sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RCPK, code);
> +}
> +
> +static void sii8620_mt_rcpe(struct sii8620 *ctx, u8 code)
> +{
> + sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RCPE, code);
> +}
> +
>  static void sii8620_mt_read_devcap_send(struct sii8620 *ctx,
>   struct sii8620_mt_msg *msg)
>  {
> @@ -1753,6 +1766,25 @@ static void sii8620_send_features(struct sii8620 *ctx)
>   sii8620_write_buf(ctx, REG_MDT_XMIT_WRITE_PORT, buf, ARRAY_SIZE(buf));
>  }
>  
> +static bool sii8620_rcp_consume(struct sii8620 *ctx, u8 scancode)
> +{
> + bool pressed = !(scancode & MHL_RCP_KEY_RELEASED_MASK);
> +
> + scancode &= MHL_RCP_KEY_ID_MASK;
> +
> + if (!ctx->rc_dev) {
> + dev_dbg(ctx->dev, "RCP input device not initialized\n");
> + return false;
> + }
> +
> + if (pressed)
> + rc_keydown(ctx->rc_dev, RC_PROTO_CEC, scancode, 0);
> + else
> + rc_keyup(ctx->rc_dev);
> +
> + return true;
> +}
> +
>  static void sii8620_msc_mr_set_int(struct sii8620 *ctx)
>  {
>   u8 ints[MHL_INT_SIZE];
> @@ -1804,19 +1836,25 @@ static void sii8620_msc_mt_done(struct sii8620 *ctx)
>  
>  static void sii8620_msc_mr_msc_msg(struct sii8620 *ctx)
>  {
> - struct sii8620_mt_msg *msg = sii8620_msc_msg_first(ctx);
> + struct sii8620_mt_msg *msg;
>   u8 buf[2];
>  
> - if (!msg)
> - return;
> -
>   sii8620_read_buf(ctx, REG_MSC_MR_MSC_MSG_RCVD_1ST_DATA, buf, 2);
>  
>   switch (buf[0]) {
>   case MHL_MSC_MSG_RAPK:
> + msg = sii8620_msc_msg_first(ctx);
> + if (!msg)
> + return;
>   msg->ret = buf[1];
>   ctx->mt_state = MT_STATE_DONE;
>   break;
> + case MHL_MSC_MSG_RCP:
> + if (!sii8620_rcp_consume(ctx, 

Re: [PATCH v4] drm/bridge/sii8620: add remote control support

2017-08-27 Thread Mauro Carvalho Chehab
Em Thu, 24 Aug 2017 10:58:07 +0200
Maciej Purski  escreveu:

> MHL specification defines Remote Control Protocol(RCP) to
> send input events between MHL devices.
> The driver now recognizes RCP messages and reacts to them
> by reporting key events to input subsystem, allowing
> a user to control a device using TV remote control.
> 
> Signed-off-by: Maciej Purski 

Acked-by: Mauro Carvalho Chehab 


> ---
> 
> Changes in v2:
> - use RC subsystem (including CEC keymap)
> - RC device initialized in attach drm_bridge callback and
>   removed in detach callback. This is necessary, because RC_CORE,
>   which is needed during rc_dev init, is loaded after sii8620.
>   DRM bridge is binded later which solves the problem.
> - add RC_CORE dependency
> 
> Changes in v3:
> - fix error handling in init_rcp and in attach callback
> 
> Changes in v4:
> - usage of rc-core API compatible with upcoming changes
> - fix error handling in init_rcp
> - fix commit message
> ---
>  drivers/gpu/drm/bridge/Kconfig   |  2 +-
>  drivers/gpu/drm/bridge/sil-sii8620.c | 96 
> ++--
>  include/drm/bridge/mhl.h |  4 ++
>  3 files changed, 96 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index adf9ae0..6ef901c 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -71,7 +71,7 @@ config DRM_PARADE_PS8622
>  
>  config DRM_SIL_SII8620
>   tristate "Silicon Image SII8620 HDMI/MHL bridge"
> - depends on OF
> + depends on OF && RC_CORE
>   select DRM_KMS_HELPER
>   help
> Silicon Image SII8620 HDMI/MHL bridge chip driver.
> diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c 
> b/drivers/gpu/drm/bridge/sil-sii8620.c
> index 2d51a22..ecb26c4 100644
> --- a/drivers/gpu/drm/bridge/sil-sii8620.c
> +++ b/drivers/gpu/drm/bridge/sil-sii8620.c
> @@ -28,6 +28,8 @@
>  #include 
>  #include 
>  
> +#include 
> +
>  #include "sil-sii8620.h"
>  
>  #define SII8620_BURST_BUF_LEN 288
> @@ -58,6 +60,7 @@ enum sii8620_mt_state {
>  struct sii8620 {
>   struct drm_bridge bridge;
>   struct device *dev;
> + struct rc_dev *rc_dev;
>   struct clk *clk_xtal;
>   struct gpio_desc *gpio_reset;
>   struct gpio_desc *gpio_int;
> @@ -431,6 +434,16 @@ static void sii8620_mt_rap(struct sii8620 *ctx, u8 code)
>   sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RAP, code);
>  }
>  
> +static void sii8620_mt_rcpk(struct sii8620 *ctx, u8 code)
> +{
> + sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RCPK, code);
> +}
> +
> +static void sii8620_mt_rcpe(struct sii8620 *ctx, u8 code)
> +{
> + sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RCPE, code);
> +}
> +
>  static void sii8620_mt_read_devcap_send(struct sii8620 *ctx,
>   struct sii8620_mt_msg *msg)
>  {
> @@ -1753,6 +1766,25 @@ static void sii8620_send_features(struct sii8620 *ctx)
>   sii8620_write_buf(ctx, REG_MDT_XMIT_WRITE_PORT, buf, ARRAY_SIZE(buf));
>  }
>  
> +static bool sii8620_rcp_consume(struct sii8620 *ctx, u8 scancode)
> +{
> + bool pressed = !(scancode & MHL_RCP_KEY_RELEASED_MASK);
> +
> + scancode &= MHL_RCP_KEY_ID_MASK;
> +
> + if (!ctx->rc_dev) {
> + dev_dbg(ctx->dev, "RCP input device not initialized\n");
> + return false;
> + }
> +
> + if (pressed)
> + rc_keydown(ctx->rc_dev, RC_PROTO_CEC, scancode, 0);
> + else
> + rc_keyup(ctx->rc_dev);
> +
> + return true;
> +}
> +
>  static void sii8620_msc_mr_set_int(struct sii8620 *ctx)
>  {
>   u8 ints[MHL_INT_SIZE];
> @@ -1804,19 +1836,25 @@ static void sii8620_msc_mt_done(struct sii8620 *ctx)
>  
>  static void sii8620_msc_mr_msc_msg(struct sii8620 *ctx)
>  {
> - struct sii8620_mt_msg *msg = sii8620_msc_msg_first(ctx);
> + struct sii8620_mt_msg *msg;
>   u8 buf[2];
>  
> - if (!msg)
> - return;
> -
>   sii8620_read_buf(ctx, REG_MSC_MR_MSC_MSG_RCVD_1ST_DATA, buf, 2);
>  
>   switch (buf[0]) {
>   case MHL_MSC_MSG_RAPK:
> + msg = sii8620_msc_msg_first(ctx);
> + if (!msg)
> + return;
>   msg->ret = buf[1];
>   ctx->mt_state = MT_STATE_DONE;
>   break;
> + case MHL_MSC_MSG_RCP:
> + if (!sii8620_rcp_consume(ctx, buf[1]))
> + sii8620_mt_rcpe(ctx,
> + MHL_RCPE_STATUS_INEFFECTIVE_KEY_CODE);
> + sii8620_mt_rcpk(ctx, buf[1]);
> + break;
>   default:
>   dev_err(ctx->dev, "%s message type %d,%d not supported",
>   __func__, buf[0], buf[1]);
> @@ -2102,11 +2140,57 @@ static void sii8620_cable_in(struct sii8620 *ctx)
>   enable_irq(to_i2c_client(ctx->dev)->irq);
>  }
>  
> +static void sii8620_init_rcp_input_dev(struct sii8620 *ctx)
> +{
> + struct rc_dev 

[PATCH] cx23885: Explicitly list Hauppauge model numbers of HVR-4400 and HVR-5500

2017-08-27 Thread Matthias Schwarzott
Add two new model numbers to suppress this message in kernel log:
  cx23885: cx23885[0]: warning: unknown hauppauge model #121029

Add these model numbers:
* Model 121019 - WinTV-HVR4400
* Model 121029 - WinTV-HVR5500

For WinTV-HVR4400 the documentation and my hardware differ:

Documentation says it supports DVB-S/S2 and DVB-T,
but my hardware also supports DVB-C.

Signed-off-by: Matthias Schwarzott 
---
 drivers/media/pci/cx23885/cx23885-cards.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index c48fa8e25a70..78a8836d03e4 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -1278,6 +1278,12 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 
*eeprom_data)
case 85721:
/* WinTV-HVR1290 (PCIe, OEM, RCA in, IR,
Dual channel ATSC and Basic analog */
+   case 121019:
+   /* WinTV-HVR4400 (PCIe, DVB-S2, DVB-C/T) */
+   break;
+   case 121029:
+   /* WinTV-HVR5500 (PCIe, DVB-S2, DVB-C/T) */
+   break;
case 150329:
/* WinTV-HVR5525 (PCIe, DVB-S/S2, DVB-T/T2/C) */
break;
-- 
2.14.1



Re: [PATCH] [media] dvb-frontends/mxl5xx: fix lock check order

2017-08-27 Thread Mauro Carvalho Chehab
Em Sun, 20 Aug 2017 12:45:45 +0200
Daniel Scheller  escreveu:

> From: Daniel Scheller 
> 

Always add a description at the patch.


> Signed-off-by: Daniel Scheller 
> ---
> When the mxl5xx driver together with the ddbridge glue gets merged ([1]),
> this one should go in aswell - this fix is part of the dddvb-0.9.31
> release.
> 
>  drivers/media/dvb-frontends/mxl5xx.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
> b/drivers/media/dvb-frontends/mxl5xx.c
> index 676c96c216c3..d9136d67f5d4 100644
> --- a/drivers/media/dvb-frontends/mxl5xx.c
> +++ b/drivers/media/dvb-frontends/mxl5xx.c
> @@ -638,13 +638,14 @@ static int tune(struct dvb_frontend *fe, bool re_tune,
>   state->tune_time = jiffies;
>   return 0;
>   }
> - if (*status & FE_HAS_LOCK)
> - return 0;
>  
>   r = read_status(fe, status);
>   if (r)
>   return r;
>  
> + if (*status & FE_HAS_LOCK)
> + return 0;
> +
>   return 0;

That's stupid! it will return 0 on all situations, no matter if FE_HAS_LOCK
or not. So, no need for the if.

Anyway, IMHO, either the original code is right and it needs to
use a previously cached value (with sounds weird to me, although
it is possible), or the logic is utterly broken, and we should,
instead, apply the enclosed patch.

>   if (r)
>   return r;

>  }
>  

Thanks,
Mauro

[PATCH RFC] media: mxl5xx: fix tuning logic

The tuning logic is broken with regards to status report:
it relies on a previously-cached value that may not be valid
if retuned.

Change the logic to always read the status.

Signed-off-by: Mauro Carvalho Chehab 


diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
b/drivers/media/dvb-frontends/mxl5xx.c
index 676c96c216c3..4b449a6943c5 100644
--- a/drivers/media/dvb-frontends/mxl5xx.c
+++ b/drivers/media/dvb-frontends/mxl5xx.c
@@ -636,16 +636,9 @@ static int tune(struct dvb_frontend *fe, bool re_tune,
if (r)
return r;
state->tune_time = jiffies;
-   return 0;
}
-   if (*status & FE_HAS_LOCK)
-   return 0;
 
-   r = read_status(fe, status);
-   if (r)
-   return r;
-
-   return 0;
+   return read_status(fe, status);
 }
 
 static enum fe_code_rate conv_fec(enum MXL_HYDRA_FEC_E fec)



Re: [PATCH] [em28xx] add config for em28xx-based board by MAGIX

2017-08-27 Thread Mauro Carvalho Chehab
Em Fri, 18 Aug 2017 12:11:00 +
panic  escreveu:

> Hi,
> 
> the patch below adds the entries to the config arrays for a capture-only
> board distributed by MAGIX [0]. The hardware itself (EM2860, SAA7113,
> EMP202) is already supported.

> This patch lacks the configuration for the GPIO pin, because I had/have
> no time yet to figure out how it works. Video and audio work fine for me
> in mplayer/mencoder.

You may won't need to touch it. Several capture-only boards just don't
use GPIO at all. That's easy to test: just connect the hardware on your
machine with Linux booted with the driver. If it works as-is, you
won't need to touch GPIOs. If, on the other hand, you need to first
boot it with the original driver and reboot linux, then you'll need
to sniff what the original driver is doing with regards to GPIO.

> The patch works against Linux 4.9.0 from Debian stretch/stable.
> 
> This is my first kernel submission, so tell me if you need more info or
> if something should be changed. Thanks!
> 
> Cheers,
> panic
> 
> [0] contains not much info, but for the record:
> http://www.magix.com/gb/rescue-your-videotapes/

The patch itself is OK, except that it should be based on upstream
Kernel (although I can easily rebase it, as the enclosed version).

The main issue with it is that you need to follow the
submission rules of the Kernel. In particular, all patches
should contain your real name and a Signed-off-by with it, as
stated at:


https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin

As reference, I enclosed how the patch should like, rebased to
the upstream Kernel version. You'll need to put your real name
on it.

Thanks,
Mauro


-

[em28xx] add config for em28xx-based board by MAGIX

From: your real name 

Adds the entries to the config arrays for a capture-only board 
distributed by MAGIX [0]. The hardware itself (EM2860, SAA7113,
EMP202) is already supported.

[0] contains not much info, but for the record:
http://www.magix.com/gb/rescue-your-videotapes/

Signed-off-by: your real name 


---
 drivers/media/usb/em28xx/em28xx-cards.c |   20 
 drivers/media/usb/em28xx/em28xx.h   |1 +
 2 files changed, 21 insertions(+)

--- patchwork.orig/drivers/media/usb/em28xx/em28xx-cards.c
+++ patchwork/drivers/media/usb/em28xx/em28xx-cards.c
@@ -2421,6 +2421,24 @@ struct em28xx_board em28xx_boards[] = {
.ir_codes  = RC_MAP_HAUPPAUGE,
.leds  = hauppauge_dualhd_leds,
},
+   /*
+* 1b80:e349 MAGIX "Rescue your Videotapes!"
+* Empia EM2860, Philips SAA7113, Empia EMP202, No Tuner
+*/
+   [EM2860_BOARD_MAGIX] = {
+   .name = "MAGIX",
+   .tuner_type   = TUNER_ABSENT,
+   .decoder  = EM28XX_SAA711X,
+   .input= { {
+   .type = EM28XX_VMUX_COMPOSITE,
+   .vmux = SAA7115_COMPOSITE0,
+   .amux = EM28XX_AMUX_AUX,
+   }, {
+   .type = EM28XX_VMUX_SVIDEO,
+   .vmux = SAA7115_SVIDEO3,
+   .amux = EM28XX_AMUX_AUX,
+   } },
+   },
 };
 EXPORT_SYMBOL_GPL(em28xx_boards);
 
@@ -2620,6 +2638,8 @@ struct usb_device_id em28xx_id_table[] =
.driver_info = EM28178_BOARD_PLEX_PX_BCUD },
{ USB_DEVICE(0xeb1a, 0x5051), /* Ion Video 2 PC MKII / Startech 
svid2usb23 / Raygo R12-41373 */
.driver_info = EM2860_BOARD_TVP5150_REFERENCE_DESIGN },
+   { USB_DEVICE(0x1b80, 0xe349),
+   .driver_info = EM2860_BOARD_MAGIX },
{ },
 };
 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
--- patchwork.orig/drivers/media/usb/em28xx/em28xx.h
+++ patchwork/drivers/media/usb/em28xx/em28xx.h
@@ -149,6 +149,7 @@
 #define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB  99
 #define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 100
 #define EM2884_BOARD_TERRATEC_H6 101
+#define EM2860_BOARD_MAGIX102
 
 /* Limits minimum and default number of buffers */
 #define EM28XX_MIN_BUF 4



Re: [RFC PATCH v4 3/6] i2c: add docs to clarify DMA handling

2017-08-27 Thread Mauro Carvalho Chehab
Em Thu, 17 Aug 2017 16:14:46 +0200
Wolfram Sang  escreveu:

> Signed-off-by: Wolfram Sang 
> ---
>  Documentation/i2c/DMA-considerations | 50 
> 
>  1 file changed, 50 insertions(+)
>  create mode 100644 Documentation/i2c/DMA-considerations
> 
> diff --git a/Documentation/i2c/DMA-considerations 
> b/Documentation/i2c/DMA-considerations
> new file mode 100644
> index 00..a4b4a107102452
> --- /dev/null
> +++ b/Documentation/i2c/DMA-considerations
> @@ -0,0 +1,50 @@
> +Linux I2C and DMA
> +-

I would use, instead:

=
Linux I2C and DMA
=

As this is the way we're starting document titles, after converted to
ReST. So, better to have it already using the right format, as one day
someone will convert i2c documentation to ReST. So, it would be
really cool if this document could be just renamed without needing
to patch it during such conversion :-)

There are also a couple of things here that Sphinx would complain.
So, it could be worth to rename it to *.rst, while you're writing
it, and see what:
make htmldocs
will complain and how it will look in html.

> +
> +Given that I2C is a low-speed bus where largely small messages are 
> transferred,
> +it is not considered a prime user of DMA access. At this time of writing, 
> only
> +10% of I2C bus master drivers have DMA support implemented.

Are you sure about that? I'd say that, on media, at least half of the
drivers use DMA for I2C bus access, as the I2C bus is on a remote
board that talks with CPU via USB, using DMA, and all communication
with USB should be DMA-safe.

I guess what you really wanted to say on most of this section is
about SoC (and other CPUs) where the I2C bus master is is at the
mainboard, and not on some peripheral.

> And the vast
> +majority of transactions are so small that setting up DMA for it will likely
> +add more overhead than a plain PIO transfer.
> +
> +Therefore, it is *not* mandatory that the buffer of an I2C message is DMA 
> safe.

Again, that may not be true on media boards. The code that implements the
I2C transfers there, on most boards, have to be DMA safe, as it won't
otherwise send/receive commands from the chips that are after the USB
bridge.

> +It does not seem reasonable to apply additional burdens when the feature is 
> so
> +rarely used. However, it is recommended to use a DMA-safe buffer if your
> +message size is likely applicable for DMA. Most drivers have this threshold
> +around 8 bytes (as of today, this is mostly an educated guess, however). For
> +any message of 16 byte or larger, it is probably a really good idea.
> +
> +If you use such a buffer in a i2c_msg, set the I2C_M_DMA_SAFE flag with it.
> +Then, the I2C core and drivers know they can safely operate DMA on it. Note
> +that setting this flag makes only sense in kernel space. User space data is
> +copied into kernel space anyhow. The I2C core makes sure the destination
> +buffers in kernel space are always DMA capable.
> +
> +FIXME: Need to implement i2c_master_{send|receive}_dma and proper buffers 
> for i2c_smbus_xfer_emulated.
> +
> +Drivers wishing to implement DMA can use helper functions from the I2C core.
> +One gives you a DMA-safe buffer for a given i2c_msg as long as a certain
> +threshold is met.
> +
> + dma_buf = i2c_get_dma_safe_msg_buf(msg, threshold_in_byte);

I'm concerned about the new bits added by this call. Right now,
USB drivers just use kalloc() for transfer buffers used to send and
receive URB control messages for both setting the main device and
for I2C messages. Before this changeset, buffers allocated this
way are DMA save and have been working for years.

When you add some flags that would make the I2C subsystem aware
that a buffer is now DMA safe, I guess you could be breaking
those drivers, as a DMA safe buffer will now be considered as
DMA-unsafe.

So, you'll likely need to patch all media USB drivers to fix it,
or come up with some other solution.

> +
> +If a buffer is returned, it either msg->buf for the I2C_M_DMA_SAFE case or a
> +bounce buffer. But you don't need to care about that detail. If NULL is
> +returned, the threshold was not met or a bounce buffer could not be 
> allocated.
> +Fall back to PIO in that case.
> +
> +In any case, a buffer obtained from above needs to be released. It ensures 
> data
> +is copied back to the message and a potentially used bounce buffer is freed.
> +
> + i2c_release_dma_safe_msg_buf(msg, dma_buf);
> +
> +The bounce buffer handling from the core is generic and simple. It will 
> always
> +allocate a new bounce buffer. If you want a more sophisticated handling (e.g.
> +reusing pre-allocated buffers), you are free to implement your own.
> +
> +Please also check the in-kernel documentation for details. The i2c-sh_mobile
> +driver can be used as a reference example how to use the above helpers.
> +
> +Final 

[PATCH V2 1/1] build: gpio-ir-tx backport

2017-08-27 Thread Jasmin J.
From: Jasmin Jessich 

- Added v3.16_gpio-ir-tx.patch
- gpio_ir_tx needs 3.13. at least

Signed-off-by: Jasmin Jessich 
---
 backports/backports.txt  |  1 +
 backports/v3.16_gpio-ir-tx.patch | 25 +
 v4l/versions.txt |  2 +-
 3 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 backports/v3.16_gpio-ir-tx.patch

diff --git a/backports/backports.txt b/backports/backports.txt
index 873b2f5..b511e57 100644
--- a/backports/backports.txt
+++ b/backports/backports.txt
@@ -83,6 +83,7 @@ add v3.17_fix_clamp.patch
 add v3.16_netdev.patch
 add v3.16_wait_on_bit.patch
 add v3.16_void_gpiochip_remove.patch
+add v3.16_gpio-ir-tx.patch
 
 [3.12.255]
 add v3.12_kfifo_in.patch
diff --git a/backports/v3.16_gpio-ir-tx.patch b/backports/v3.16_gpio-ir-tx.patch
new file mode 100644
index 000..3ec4304
--- /dev/null
+++ b/backports/v3.16_gpio-ir-tx.patch
@@ -0,0 +1,25 @@
+diff --git a/drivers/media/rc/gpio-ir-tx.c b/drivers/media/rc/gpio-ir-tx.c
+index cd476ca..f48aba2 100644
+--- a/drivers/media/rc/gpio-ir-tx.c
 b/drivers/media/rc/gpio-ir-tx.c
+@@ -136,13 +136,19 @@ static int gpio_ir_tx_probe(struct platform_device *pdev)
+   if (!rcdev)
+   return -ENOMEM;
+ 
+-  gpio_ir->gpio = devm_gpiod_get(>dev, NULL, GPIOD_OUT_LOW);
++  gpio_ir->gpio = devm_gpiod_get(>dev, NULL);
+   if (IS_ERR(gpio_ir->gpio)) {
+   if (PTR_ERR(gpio_ir->gpio) != -EPROBE_DEFER)
+   dev_err(>dev, "Failed to get gpio (%ld)\n",
+   PTR_ERR(gpio_ir->gpio));
+   return PTR_ERR(gpio_ir->gpio);
+   }
++  rc = gpiod_direction_output(gpio_ir->gpio, 0);
++  if (!rc) {
++  dev_err(>dev, "Failed to set output direction(%d)\n", rc);
++  gpiod_put(gpio_ir->gpio);
++  return rc;
++  }
+ 
+   rcdev->priv = gpio_ir;
+   rcdev->driver_name = DRIVER_NAME;
diff --git a/v4l/versions.txt b/v4l/versions.txt
index 7634038..7c54778 100644
--- a/v4l/versions.txt
+++ b/v4l/versions.txt
@@ -39,7 +39,6 @@ VIDEO_XILINX
 VIDEO_OV5670
 # needs ktime_t as s64
 CEC_PIN
-IR_GPIO_TX
 
 [4.7.0]
 # needs i2c_mux_alloc
@@ -98,6 +97,7 @@ VIDEO_COBALT
 [3.13.0]
 # needs gpio/consumer.h
 RADIO_SI4713
+IR_GPIO_TX
 
 [3.12.0]
 # BIN_ATTR_RW was changed
-- 
2.7.4



[PATCH V2 0/1] build: gpio-ir-tx for 3.13

2017-08-27 Thread Jasmin J.
From: Jasmin Jessich 

Changes to V1:
 Moved IR_GPIO_TX from 4.10.0 to 3.13.0 instead of adding it.

Kernel 3.17 introduces GPIOD_OUT_LOW/HIGH. gpio-ir-tx requires this
definitions. This patch adds the API calls prior to 3.17 to be used
by gpio-ir-tx.
With that gpio-ir-tx can be compiled back to Kernel 3.13.
I tested the compilation (not the functionality!) on 4.4, 3.13 and
3.4.

@Sean: Please check if the code in v3.16_gpio-ir-tx.patch looks
feasible for you (can't test this here). If not, we will drop this
patch and simply disable gpio-ir-tx for Kernels older than 3.17.

Jasmin Jessich (1):
  build: gpio-ir-tx backport

 backports/backports.txt  |  1 +
 backports/v3.16_gpio-ir-tx.patch | 25 +
 v4l/versions.txt |  2 +-
 3 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 backports/v3.16_gpio-ir-tx.patch

-- 
2.7.4



Re: [GIT PULL] SAA716x DVB driver

2017-08-27 Thread Mauro Carvalho Chehab
Em Fri, 21 Jul 2017 22:44:42 +0200
Soeren Moch  escreveu:

> Hi Mauro,
> 
> On 20.07.2017 07:49:36 -0300, Mauro Carvalho Chehab wrote:
> >Hi Soeren,
> >
> >Em Sun, 16 Jul 2017 20:34:23 +0200
> >Soeren Moch  escreveu:
> >  
> >> This is a driver for DVB cards based on the SAA7160/62 PCIe bridges from
> >> Philips/NXP. The most important of these cards, at least for me, is the
> >> TechnoTrend S2-6400, a high-definition full-featured DVB-S2 card, the
> >> successor of the famous ttpci decoder cards. Other supported cards are:
> >> Avermedia H788
> >> Avermedia HC82 Express-54
> >> KNC One Dual S2
> >> KWorld DVB-T PE310
> >> Technisat SkyStar 2 eXpress HD
> >> Twinhan/Azurewave VP-1028
> >> Twinhan/Azurewave VP-3071
> >> Twinhan/Azurewave VP-6002
> >> Twinhan/Azurewave VP-6090
> >>
> >> The driver is taken from [1] with adaptations for current mainline,
> >> converted to git and moved to drivers/staging/media. See TODO for
> >> required cleanups (from my point of view, maybe more to come from
> >> additional code review by other developers). I added myself as driver
> >> maintainer to document my commitment to further development to get this
> >> out of staging, help from others welcome.
> >>
> >> This driver was licensed "GPL" from the beginning. S2-6400 firmware is
> >> available at [2].
> >>
> >> I want to preserve the development history of the driver, since this
> >> is mainly work of Andreas Regel, Manu Abraham, and Oliver Endriss.
> >> Unfortunately Andreas seems not to take care of this driver anymore, he
> >> also did not answer my requests to integrate patches for newer kernel
> >> versions. So I send this upstream.
> >>
> >> With all the history this is a 280 part patch series, so I send this as
> >> pull request. Of course I can also send this as 'git send-email' series
> >> if desired.  
> >
> >Even on staging, reviewing a 280 patch series take a while ;)
> >
> >As the patches that make it build with current upstream are at the
> >end of the series, you need to be sure that the saa716x Makefile
> >won't be included until those fixes get applied. It seems you took
> >care of it already, with is good!
> >
> >
> >The hole idea of adding a driver to staging is that it will be moved
> >some day out of staging. That's why a TODO and an entry at MAINTAINERS
> >is required.
> >
> >By looking at the saa716x_ff_main:
> >
> > 
> https://github.com/s-moch/linux-saa716x/blob/for-media/drivers/staging/media/saa716x/saa716x_ff_main.c
> >
> >I'm seeing that the main problem of this driver is that it still use
> >the API from the legacy ttpci driver, e. g. DVB audio, video and osd APIs.
> >
> >Those APIs were deprecated because they duplicate a functionality
> >provided by the V4L2 API, and are obscure, because they're not
> >properly documented. Also, no other driver uses it upstream.
> >
> >So, it was agreed several years ago that new full featured drivers
> >should use the V4L2 API for audio/video codecs.
> >
> >We have a some drivers that use V4L2 for MPEG audio/video decoding
> >and encoding. The best examples are ivtv and cx18 (as both are for
> >PCI devices). Currently, none of those drivers support the DVB
> >API, though, as they're used only on analog TV devices.
> >
> >It was also agreed that setup pipelines on more complex DVB
> >devices should use the media controller API (MC API).
> >
> >Yet, we don't have, currently, any full featured drivers upstream
> >(except for the legacy one).
> >
> >So, if we're willing to apply this driver, you should be committed
> >to do implement the media APIs properly, porting from DVB
> >audio/video/osd to V4L2 and MC APIs.
> >
> >That should also reflect its TODO:
> >
> > 
> https://github.com/s-moch/linux-saa716x/blob/for-media/drivers/staging/media/saa716x/TODO
> 
> Thanks for your feedback. I understand all your concerns about the legacy
> API and your request to convert this to v4l2. For me the whole story looks
> a little bit different, though.
> 
> The only application which makes use of the decoder part of this saa716x_ff
> driver is VDR (Video Disk Recorder by Klaus Schmidinger, [1] [2]) - if
> anybody else knows about a different use-case, please speak up!
> In fact the high-definition version of VDR (vdr-2.x) was co-developed with
> the S2-6400 hardware and this saa716x_ff driver. So it is no surprise, that
> this driver utilizes the - now legacy - DVB API of the ttpci cards, since
> VDR was originally developed with this API in mind. The missing API
> documentation, besides of course not being ideal, is therefore no real
> problem here, since driver and application are closely tied together.
> 
> The S2-6400 card (the only hardware which saa716x_ff supports) only has
> two simple hardware interfaces for the decoder part, a transport stream
> interface for the video/audio decoder, and a DVB API command interface
> for osd. There is no real separate DVB audio interface, audio TS packets
> are simply multiplexed into the 

Fwd: Aw: Fwd: [PATCH 1/2] cx23885: Fix use-after-free when unregistering the i2c_client for the dvb demod

2017-08-27 Thread Matthias Schwarzott
Forwarding a tested-by statement (using a HVR-5500).

Regards
Matthias

 Weitergeleitete Nachricht 
Betreff: Aw: Fwd: [PATCH 1/2] cx23885: Fix use-after-free when
unregistering the i2c_client for the dvb demod
Datum: Sun, 27 Aug 2017 12:18:55 +0200
Von: "Sven Müller" 
An: Matthias Schwarzott 

Tested-by: Sven Müller 

> Gesendet: Sonntag, 27. August 2017 um 12:12 Uhr
> Von: "Matthias Schwarzott" 
> An: "Sven Müller" 
> Betreff: Fwd: [PATCH 1/2] cx23885: Fix use-after-free when unregistering the 
> i2c_client for the dvb demod
>
> 
> 
> 
>  Weitergeleitete Nachricht 
> Betreff: [PATCH 1/2] cx23885: Fix use-after-free when unregistering the
> i2c_client for the dvb demod
> Datum: Wed,  2 Aug 2017 18:45:59 +0200
> Von: Matthias Schwarzott 
> An: linux-media@vger.kernel.org
> Kopie (CC): mche...@osg.samsung.com, cr...@iki.fi, Matthias Schwarzott
> 
> 
> Unregistering the i2c_client of the demod driver destroys the frontend
> object.
> Calling vb2_dvb_unregister_bus later accesses the frontend (and with the
> refcount_t) conversion the refcount_t code complains:
> 
> kernel: [ cut here ]
> kernel: WARNING: CPU: 0 PID: 7883 at lib/refcount.c:128
> refcount_sub_and_test+0x70/0x80
> kernel: refcount_t: underflow; use-after-free.
> kernel: Modules linked in: bluetooth si2165(O) a8293(O) tda10071(O)
> tea5767(O) tuner(O) cx23885(O-) tda18271(O) videobuf2_dvb(O)
> videobuf2_dma_sg(O) m88ds3103(O) tveeprom(O) cx2341x(O) v4l2_common(O)
> dvb_core(O) rc_core(O) videobuf2_memops(O) videobuf2_v4l2(O) ums_realtek
> videobuf2_core(O) uas videodev(O) media(O) rtl8192cu i2c_mux usb_storage
> rtl_usb rtl8192c_common rtlwifi snd_hda_codec_hdmi snd_hda_codec_realtek
> snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core
> x86_pkg_temp_thermal kvm_intel kvm irqbypass
> kernel: CPU: 0 PID: 7883 Comm: rmmod Tainted: GW  O
> 4.11.3-gentoo #3
> kernel: Hardware name: MEDION E2050 2391/H81H3-EM2, BIOS H81EM2W08.308
> 08/25/2014
> kernel: Call Trace:
> kernel:  dump_stack+0x4d/0x66
> kernel:  __warn+0xc6/0xe0
> kernel:  warn_slowpath_fmt+0x46/0x50
> kernel:  ? kobject_put+0x2f/0x60
> kernel:  refcount_sub_and_test+0x70/0x80
> kernel:  refcount_dec_and_test+0x11/0x20
> kernel:  dvb_unregister_frontend+0x42/0x60 [dvb_core]
> kernel:  vb2_dvb_dealloc_frontends+0x9e/0x100 [videobuf2_dvb]
> kernel:  vb2_dvb_unregister_bus+0xd/0x20 [videobuf2_dvb]
> kernel:  cx23885_dvb_unregister+0xc3/0x110 [cx23885]
> kernel:  cx23885_dev_unregister+0xea/0x150 [cx23885]
> kernel:  cx23885_finidev+0x4f/0x70 [cx23885]
> kernel:  pci_device_remove+0x34/0xb0
> kernel:  device_release_driver_internal+0x150/0x200
> kernel:  driver_detach+0x33/0x70
> kernel:  bus_remove_driver+0x47/0xa0
> kernel:  driver_unregister+0x27/0x50
> kernel:  pci_unregister_driver+0x34/0x90
> kernel:  cx23885_fini+0x10/0x12 [cx23885]
> kernel:  SyS_delete_module+0x166/0x220
> kernel:  ? exit_to_usermode_loop+0x7b/0x80
> kernel:  entry_SYSCALL_64_fastpath+0x17/0x98
> kernel: RIP: 0033:0x7f5901680b07
> kernel: RSP: 002b:7ffdf6cdb028 EFLAGS: 0206 ORIG_RAX:
> 00b0
> kernel: RAX: ffda RBX: 0003 RCX: 7f5901680b07
> kernel: RDX: 000a RSI: 0800 RDI: 01500258
> kernel: RBP: 015001f0 R08:  R09: 1999
> kernel: R10: 0884 R11: 0206 R12: 7ffdf6cda010
> kernel: R13:  R14: 015001f0 R15: 014ff010
> kernel: ---[ end trace c3a4659b89086061 ]---
> 
> Signed-off-by: Matthias Schwarzott 
> ---
>  drivers/media/pci/cx23885/cx23885-dvb.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c
> b/drivers/media/pci/cx23885/cx23885-dvb.c
> index 979b66627f60..e795ddeb7fe2 100644
> --- a/drivers/media/pci/cx23885/cx23885-dvb.c
> +++ b/drivers/media/pci/cx23885/cx23885-dvb.c
> @@ -2637,6 +2637,11 @@ int cx23885_dvb_unregister(struct cx23885_tsport
> *port)
>   struct vb2_dvb_frontend *fe0;
>   struct i2c_client *client;
>  +fe0 = vb2_dvb_get_frontend(>frontends, 1);
> +
> + if (fe0 && fe0->dvb.frontend)
> + vb2_dvb_unregister_bus(>frontends);
> +
>   /* remove I2C client for CI */
>   client = port->i2c_client_ci;
>   if (client) {
> @@ -2665,11 +2670,6 @@ int cx23885_dvb_unregister(struct cx23885_tsport
> *port)
>   i2c_unregister_device(client);
>   }
>  -fe0 = vb2_dvb_get_frontend(>frontends, 1);
> -
> - if (fe0 && fe0->dvb.frontend)
> - vb2_dvb_unregister_bus(>frontends);
> -
>   switch (port->dev->board) {
>   case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
>   netup_ci_exit(port);
> -- 
> 2.13.3
> 
> 
>