cron job: media_tree daily build: ERRORS

2017-03-24 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:   Sat Mar 25 05:00:17 CET 2017
media-tree git hash:c3d4fb0fb41f4b5eafeee51173c14e50be12f839
media_build git hash:   bc4c2a205c087c8deff3cd14ed663c4767dd2016
v4l-utils git hash: 38e099d8674851ddef6f371e8f7cf67acf57c59a
gcc version:i686-linux-gcc (GCC) 6.2.0
sparse version: v0.5.0-3553-g78b2ea6
smatch version: v0.5.0-3553-g78b2ea6
host hardware:  x86_64
host os:4.9.0-164

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-multi: OK
linux-git-arm-pxa: 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: WARNINGS
linux-3.14.9-i686: WARNINGS
linux-3.15.2-i686: WARNINGS
linux-3.16.7-i686: WARNINGS
linux-3.17.8-i686: WARNINGS
linux-3.18.7-i686: WARNINGS
linux-3.19-i686: WARNINGS
linux-4.0.9-i686: WARNINGS
linux-4.1.33-i686: WARNINGS
linux-4.2.8-i686: WARNINGS
linux-4.3.6-i686: WARNINGS
linux-4.4.22-i686: WARNINGS
linux-4.5.7-i686: WARNINGS
linux-4.6.7-i686: WARNINGS
linux-4.7.5-i686: WARNINGS
linux-4.8-i686: OK
linux-4.9-i686: OK
linux-4.10.1-i686: OK
linux-4.11-rc1-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: WARNINGS
linux-3.14.9-x86_64: WARNINGS
linux-3.15.2-x86_64: WARNINGS
linux-3.16.7-x86_64: WARNINGS
linux-3.17.8-x86_64: WARNINGS
linux-3.18.7-x86_64: WARNINGS
linux-3.19-x86_64: WARNINGS
linux-4.0.9-x86_64: WARNINGS
linux-4.1.33-x86_64: WARNINGS
linux-4.2.8-x86_64: WARNINGS
linux-4.3.6-x86_64: WARNINGS
linux-4.4.22-x86_64: WARNINGS
linux-4.5.7-x86_64: WARNINGS
linux-4.6.7-x86_64: WARNINGS
linux-4.7.5-x86_64: WARNINGS
linux-4.8-x86_64: WARNINGS
linux-4.9-x86_64: WARNINGS
linux-4.10.1-x86_64: WARNINGS
linux-4.11-rc1-x86_64: OK
apps: WARNINGS
spec-git: OK
sparse: WARNINGS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


[PATCH v3] staging: media: davinci_vpfe: Replace a bit shift.

2017-03-24 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v3
 - change the subject.
 - remove extra parenthesis.

 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c| 10 +-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index 6a3434cebd79..7eeb53217168 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -1815,7 +1815,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct 
platform_device *pdev)
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "DAVINCI IPIPE", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
+   sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
v4l2_set_subdevdata(sd, ipipe);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
index 46fd2c7f69c3..c07f028dd6be 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
@@ -1021,7 +1021,7 @@ int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif,
 
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "DAVINCI IPIPEIF", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
+   sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
 
v4l2_set_subdevdata(sd, ipipeif);
 
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c 
b/drivers/staging/media/davinci_vpfe/dm365_isif.c
index 569bcdc9ce2f..74b1247203b1 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
@@ -821,7 +821,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
vpfe_isif_dfc *vdfc)
 
/* Correct whole line or partial */
if (vdfc->corr_whole_line)
-   val |= 1 << ISIF_VDFC_CORR_WHOLE_LN_SHIFT;
+   val |= BIT(ISIF_VDFC_CORR_WHOLE_LN_SHIFT);
 
/* level shift value */
val |= (vdfc->def_level_shift & ISIF_VDFC_LEVEL_SHFT_MASK) <<
@@ -849,7 +849,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
vpfe_isif_dfc *vdfc)
 
val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
/* set DFCMARST and set DFCMWR */
-   val |= 1 << ISIF_DFCMEMCTL_DFCMARST_SHIFT;
+   val |= BIT(ISIF_DFCMEMCTL_DFCMARST_SHIFT);
val |= 1;
isif_write(isif->isif_cfg.base_addr, val, DFCMEMCTL);
 
@@ -880,7 +880,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
vpfe_isif_dfc *vdfc)
}
val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
/* clear DFCMARST and set DFCMWR */
-   val &= ~(1 << ISIF_DFCMEMCTL_DFCMARST_SHIFT);
+   val &= ~BIT(ISIF_DFCMEMCTL_DFCMARST_SHIFT);
val |= 1;
isif_write(isif->isif_cfg.base_addr, val, DFCMEMCTL);
 
@@ -1140,7 +1140,7 @@ static int isif_config_raw(struct v4l2_subdev *sd, int 
mode)
isif_write(isif->isif_cfg.base_addr, val, CGAMMAWD);
/* Configure DPCM compression settings */
if (params->v4l2_pix_fmt == V4L2_PIX_FMT_SGRBG10DPCM8) {
-   val =  1 << ISIF_DPCM_EN_SHIFT;
+   val =  BIT(ISIF_DPCM_EN_SHIFT);
val |= (params->dpcm_predictor &
ISIF_DPCM_PREDICTOR_MASK) << ISIF_DPCM_PREDICTOR_SHIFT;
}
@@ -2044,7 +2044,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct 
platform_device *pdev)
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "DAVINCI ISIF", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
+   sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
v4l2_set_subdevdata(sd, isif);
sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
pads[ISIF_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c 
b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
index 857b0e847c5e..3b3469adaf91 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
@@ -1903,7 +1903,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device 
*vpfe_rsz,
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "DAVINCI RESIZER 

[PATCH] Staging: atomisp - octal permissions, style fix

2017-03-24 Thread Derek Robson
Changed permissions to octal style
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c | 9 +++--
 drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c   | 8 
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c
index fcfe8d7190b0..763bc5f2a033 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_drvfs.c
@@ -163,12 +163,9 @@ static ssize_t iunit_dbgopt_store(struct device_driver 
*drv, const char *buf,
 }
 
 static struct driver_attribute iunit_drvfs_attrs[] = {
-   __ATTR(dbglvl, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbglvl_show,
-   iunit_dbglvl_store),
-   __ATTR(dbgfun, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbgfun_show,
-   iunit_dbgfun_store),
-   __ATTR(dbgopt, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, iunit_dbgopt_show,
-   iunit_dbgopt_store),
+   __ATTR(dbglvl, 0644, iunit_dbglvl_show, iunit_dbglvl_store),
+   __ATTR(dbgfun, 0644, iunit_dbgfun_show, iunit_dbgfun_store),
+   __ATTR(dbgopt, 0644, iunit_dbgopt_show, iunit_dbgopt_store),
 };
 
 static int iunit_drvfs_create_files(struct pci_driver *drv)
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
index a362b492ec8e..edf554e8e96e 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c
@@ -161,10 +161,10 @@ static ssize_t dynamic_pool_show(struct device *dev,
return ret;
 };
 
-static DEVICE_ATTR(active_bo, S_IRUGO, active_bo_show, NULL);
-static DEVICE_ATTR(free_bo, S_IRUGO, free_bo_show, NULL);
-static DEVICE_ATTR(reserved_pool, S_IRUGO, reserved_pool_show, NULL);
-static DEVICE_ATTR(dynamic_pool, S_IRUGO, dynamic_pool_show, NULL);
+static DEVICE_ATTR(active_bo, 0444, active_bo_show, NULL);
+static DEVICE_ATTR(free_bo, 0444, free_bo_show, NULL);
+static DEVICE_ATTR(reserved_pool, 0444, reserved_pool_show, NULL);
+static DEVICE_ATTR(dynamic_pool, 0444, dynamic_pool_show, NULL);
 
 static struct attribute *sysfs_attrs_ctrl[] = {
_attr_active_bo.attr,
-- 
2.12.0



Re: [PATCH v6] [media] vimc: Virtual Media Controller core, capture and sensor

2017-03-24 Thread Helen Koike

Hi Sakari,

Thanks for your review, I have some questions below:

On 2017-01-25 11:03 AM, Sakari Ailus wrote:

Hi Helen,

My apologies for the long review time!

Please see my comments below.

On Sun, Sep 04, 2016 at 05:02:18PM -0300, Helen Koike wrote:

From: Helen Fornazier 

First version of the Virtual Media Controller.
Add a simple version of the core of the driver, the capture and
sensor nodes in the topology, generating a grey image in a hardcoded
format.

Signed-off-by: Helen Koike 

---

Patch based in media/master tree, and available here:
https://github.com/helen-fornazier/opw-staging/tree/vimc/devel/vpu

Changes since v5:
- Fix message "Entity type for entity Sensor A was not initialized!"
  by initializing the sensor entity.function after the calling
  v4l2_subded_init
- populate device_caps in vimc_cap_create instead of in
  vimc_cap_querycap
- Fix typo in vimc-core.c s/de/the

Changes since v4:
- coding style fixes
- remove BUG_ON
- change copyright to 2016
- depens on VIDEO_V4L2_SUBDEV_API instead of select
- remove assignement of V4L2_CAP_DEVICE_CAPS
- s/vimc_cap_g_fmt_vid_cap/vimc_cap_fmt_vid_cap
- fix vimc_cap_queue_setup declaration type
- remove wrong buffer size check and add it in vimc_cap_buffer_prepare
- vimc_cap_create: remove unecessary check if v4l2_dev or v4l2_dev->dev is null
- vimc_cap_create: only allow a single pad
- vimc_sen_create: only allow source pads, remove unecessary source pads
checks in vimc_thread_sen

Changes since v3: fix rmmod crash and built-in compile
- Re-order unregister calls in vimc_device_unregister function (remove
rmmod issue)
- Call media_device_unregister_entity in vimc_raw_destroy
- Add depends on VIDEO_DEV && VIDEO_V4L2 and select VIDEOBUF2_VMALLOC
- Check *nplanes in queue_setup (this remove v4l2-compliance fail)
- Include  in vimc-sensor.c
- Move include of  from vimc-core.c to vimc-core.h
- Generate 60 frames per sec instead of 1 in the sensor

Changes since v2: update with current media master tree
- Add struct media_pipeline in vimc_cap_device
- Use vb2_v4l2_buffer instead of vb2_buffer
- Typos
- Remove usage of entity->type and use entity->function instead
- Remove fmt argument from queue setup
- Use ktime_get_ns instead of v4l2_get_timestamp
- Iterate over link's list using list_for_each_entry
- Use media_device_{init, cleanup}
- Use entity->use_count to keep track of entities instead of the old
entity->id
- Replace media_entity_init by media_entity_pads_init
---
 drivers/media/platform/Kconfig |   2 +
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/vimc/Kconfig|   7 +
 drivers/media/platform/vimc/Makefile   |   3 +
 drivers/media/platform/vimc/vimc-capture.c | 553 ++
 drivers/media/platform/vimc/vimc-capture.h |  28 ++
 drivers/media/platform/vimc/vimc-core.c| 600 +
 drivers/media/platform/vimc/vimc-core.h|  57 +++
 drivers/media/platform/vimc/vimc-sensor.c  | 279 ++
 drivers/media/platform/vimc/vimc-sensor.h  |  28 ++
 10 files changed, 1558 insertions(+)
 create mode 100644 drivers/media/platform/vimc/Kconfig
 create mode 100644 drivers/media/platform/vimc/Makefile
 create mode 100644 drivers/media/platform/vimc/vimc-capture.c
 create mode 100644 drivers/media/platform/vimc/vimc-capture.h
 create mode 100644 drivers/media/platform/vimc/vimc-core.c
 create mode 100644 drivers/media/platform/vimc/vimc-core.h
 create mode 100644 drivers/media/platform/vimc/vimc-sensor.c
 create mode 100644 drivers/media/platform/vimc/vimc-sensor.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 46f14dd..4a0577f 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -329,6 +329,8 @@ menuconfig V4L_TEST_DRIVERS

 if V4L_TEST_DRIVERS

+source "drivers/media/platform/vimc/Kconfig"
+
 source "drivers/media/platform/vivid/Kconfig"

 config VIDEO_VIM2M
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 536d1d8..dd4f658 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_VIDEO_OMAP3) += omap3isp/

 obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o

+obj-$(CONFIG_VIDEO_VIMC)   += vimc/
 obj-$(CONFIG_VIDEO_VIVID)  += vivid/
 obj-$(CONFIG_VIDEO_VIM2M)  += vim2m.o

diff --git a/drivers/media/platform/vimc/Kconfig 
b/drivers/media/platform/vimc/Kconfig
new file mode 100644
index 000..b48819c
--- /dev/null
+++ b/drivers/media/platform/vimc/Kconfig
@@ -0,0 +1,7 @@
+config VIDEO_VIMC
+   tristate "Virtual Media Controller Driver (VIMC)"
+   depends on VIDEO_DEV && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+   select VIDEOBUF2_VMALLOC
+   default n
+   ---help---
+ Skeleton driver for Virtual Media Controller


A bit more verbose description would be nice.


diff --git 

Re: [PATCH 2/2] em28xx: simplify ID-reading from Micron sensors

2017-03-24 Thread Mauro Carvalho Chehab
Em Thu, 23 Mar 2017 19:03:20 +0100
Frank Schäfer  escreveu:

> Am 23.03.2017 um 13:56 schrieb Mauro Carvalho Chehab:
> > Em Thu, 23 Mar 2017 13:01:32 +0100
> > Frank Schäfer  escreveu:
> >  
> >> Am 22.03.2017 um 15:46 schrieb Mauro Carvalho Chehab:  
> >>> Em Sun, 19 Feb 2017 19:29:18 +0100
> >>> Frank Schäfer  escreveu:
> >>> 
>  Use i2c_smbus_read_word_data() instead of i2c_master_send() and
>  i2c_master_recv() for reading the ID of Micorn sensors.
>  Bytes need to be swapped afterwards, because i2c_smbus_read_word_data()
>  assumes that the received bytes are little-endian byte order (as 
>  specified
>  by smbus), while Micron sensors with 16 bit register width use big endian
>  byte order.
> 
>  Signed-off-by: Frank Schäfer 
>  ---
> drivers/media/usb/em28xx/em28xx-camera.c | 28 
>  
> 1 file changed, 4 insertions(+), 24 deletions(-)
> 
>  diff --git a/drivers/media/usb/em28xx/em28xx-camera.c 
>  b/drivers/media/usb/em28xx/em28xx-camera.c
>  index 7b4129ab1cf9..4839479624e7 100644
>  --- a/drivers/media/usb/em28xx/em28xx-camera.c
>  +++ b/drivers/media/usb/em28xx/em28xx-camera.c
>  @@ -106,8 +106,6 @@ static int em28xx_probe_sensor_micron(struct em28xx 
>  *dev)
> {
>   int ret, i;
>   char *name;
>  -u8 reg;
>  -__be16 id_be;
>   u16 id;
> 
>   struct i2c_client *client = >i2c_client[dev->def_i2c_bus];
>  @@ -115,10 +113,8 @@ static int em28xx_probe_sensor_micron(struct em28xx 
>  *dev)
>   dev->em28xx_sensor = EM28XX_NOSENSOR;
>   for (i = 0; micron_sensor_addrs[i] != I2C_CLIENT_END; i++) {
>   client->addr = micron_sensor_addrs[i];
>  -/* NOTE: i2c_smbus_read_word_data() doesn't work with 
>  BE data */
>   /* Read chip ID from register 0x00 */
>  -reg = 0x00;
>  -ret = i2c_master_send(client, , 1);
>  +ret = i2c_smbus_read_word_data(client, 0x00); /* 
>  assumes LE */
>   if (ret < 0) {
>   if (ret != -ENXIO)
>   dev_err(>intf->dev,
>  @@ -126,24 +122,9 @@ static int em28xx_probe_sensor_micron(struct em28xx 
>  *dev)
>  client->addr << 1, ret);
>   continue;
>   }
>  -ret = i2c_master_recv(client, (u8 *)_be, 2);
>  -if (ret < 0) {
>  -dev_err(>intf->dev,
>  -"couldn't read from i2c device 0x%02x: 
>  error %i\n",
>  -client->addr << 1, ret);
>  -continue;
>  -}
>  -id = be16_to_cpu(id_be);
>  +id = swab16(ret); /* LE -> BE */  
> >>> That's wrong! You can't assume that CPU is BE, as some archs use LE.
> >>>
> >>> You should, instead, call le16_to_cpu(), to be sure that it will be
> >>> doing the right thing.
> >>>
> >>> Something like:
> >>>
> >>>   id = le16_to_cpu((__le16)ret);  
> >> SMBus read/write word transfers are always LE (see SMBus spec section
> >> 6.5.5),
> >> which is also what i2c_smbus_xfer_emulated() assumes:
> >> http://lxr.free-electrons.com/source/drivers/i2c/i2c-core.c#L3485  
> > I got that part, but, if the CPU is also LE, doing swab16() is
> > wrong. It should swap it *only* if the CPU is BE.  
> No, it should always be swapped, because the bytes are always transfered 
> in the wrong order.
> The cpu endianess doesn't matter, (0x12 << 8) | 0x34 is always 0x1234.

You still didn't get it.

Let's assume that the ID is 0x148c (MT9M112).

This value, represented in low endian, is stored in memory as:

unsigned char __id[2] = { 0x8c, 0x14 };

If we do:
u16 ret = *(u16 *)__id;

What's stored at "ret" will depend if the sistem is LE or BE:

on LE, ret == 0x148c
on BE, ret == 0x8c14

If you do:
u16 id = swapb16(val)

you'll get:

on LE, id == 0x8c14
on BE, id == 0x148c

So, the value will be *wrong* at LE.

However, if you do:
id = le16_to_cpu((__le16)ret); 

On LE, this will evaluate to id = ret, and on BE, to id = swab16(ret).
So, on both, you'll have:
id = 0x148c.


Thanks,
Mauro


Re: [Outreachy kernel] [PATCH v2] staging: media: davinci_vpfe:Replace a bit shift.

2017-03-24 Thread Julia Lawall
There should be a spac after every colon in the subject.  Please pay
attention to these small details, so you don't have to send the same patch
over and over.

julia

On Fri, 24 Mar 2017, Arushi Singhal wrote:

> This patch replaces bit shifting on 1 with the BIT(x) macro.
> This was done with coccinelle:
> @@
> constant c;
> @@
>
> -1 << c
> +BIT(c)
>
> Signed-off-by: Arushi Singhal 
> ---
> changes in v2
>  -Remove unnecessary parenthesis.
>
>  drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  2 +-
>  drivers/staging/media/davinci_vpfe/dm365_ipipeif.c |  2 +-
>  drivers/staging/media/davinci_vpfe/dm365_isif.c| 10 +-
>  drivers/staging/media/davinci_vpfe/dm365_resizer.c |  6 +++---
>  4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
> b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
> index 6a3434cebd79..7eeb53217168 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
> +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
> @@ -1815,7 +1815,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct 
> platform_device *pdev)
>   v4l2_subdev_init(sd, _v4l2_ops);
>   sd->internal_ops = _v4l2_internal_ops;
>   strlcpy(sd->name, "DAVINCI IPIPE", sizeof(sd->name));
> - sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
> + sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
>   v4l2_set_subdevdata(sd, ipipe);
>   sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c 
> b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> index 46fd2c7f69c3..c07f028dd6be 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
> @@ -1021,7 +1021,7 @@ int vpfe_ipipeif_init(struct vpfe_ipipeif_device 
> *ipipeif,
>
>   sd->internal_ops = _v4l2_internal_ops;
>   strlcpy(sd->name, "DAVINCI IPIPEIF", sizeof(sd->name));
> - sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
> + sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
>
>   v4l2_set_subdevdata(sd, ipipeif);
>
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c 
> b/drivers/staging/media/davinci_vpfe/dm365_isif.c
> index 569bcdc9ce2f..74b1247203b1 100644
> --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
> +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
> @@ -821,7 +821,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
> vpfe_isif_dfc *vdfc)
>
>   /* Correct whole line or partial */
>   if (vdfc->corr_whole_line)
> - val |= 1 << ISIF_VDFC_CORR_WHOLE_LN_SHIFT;
> + val |= BIT(ISIF_VDFC_CORR_WHOLE_LN_SHIFT);
>
>   /* level shift value */
>   val |= (vdfc->def_level_shift & ISIF_VDFC_LEVEL_SHFT_MASK) <<
> @@ -849,7 +849,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
> vpfe_isif_dfc *vdfc)
>
>   val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
>   /* set DFCMARST and set DFCMWR */
> - val |= 1 << ISIF_DFCMEMCTL_DFCMARST_SHIFT;
> + val |= BIT(ISIF_DFCMEMCTL_DFCMARST_SHIFT);
>   val |= 1;
>   isif_write(isif->isif_cfg.base_addr, val, DFCMEMCTL);
>
> @@ -880,7 +880,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
> vpfe_isif_dfc *vdfc)
>   }
>   val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
>   /* clear DFCMARST and set DFCMWR */
> - val &= ~(1 << ISIF_DFCMEMCTL_DFCMARST_SHIFT);
> + val &= ~BIT(ISIF_DFCMEMCTL_DFCMARST_SHIFT);
>   val |= 1;
>   isif_write(isif->isif_cfg.base_addr, val, DFCMEMCTL);
>
> @@ -1140,7 +1140,7 @@ static int isif_config_raw(struct v4l2_subdev *sd, int 
> mode)
>   isif_write(isif->isif_cfg.base_addr, val, CGAMMAWD);
>   /* Configure DPCM compression settings */
>   if (params->v4l2_pix_fmt == V4L2_PIX_FMT_SGRBG10DPCM8) {
> - val =  1 << ISIF_DPCM_EN_SHIFT;
> + val =  BIT(ISIF_DPCM_EN_SHIFT);
>   val |= (params->dpcm_predictor &
>   ISIF_DPCM_PREDICTOR_MASK) << ISIF_DPCM_PREDICTOR_SHIFT;
>   }
> @@ -2044,7 +2044,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, 
> struct platform_device *pdev)
>   v4l2_subdev_init(sd, _v4l2_ops);
>   sd->internal_ops = _v4l2_internal_ops;
>   strlcpy(sd->name, "DAVINCI ISIF", sizeof(sd->name));
> - sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
> + sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
>   v4l2_set_subdevdata(sd, isif);
>   sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
>   pads[ISIF_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
> diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c 
> b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
> index 857b0e847c5e..3b3469adaf91 100644
> --- 

[no subject]

2017-03-24 Thread Scott Tisdale
Greetings Linux

http://trevorroth.com/calcloan.php?sets=mz25y2rpda7g4wsb


Scott


[PATCH v2 12/12] [media] ddbridge: support STV0367-based cards and modules

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

This adds detection and activation for STV0367-based tuner hardware (namely
CineCTv6 bridge cards and older DuoFlex CT addon modules). Utilises the
extended stv0367 demod driver.

TDA18212 i2c_client/regmap-api code was originally implemented by
Antti Palosaari  in a variant to update the ddbridge code
from the vendor dddvb package (formal ack for these parts received).
Original patch at [1].

When boards with STV0367 are cold-started, there might be issues with the
I2C gate, causing the TDA18212 detection/probe to fail. For these demods,
a workaround is implemented to do the tuner probe again which will result
in success if no other issue arises. Other demod/port types won't be
retried.

Signed-off-by: Daniel Scheller 

[1] https://patchwork.linuxtv.org/patch/25146/
---
 drivers/media/pci/ddbridge/Kconfig |   3 +
 drivers/media/pci/ddbridge/ddbridge-core.c | 138 +
 drivers/media/pci/ddbridge/ddbridge.h  |   1 +
 3 files changed, 142 insertions(+)

diff --git a/drivers/media/pci/ddbridge/Kconfig 
b/drivers/media/pci/ddbridge/Kconfig
index 44e5dc1..16ede23 100644
--- a/drivers/media/pci/ddbridge/Kconfig
+++ b/drivers/media/pci/ddbridge/Kconfig
@@ -6,6 +6,8 @@ config DVB_DDBRIDGE
select DVB_STV090x if MEDIA_SUBDRV_AUTOSELECT
select DVB_DRXK if MEDIA_SUBDRV_AUTOSELECT
select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
---help---
  Support for cards with the Digital Devices PCI express bridge:
  - Octopus PCIe Bridge
@@ -14,5 +16,6 @@ config DVB_DDBRIDGE
  - DuoFlex S2 Octopus
  - DuoFlex CT Octopus
  - cineS2(v6)
+ - CineCTv6 and DuoFlex CT (STV0367-based)
 
  Say Y if you own such a card and want to use it.
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 340cff0..085fea0 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -39,6 +39,9 @@
 #include "stv090x.h"
 #include "lnbh24.h"
 #include "drxk.h"
+#include "stv0367.h"
+#include "stv0367_priv.h"
+#include "tda18212.h"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
@@ -609,6 +612,103 @@ static int tuner_attach_tda18271(struct ddb_input *input)
 
/**/
 
/**/
 
+static struct stv0367_config ddb_stv0367_config[] = {
+   {
+   .demod_address = 0x1f,
+   .xtal = 2700,
+   .if_khz = 0,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   }, {
+   .demod_address = 0x1e,
+   .xtal = 2700,
+   .if_khz = 0,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   },
+};
+
+static int demod_attach_stv0367(struct ddb_input *input)
+{
+   struct i2c_adapter *i2c = >port->i2c->adap;
+
+   /* attach frontend */
+   input->fe = dvb_attach(stv0367ddb_attach,
+   _stv0367_config[(input->nr & 1)], i2c);
+
+   if (!input->fe) {
+   printk(KERN_ERR "stv0367ddb_attach failed (not found?)\n");
+   return -ENODEV;
+   }
+
+   input->fe->sec_priv = input;
+   input->gate_ctrl = input->fe->ops.i2c_gate_ctrl;
+   input->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
+
+   return 0;
+}
+
+static int tuner_attach_tda18212(struct ddb_input *input, u32 porttype)
+{
+   struct i2c_adapter *adapter = >port->i2c->adap;
+   struct i2c_client *client;
+   struct tda18212_config config = {
+   .fe = input->fe,
+   .if_dvbt_6 = 3550,
+   .if_dvbt_7 = 3700,
+   .if_dvbt_8 = 4150,
+   .if_dvbt2_6 = 3250,
+   .if_dvbt2_7 = 4000,
+   .if_dvbt2_8 = 4000,
+   .if_dvbc = 5000,
+   };
+   struct i2c_board_info board_info = {
+   .type = "tda18212",
+   .platform_data = ,
+   };
+
+   if (input->nr & 1)
+   board_info.addr = 0x63;
+   else
+   board_info.addr = 0x60;
+
+   request_module(board_info.type);
+
+   /* perform tuner init/attach */
+   client = i2c_new_device(adapter, _info);
+   /* hack/workaround: STV0367 demods sometimes misbehaves on it's
+* I2C gate when cold started, so try again for this hardware
+* combination
+*/
+   if ((client == NULL || client->dev.driver == NULL)
+   && (porttype == 

[PATCH v2 00/12] stv0367/ddbridge: support CTv6/FlexCT hardware

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

These patches enhance the functionality of dvb-frontends/stv0367 to work
with Digital Devices hardware driven by the ST STV0367 demodulator chip
and adds probe & attach bits to ddbridge to make use of them, effectively
enabling full support for CineCTv6 PCIe bridges and (older) DuoFlex CT
addon modules.

While the stv0367 code basically works with the DD hardware (e.g. setup
of demodulation works for both -C and -T delivery systems), some bits
(mostly initialisation) have to be done differently. Also, the static
if_khz configuration is not sufficient as the TDA18212 tuner works at
different IF speeds depending on the delivery system and carrier
bandwidth, so functionality is added to read that speed from the tuner.

The most important part is the addition of register default tabs for
the DD boards, the DD demod initialisation code and the automated
operation mode switch (OFDM vs. QAM) to be able to provide both systems
in one DVB frontend. Everything else is provided by the existing code
or the existing code is enhanced where it didn't suffice. So instead
of duplicating the driver, the existing one is reused. Patches are
laid out in a way to add each enhancement in small increments so they
should be fairly easy to review.

A note on the i2c_gatectrl flag: In the meantime (since v1) I got
clarification why this is needed (reception issues), so I'd prefer to
not diverge from that behaviour to not cause issues for anyone.

Checkpatch complains about some minor style issues, however the patches
were cleaned up beforehand and - where it still complains - match the
rest of the code style throughout the respective files.

In patches where code parts have been picked from other places, proper
credits to the original author is given and permissions where granted
beforehand.

Resulting STV0367/DD support was successfully tested with TVHeadend
and VDR setups by some users, with -C and -T combinations and two+four
port tuner setups (CTv6 with and without attached CT modules).

Apologizes if anything regarding the patch submission is/went wrong,
as this is my first time contribution to OSS via patch emails.

I'd appreciate any comments or even reviews on this to see if the way
the device support is done is acceptable at all, and how to proceed with
this.

Changes from v1 to v2:
 - tda18212 modification/hack removed and implemented into ddbridge
   where it shouldn't harm but still is needed due to HW quirks
 - symbolrate_min/max added to dvb_frontend_ops
 - updated commit message body of the i2c_gatectrl flag patch (1/12) so
   it is more clear why this is needed and relevant, updated commit
   message body of 12/12 (ddbridge patch) aswell

Daniel Scheller (12):
  [media] dvb-frontends/stv0367: add flag to make i2c_gatectrl optional
  [media] dvb-frontends/stv0367: print CPAMP status only if stv_debug is
enabled
  [media] dvb-frontends/stv0367: refactor defaults table handling
  [media] dvb-frontends/stv0367: move out tables, support multiple tab
variants
  [media] dvb-frontends/stv0367: make PLLSETUP a function, add 58MHz IC
speed
  [media] dvb-frontends/stv0367: make full reinit on set_frontend()
optional
  [media] dvb-frontends/stv0367: support reading if_khz from tuner
config
  [media] dvb-frontends/stv0367: selectable QAM FEC Lock status register
  [media] dvb-frontends/stv0367: fix symbol rate conditions in
cab_SetQamSize()
  [media] dvb-frontends/stv0367: add defaults for use w/DD-branded
devices
  [media] dvb-frontends/stv0367: add Digital Devices compatibility
  [media] ddbridge: support STV0367-based cards and modules

 drivers/media/dvb-frontends/stv0367.c  | 1169 ++---
 drivers/media/dvb-frontends/stv0367.h  |   13 +
 drivers/media/dvb-frontends/stv0367_defs.h | 1301 
 drivers/media/dvb-frontends/stv0367_regs.h |4 -
 drivers/media/pci/ddbridge/Kconfig |3 +
 drivers/media/pci/ddbridge/ddbridge-core.c |  138 +++
 drivers/media/pci/ddbridge/ddbridge.h  |1 +
 7 files changed, 1917 insertions(+), 712 deletions(-)
 create mode 100644 drivers/media/dvb-frontends/stv0367_defs.h

-- 
2.10.2



[PATCH v2 04/12] [media] dvb-frontends/stv0367: move out tables, support multiple tab variants

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

Move the *ter and *cab st_register tables into a separate header file and
additionally organize them via a multidimensional array, allowing to add
more tables with differing init values, and also prepare for a base init
table which should contain general setup values. Also add a state var to
store the table triplet to be used.

Also fixes three minor style problems reported by checkpatch.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c  | 658 +--
 drivers/media/dvb-frontends/stv0367_defs.h | 693 +
 2 files changed, 701 insertions(+), 650 deletions(-)
 create mode 100644 drivers/media/dvb-frontends/stv0367_defs.h

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index 5ed52ec..5b52673 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -26,6 +26,7 @@
 #include 
 
 #include "stv0367.h"
+#include "stv0367_defs.h"
 #include "stv0367_regs.h"
 #include "stv0367_priv.h"
 
@@ -91,462 +92,7 @@ struct stv0367_state {
struct stv0367ter_state *ter_state;
/* flags for operation control */
u8 use_i2c_gatectrl;
-};
-
-struct st_register {
-   u16 addr;
-   u8  value;
-};
-
-/* values for STV4100 XTAL=30M int clk=53.125M*/
-static const struct st_register def0367ter[] = {
-   {R367TER_ID,0x60},
-   {R367TER_I2CRPT,0xa0},
-   /* {R367TER_I2CRPT, 0x22},*/
-   {R367TER_TOPCTRL,   0x00},/* for xc5000; was 0x02 */
-   {R367TER_IOCFG0,0x40},
-   {R367TER_DAC0R, 0x00},
-   {R367TER_IOCFG1,0x00},
-   {R367TER_DAC1R, 0x00},
-   {R367TER_IOCFG2,0x62},
-   {R367TER_SDFR,  0x00},
-   {R367TER_STATUS,0xf8},
-   {R367TER_AUX_CLK,   0x0a},
-   {R367TER_FREESYS1,  0x00},
-   {R367TER_FREESYS2,  0x00},
-   {R367TER_FREESYS3,  0x00},
-   {R367TER_GPIO_CFG,  0x55},
-   {R367TER_GPIO_CMD,  0x00},
-   {R367TER_AGC2MAX,   0xff},
-   {R367TER_AGC2MIN,   0x00},
-   {R367TER_AGC1MAX,   0xff},
-   {R367TER_AGC1MIN,   0x00},
-   {R367TER_AGCR,  0xbc},
-   {R367TER_AGC2TH,0x00},
-   {R367TER_AGC12C,0x00},
-   {R367TER_AGCCTRL1,  0x85},
-   {R367TER_AGCCTRL2,  0x1f},
-   {R367TER_AGC1VAL1,  0x00},
-   {R367TER_AGC1VAL2,  0x00},
-   {R367TER_AGC2VAL1,  0x6f},
-   {R367TER_AGC2VAL2,  0x05},
-   {R367TER_AGC2PGA,   0x00},
-   {R367TER_OVF_RATE1, 0x00},
-   {R367TER_OVF_RATE2, 0x00},
-   {R367TER_GAIN_SRC1, 0xaa},/* for xc5000; was 0x2b */
-   {R367TER_GAIN_SRC2, 0xd6},/* for xc5000; was 0x04 */
-   {R367TER_INC_DEROT1,0x55},
-   {R367TER_INC_DEROT2,0x55},
-   {R367TER_PPM_CPAMP_DIR, 0x2c},
-   {R367TER_PPM_CPAMP_INV, 0x00},
-   {R367TER_FREESTFE_1,0x00},
-   {R367TER_FREESTFE_2,0x1c},
-   {R367TER_DCOFFSET,  0x00},
-   {R367TER_EN_PROCESS,0x05},
-   {R367TER_SDI_SMOOTHER,  0x80},
-   {R367TER_FE_LOOP_OPEN,  0x1c},
-   {R367TER_FREQOFF1,  0x00},
-   {R367TER_FREQOFF2,  0x00},
-   {R367TER_FREQOFF3,  0x00},
-   {R367TER_TIMOFF1,   0x00},
-   {R367TER_TIMOFF2,   0x00},
-   {R367TER_EPQ,   0x02},
-   {R367TER_EPQAUTO,   0x01},
-   {R367TER_SYR_UPDATE,0xf5},
-   {R367TER_CHPFREE,   0x00},
-   {R367TER_PPM_STATE_MAC, 0x23},
-   {R367TER_INR_THRESHOLD, 0xff},
-   {R367TER_EPQ_TPS_ID_CELL, 0xf9},
-   {R367TER_EPQ_CFG,   0x00},
-   {R367TER_EPQ_STATUS,0x01},
-   {R367TER_AUTORELOCK,0x81},
-   {R367TER_BER_THR_VMSB,  0x00},
-   {R367TER_BER_THR_MSB,   0x00},
-   {R367TER_BER_THR_LSB,   0x00},
-   {R367TER_CCD,   0x83},
-   {R367TER_SPECTR_CFG,0x00},
-   {R367TER_CHC_DUMMY, 0x18},
-   {R367TER_INC_CTL,   0x88},
-   {R367TER_INCTHRES_COR1, 0xb4},
-   {R367TER_INCTHRES_COR2, 0x96},
-   {R367TER_INCTHRES_DET1, 0x0e},
-   {R367TER_INCTHRES_DET2, 0x11},
-   {R367TER_IIR_CELLNB,0x8d},
-   {R367TER_IIRCX_COEFF1_MSB, 0x00},
-   {R367TER_IIRCX_COEFF1_LSB, 0x00},
-   {R367TER_IIRCX_COEFF2_MSB, 0x09},
-   {R367TER_IIRCX_COEFF2_LSB, 0x18},
-   {R367TER_IIRCX_COEFF3_MSB, 0x14},
-   {R367TER_IIRCX_COEFF3_LSB, 0x9c},
-   {R367TER_IIRCX_COEFF4_MSB, 0x00},
-   {R367TER_IIRCX_COEFF4_LSB, 0x00},
-   {R367TER_IIRCX_COEFF5_MSB, 0x36},
-   {R367TER_IIRCX_COEFF5_LSB, 0x42},
-   {R367TER_FEPATH_CFG,0x00},
-   {R367TER_PMC1_FUNC, 0x65},
-   {R367TER_PMC1_FOR,  0x00},
-   {R367TER_PMC2_FUNC, 0x00},
-   {R367TER_STATUS_ERR_DA, 0xe0},
-   {R367TER_DIG_AGC_R, 0xfe},
-  

[PATCH v2 06/12] [media] dvb-frontends/stv0367: make full reinit on set_frontend() optional

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

Every time dvb_frontend_ops.set_frontend() is called, an almost full reinit
of the demodulator will be performed. While this might cause a slight delay
when switching channels due to all involved tables being rewritten, it can
even be dangerous in certain causes in that the demod may lock up and
requires to be powercycled (this can happen on Digital Devices hardware).
So this adds a flag if it should be done, and to not change behaviour with
existing card support, it'll be enabled in all cases.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index da10d9a..9370afa 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -93,6 +93,7 @@ struct stv0367_state {
/* flags for operation control */
u8 use_i2c_gatectrl;
u8 deftabs;
+   u8 reinit_on_setfrontend;
 };
 
 #define RF_LOOKUP_TABLE_SIZE  31
@@ -1217,7 +1218,8 @@ static int stv0367ter_set_frontend(struct dvb_frontend 
*fe)
s8 num_trials, index;
u8 SenseTrials[] = { INVERSION_ON, INVERSION_OFF };
 
-   stv0367ter_init(fe);
+   if (state->reinit_on_setfrontend)
+   stv0367ter_init(fe);
 
if (fe->ops.tuner_ops.set_params) {
if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl)
@@ -1717,6 +1719,7 @@ struct dvb_frontend *stv0367ter_attach(const struct 
stv0367_config *config,
/* demod operation options */
state->use_i2c_gatectrl = 1;
state->deftabs = STV0367_DEFTAB_GENERIC;
+   state->reinit_on_setfrontend = 1;
 
dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id);
 
@@ -2511,7 +2514,8 @@ static int stv0367cab_set_frontend(struct dvb_frontend 
*fe)
break;
}
 
-   stv0367cab_init(fe);
+   if (state->reinit_on_setfrontend)
+   stv0367cab_init(fe);
 
/* Tuner Frequency Setting */
if (fe->ops.tuner_ops.set_params) {
@@ -2835,6 +2839,7 @@ struct dvb_frontend *stv0367cab_attach(const struct 
stv0367_config *config,
/* demod operation options */
state->use_i2c_gatectrl = 1;
state->deftabs = STV0367_DEFTAB_GENERIC;
+   state->reinit_on_setfrontend = 1;
 
dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id);
 
-- 
2.10.2



[PATCH v2 10/12] [media] dvb-frontends/stv0367: add defaults for use w/DD-branded devices

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

Digital Devices uses defaults tables in their stv0367dd demod driver
variant which differ in a few registers, at least enough that no stable
operation can be provided with the tables already present in the driver
(init succeeds and DVB reception works but at least when the driver is
reloaded using rmmod/modprobe, the demod goes into a crashed state in a
way it doesn't react on any I2C command anymore, while even more
side-effects may occur), so there's a good reason to better have another
set of defaults.

Defaults originating from the stv0367dd driver. Permission to reuse them
was formally granted by Ralph Metzler .

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367_defs.h | 610 -
 1 file changed, 609 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/stv0367_defs.h 
b/drivers/media/dvb-frontends/stv0367_defs.h
index 53faad6..277d297 100644
--- a/drivers/media/dvb-frontends/stv0367_defs.h
+++ b/drivers/media/dvb-frontends/stv0367_defs.h
@@ -25,7 +25,8 @@
 #include "stv0367_regs.h"
 
 #define STV0367_DEFTAB_GENERIC 0
-#define STV0367_DEFTAB_MAX 1
+#define STV0367_DEFTAB_DDB 1
+#define STV0367_DEFTAB_MAX 2
 
 #define STV0367_TAB_TER0
 #define STV0367_TAB_CAB1
@@ -680,6 +681,611 @@ static const struct st_register def0367cab[] = {
{0x,0x00},
 };
 
+/**
+ *
+ * Defaults / Tables for Digital Devices C/T Cine/Flex devices
+ *
+ **/
+
+static const struct st_register def0367dd_ofdm[] = {
+   {R367TER_AGC2MAX,0xff},
+   {R367TER_AGC2MIN,0x00},
+   {R367TER_AGC1MAX,0xff},
+   {R367TER_AGC1MIN,0x00},
+   {R367TER_AGCR,   0xbc},
+   {R367TER_AGC2TH, 0x00},
+   {R367TER_AGCCTRL1,   0x85},
+   {R367TER_AGCCTRL2,   0x1f},
+   {R367TER_AGC1VAL1,   0x00},
+   {R367TER_AGC1VAL2,   0x00},
+   {R367TER_AGC2VAL1,   0x6f},
+   {R367TER_AGC2VAL2,   0x05},
+   {R367TER_AGC2PGA,0x00},
+   {R367TER_OVF_RATE1,  0x00},
+   {R367TER_OVF_RATE2,  0x00},
+   {R367TER_GAIN_SRC1,  0x2b},
+   {R367TER_GAIN_SRC2,  0x04},
+   {R367TER_INC_DEROT1, 0x55},
+   {R367TER_INC_DEROT2, 0x55},
+   {R367TER_PPM_CPAMP_DIR,  0x2c},
+   {R367TER_PPM_CPAMP_INV,  0x00},
+   {R367TER_FREESTFE_1, 0x00},
+   {R367TER_FREESTFE_2, 0x1c},
+   {R367TER_DCOFFSET,   0x00},
+   {R367TER_EN_PROCESS, 0x05},
+   {R367TER_SDI_SMOOTHER,   0x80},
+   {R367TER_FE_LOOP_OPEN,   0x1c},
+   {R367TER_FREQOFF1,   0x00},
+   {R367TER_FREQOFF2,   0x00},
+   {R367TER_FREQOFF3,   0x00},
+   {R367TER_TIMOFF1,0x00},
+   {R367TER_TIMOFF2,0x00},
+   {R367TER_EPQ,0x02},
+   {R367TER_EPQAUTO,0x01},
+   {R367TER_SYR_UPDATE, 0xf5},
+   {R367TER_CHPFREE,0x00},
+   {R367TER_PPM_STATE_MAC,  0x23},
+   {R367TER_INR_THRESHOLD,  0xff},
+   {R367TER_EPQ_TPS_ID_CELL,0xf9},
+   {R367TER_EPQ_CFG,0x00},
+   {R367TER_EPQ_STATUS, 0x01},
+   {R367TER_AUTORELOCK, 0x81},
+   {R367TER_BER_THR_VMSB,   0x00},
+   {R367TER_BER_THR_MSB,0x00},
+   {R367TER_BER_THR_LSB,0x00},
+   {R367TER_CCD,0x83},
+   {R367TER_SPECTR_CFG, 0x00},
+   {R367TER_CHC_DUMMY,  0x18},
+   {R367TER_INC_CTL,0x88},
+   {R367TER_INCTHRES_COR1,  0xb4},
+   {R367TER_INCTHRES_COR2,  0x96},
+   {R367TER_INCTHRES_DET1,  0x0e},
+   {R367TER_INCTHRES_DET2,  0x11},
+   {R367TER_IIR_CELLNB, 0x8d},
+   {R367TER_IIRCX_COEFF1_MSB,   0x00},
+   {R367TER_IIRCX_COEFF1_LSB,   0x00},
+   {R367TER_IIRCX_COEFF2_MSB,   0x09},
+   {R367TER_IIRCX_COEFF2_LSB,   0x18},
+   {R367TER_IIRCX_COEFF3_MSB,   0x14},
+   {R367TER_IIRCX_COEFF3_LSB,   0x9c},
+   {R367TER_IIRCX_COEFF4_MSB,   0x00},
+   {R367TER_IIRCX_COEFF4_LSB,   0x00},
+   {R367TER_IIRCX_COEFF5_MSB,   0x36},
+   {R367TER_IIRCX_COEFF5_LSB,   0x42},
+   {R367TER_FEPATH_CFG, 0x00},
+   {R367TER_PMC1_FUNC,  0x65},
+   {R367TER_PMC1_FOR,   0x00},
+   {R367TER_PMC2_FUNC,  0x00},
+   {R367TER_STATUS_ERR_DA,  0xe0},
+   {R367TER_DIG_AGC_R,

[PATCH v2 05/12] [media] dvb-frontends/stv0367: make PLLSETUP a function, add 58MHz IC speed

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

This moves the PLL SETUP code from stv0367ter_init() into a dedicated
function, and also make it possible to configure 58Mhz IC speed at
27MHz Xtal (used on STV0367-based DDB cards/modules in QAM mode).

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 73 +++
 drivers/media/dvb-frontends/stv0367.h |  3 ++
 2 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index 5b52673..da10d9a 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -271,6 +271,53 @@ static void stv0367_write_table(struct stv0367_state 
*state,
}
 }
 
+static void stv0367_pll_setup(struct stv0367_state *state,
+   u32 icspeed, u32 xtal)
+{
+   /* note on regs: R367TER_* and R367CAB_* defines each point to
+* 0xf0d8, so just use R367TER_ for both cases
+*/
+
+   switch (icspeed) {
+   case STV0367_ICSPEED_58000:
+   switch (xtal) {
+   default:
+   case 2700:
+   dprintk("STV0367 SetCLKgen for 58MHz IC and 27Mhz 
crystal\n");
+   /* PLLMDIV: 27, PLLNDIV: 232 */
+   stv0367_writereg(state, R367TER_PLLMDIV, 0x1b);
+   stv0367_writereg(state, R367TER_PLLNDIV, 0xe8);
+   break;
+   }
+   break;
+   default:
+   case STV0367_ICSPEED_53125:
+   switch (xtal) {
+   /* set internal freq to 53.125MHz */
+   case 1600:
+   stv0367_writereg(state, R367TER_PLLMDIV, 0x2);
+   stv0367_writereg(state, R367TER_PLLNDIV, 0x1b);
+   break;
+   case 2500:
+   stv0367_writereg(state, R367TER_PLLMDIV, 0xa);
+   stv0367_writereg(state, R367TER_PLLNDIV, 0x55);
+   break;
+   default:
+   case 2700:
+   dprintk("FE_STV0367TER_SetCLKgen for 27Mhz\n");
+   stv0367_writereg(state, R367TER_PLLMDIV, 0x1);
+   stv0367_writereg(state, R367TER_PLLNDIV, 0x8);
+   break;
+   case 3000:
+   stv0367_writereg(state, R367TER_PLLMDIV, 0xc);
+   stv0367_writereg(state, R367TER_PLLNDIV, 0x55);
+   break;
+   }
+   }
+
+   stv0367_writereg(state, R367TER_PLLSETUP, 0x18);
+}
+
 static int stv0367ter_gate_ctrl(struct dvb_frontend *fe, int enable)
 {
struct stv0367_state *state = fe->demodulator_priv;
@@ -918,31 +965,7 @@ static int stv0367ter_init(struct dvb_frontend *fe)
stv0367_write_table(state,
stv0367_deftabs[state->deftabs][STV0367_TAB_TER]);
 
-   switch (state->config->xtal) {
-   /*set internal freq to 53.125MHz */
-   case 1600:
-   stv0367_writereg(state, R367TER_PLLMDIV, 0x2);
-   stv0367_writereg(state, R367TER_PLLNDIV, 0x1b);
-   stv0367_writereg(state, R367TER_PLLSETUP, 0x18);
-   break;
-   case 2500:
-   stv0367_writereg(state, R367TER_PLLMDIV, 0xa);
-   stv0367_writereg(state, R367TER_PLLNDIV, 0x55);
-   stv0367_writereg(state, R367TER_PLLSETUP, 0x18);
-   break;
-   default:
-   case 2700:
-   dprintk("FE_STV0367TER_SetCLKgen for 27Mhz\n");
-   stv0367_writereg(state, R367TER_PLLMDIV, 0x1);
-   stv0367_writereg(state, R367TER_PLLNDIV, 0x8);
-   stv0367_writereg(state, R367TER_PLLSETUP, 0x18);
-   break;
-   case 3000:
-   stv0367_writereg(state, R367TER_PLLMDIV, 0xc);
-   stv0367_writereg(state, R367TER_PLLNDIV, 0x55);
-   stv0367_writereg(state, R367TER_PLLSETUP, 0x18);
-   break;
-   }
+   stv0367_pll_setup(state, STV0367_ICSPEED_53125, state->config->xtal);
 
stv0367_writereg(state, R367TER_I2CRPT, 0xa0);
stv0367_writereg(state, R367TER_ANACTRL, 0x00);
diff --git a/drivers/media/dvb-frontends/stv0367.h 
b/drivers/media/dvb-frontends/stv0367.h
index 26c38a0..aaa0236 100644
--- a/drivers/media/dvb-frontends/stv0367.h
+++ b/drivers/media/dvb-frontends/stv0367.h
@@ -25,6 +25,9 @@
 #include 
 #include "dvb_frontend.h"
 
+#define STV0367_ICSPEED_53125  53125000
+#define STV0367_ICSPEED_58000  5800
+
 struct stv0367_config {
u8 demod_address;
u32 xtal;
-- 
2.10.2



[PATCH v2 11/12] [media] dvb-frontends/stv0367: add Digital Devices compatibility

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

This - in conjunction with the previous changes - makes it possible to use
the STV0367 DVB-C/T demodulator driver with Digital Devices hardware having
this demodulator soldered on them (namely CineCTv6 bridges and some earlier
DuoFlex CT addon modules).

The changes do the following:

- add a third *_attach function which will make use of a third frontend_ops
  struct which announces both -C and -T support (the same as with DD's own
  driver stv0367dd). This is necessary to support both delivery systems
  on one FE without having to do large conversions to VB2 or the need to
  select either -C or -T mode via modparams and the like. Additionally,
  the frontend_ops point to new "glue" functions which will then call into
  the existing functionality depending on the active delivery system/demod
  state (all used functionality works almost OOTB).
- Demod initialisation has been ported from stv0367dd. DD's driver always
  does a full init of both OFDM and QAM cores, with some additional things.
  The active delivery system is remembered and upon switch, the Demod will
  be reconfigured to work in OFDM or QAM mode (that's what the ddb_setup_XX
  functions are used for). Note that in QAM mode, the DD demods work with
  an IC speed of 58Mhz. It's not very good to perform full reinits upon
  Demod mode changes since in very rare occasions this can lead to the I2C
  interface or the whole Demod to crash, requiring a powercycle, thus the
  flag to perform full reinit is set to disabled.
- A little enum is added for named identifiers of the current Demod state.

Initialisation code/register writes originate from stv0367dd. Permission
to reuse was formally granted by Ralph Metzler .

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 325 ++
 drivers/media/dvb-frontends/stv0367.h |  10 ++
 2 files changed, 335 insertions(+)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index ffc046a..77dd76d 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -46,6 +46,8 @@ module_param_named(i2c_debug, i2cdebug, int, 0644);
} while (0)
/* DVB-C */
 
+enum active_demod_state { demod_none, demod_ter, demod_cab };
+
 struct stv0367cab_state {
enum stv0367_cab_signal_typestate;
u32 mclk;
@@ -96,6 +98,7 @@ struct stv0367_state {
u8 deftabs;
u8 reinit_on_setfrontend;
u8 auto_if_khz;
+   enum active_demod_state activedemod;
 };
 
 #define RF_LOOKUP_TABLE_SIZE  31
@@ -2880,6 +2883,328 @@ struct dvb_frontend *stv0367cab_attach(const struct 
stv0367_config *config,
 }
 EXPORT_SYMBOL(stv0367cab_attach);
 
+/*
+ * Functions for operation on Digital Devices hardware
+ */
+
+static void stv0367ddb_setup_ter(struct stv0367_state *state)
+{
+   stv0367_writereg(state, R367TER_DEBUG_LT4, 0x00);
+   stv0367_writereg(state, R367TER_DEBUG_LT5, 0x00);
+   stv0367_writereg(state, R367TER_DEBUG_LT6, 0x00); /* R367CAB_CTRL_1 */
+   stv0367_writereg(state, R367TER_DEBUG_LT7, 0x00); /* R367CAB_CTRL_2 */
+   stv0367_writereg(state, R367TER_DEBUG_LT8, 0x00);
+   stv0367_writereg(state, R367TER_DEBUG_LT9, 0x00);
+
+   /* Tuner Setup */
+   /* Buffer Q disabled, I Enabled, unsigned ADC */
+   stv0367_writereg(state, R367TER_ANADIGCTRL, 0x89);
+   stv0367_writereg(state, R367TER_DUAL_AD12, 0x04); /* ADCQ disabled */
+
+   /* Clock setup */
+   /* PLL bypassed and disabled */
+   stv0367_writereg(state, R367TER_ANACTRL, 0x0D);
+   stv0367_writereg(state, R367TER_TOPCTRL, 0x00); /* Set OFDM */
+
+   /* IC runs at 54 MHz with a 27 MHz crystal */
+   stv0367_pll_setup(state, STV0367_ICSPEED_53125, state->config->xtal);
+
+   msleep(50);
+   /* PLL enabled and used */
+   stv0367_writereg(state, R367TER_ANACTRL, 0x00);
+
+   state->activedemod = demod_ter;
+}
+
+static void stv0367ddb_setup_cab(struct stv0367_state *state)
+{
+   stv0367_writereg(state, R367TER_DEBUG_LT4, 0x00);
+   stv0367_writereg(state, R367TER_DEBUG_LT5, 0x01);
+   stv0367_writereg(state, R367TER_DEBUG_LT6, 0x06); /* R367CAB_CTRL_1 */
+   stv0367_writereg(state, R367TER_DEBUG_LT7, 0x03); /* R367CAB_CTRL_2 */
+   stv0367_writereg(state, R367TER_DEBUG_LT8, 0x00);
+   stv0367_writereg(state, R367TER_DEBUG_LT9, 0x00);
+
+   /* Tuner Setup */
+   /* Buffer Q disabled, I Enabled, signed ADC */
+   stv0367_writereg(state, R367TER_ANADIGCTRL, 0x8B);
+   /* ADCQ disabled */
+   stv0367_writereg(state, R367TER_DUAL_AD12, 0x04);
+
+   /* Clock setup */
+   /* PLL bypassed and disabled */
+   stv0367_writereg(state, R367TER_ANACTRL, 0x0D);
+   /* Set QAM */
+   stv0367_writereg(state, R367TER_TOPCTRL, 0x10);
+
+   /* IC runs at 58 MHz with a 27 MHz crystal */
+   

[PATCH v2 03/12] [media] dvb-frontends/stv0367: refactor defaults table handling

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

Change defaults table writing so tables can be of dynamic length without
having to keep track of their lengths by adding and evaluating an end
marker (reg 0x), also move table writing to a dedicated function to
remove code duplication. Additionally mark st_register tables const since
they're used read-only.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c  | 30 --
 drivers/media/dvb-frontends/stv0367_regs.h |  4 
 2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index 0064d9d..5ed52ec 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -99,7 +99,7 @@ struct st_register {
 };
 
 /* values for STV4100 XTAL=30M int clk=53.125M*/
-static struct st_register def0367ter[STV0367TER_NBREGS] = {
+static const struct st_register def0367ter[] = {
{R367TER_ID,0x60},
{R367TER_I2CRPT,0xa0},
/* {R367TER_I2CRPT, 0x22},*/
@@ -546,6 +546,7 @@ static struct st_register def0367ter[STV0367TER_NBREGS] = {
{R367TER_DEBUG_LT7, 0x00},
{R367TER_DEBUG_LT8, 0x00},
{R367TER_DEBUG_LT9, 0x00},
+   {0x,0x00},
 };
 
 #define RF_LOOKUP_TABLE_SIZE  31
@@ -573,7 +574,7 @@ static const s32 
stv0367cab_RF_LookUp2[RF_LOOKUP_TABLE2_SIZE][RF_LOOKUP_TABLE2_S
}
 };
 
-static struct st_register def0367cab[STV0367CAB_NBREGS] = {
+static const struct st_register def0367cab[] = {
{R367CAB_ID,0x60},
{R367CAB_I2CRPT,0xa0},
/*{R367CAB_I2CRPT,  0x22},*/
@@ -762,6 +763,7 @@ static struct st_register def0367cab[STV0367CAB_NBREGS] = {
{R367CAB_T_O_ID_1,  0x00},
{R367CAB_T_O_ID_2,  0x00},
{R367CAB_T_O_ID_3,  0x00},
+   {0x,0x00},
 };
 
 static
@@ -901,6 +903,20 @@ static u8 stv0367_getbits(u8 reg, u32 label)
return (reg & mask) >> pos;
 }
 #endif
+
+static void stv0367_write_table(struct stv0367_state *state,
+   const struct st_register *deftab)
+{
+   int i = 0;
+
+   while (1) {
+   if (!deftab[i].addr)
+   break;
+   stv0367_writereg(state, deftab[i].addr, deftab[i].value);
+   i++;
+   }
+}
+
 static int stv0367ter_gate_ctrl(struct dvb_frontend *fe, int enable)
 {
struct stv0367_state *state = fe->demodulator_priv;
@@ -1540,15 +1556,12 @@ static int stv0367ter_init(struct dvb_frontend *fe)
 {
struct stv0367_state *state = fe->demodulator_priv;
struct stv0367ter_state *ter_state = state->ter_state;
-   int i;
 
dprintk("%s:\n", __func__);
 
ter_state->pBER = 0;
 
-   for (i = 0; i < STV0367TER_NBREGS; i++)
-   stv0367_writereg(state, def0367ter[i].addr,
-   def0367ter[i].value);
+   stv0367_write_table(state, def0367ter);
 
switch (state->config->xtal) {
/*set internal freq to 53.125MHz */
@@ -2782,13 +2795,10 @@ static int stv0367cab_init(struct dvb_frontend *fe)
 {
struct stv0367_state *state = fe->demodulator_priv;
struct stv0367cab_state *cab_state = state->cab_state;
-   int i;
 
dprintk("%s:\n", __func__);
 
-   for (i = 0; i < STV0367CAB_NBREGS; i++)
-   stv0367_writereg(state, def0367cab[i].addr,
-   def0367cab[i].value);
+   stv0367_write_table(state, def0367cab);
 
switch (state->config->ts_mode) {
case STV0367_DVBCI_CLOCK:
diff --git a/drivers/media/dvb-frontends/stv0367_regs.h 
b/drivers/media/dvb-frontends/stv0367_regs.h
index 1d15862..cc66d93 100644
--- a/drivers/media/dvb-frontends/stv0367_regs.h
+++ b/drivers/media/dvb-frontends/stv0367_regs.h
@@ -2639,8 +2639,6 @@
 #defineR367TER_DEBUG_LT9   0xf405
 #defineF367TER_F_DEBUG_LT9 0xf40500ff
 
-#define STV0367TER_NBREGS  445
-
 /* ID */
 #defineR367CAB_ID  0xf000
 #defineF367CAB_IDENTIFICATIONREGISTER  0xf0ff
@@ -3605,6 +3603,4 @@
 #defineR367CAB_T_O_ID_30xf4d3
 #defineF367CAB_TS_ID_I_H   0xf4d300ff
 
-#define STV0367CAB_NBREGS  187
-
 #endif
-- 
2.10.2



[PATCH v2 01/12] [media] dvb-frontends/stv0367: add flag to make i2c_gatectrl optional

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

Some hardware and bridges (namely ddbridge) require that tuner access is
limited to one concurrent access and wrap i2c gate control with a
mutex_lock when attaching frontends. According to vendor information, this
is required as concurrent tuner reconfiguration can interfere each other
and at worst cause tuning fails or bad reception quality.

If the demod driver does gate_ctrl before setting up tuner parameters, and
the tuner does another I2C enable, it will deadlock forever when gate_ctrl
is wrapped into the mutex_lock. This adds a flag and a conditional before
triggering gate_ctrl in the demodulator driver.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index fd49c43..fc80934 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -89,6 +89,8 @@ struct stv0367_state {
struct stv0367cab_state *cab_state;
/* DVB-T */
struct stv0367ter_state *ter_state;
+   /* flags for operation control */
+   u8 use_i2c_gatectrl;
 };
 
 struct st_register {
@@ -1827,10 +1829,10 @@ static int stv0367ter_set_frontend(struct dvb_frontend 
*fe)
stv0367ter_init(fe);
 
if (fe->ops.tuner_ops.set_params) {
-   if (fe->ops.i2c_gate_ctrl)
+   if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
fe->ops.tuner_ops.set_params(fe);
-   if (fe->ops.i2c_gate_ctrl)
+   if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 0);
}
 
@@ -2321,6 +2323,9 @@ struct dvb_frontend *stv0367ter_attach(const struct 
stv0367_config *config,
state->fe.demodulator_priv = state;
state->chip_id = stv0367_readreg(state, 0xf000);
 
+   /* demod operation options */
+   state->use_i2c_gatectrl = 1;
+
dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id);
 
/* check if the demod is there */
@@ -3120,10 +3125,10 @@ static int stv0367cab_set_frontend(struct dvb_frontend 
*fe)
 
/* Tuner Frequency Setting */
if (fe->ops.tuner_ops.set_params) {
-   if (fe->ops.i2c_gate_ctrl)
+   if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
fe->ops.tuner_ops.set_params(fe);
-   if (fe->ops.i2c_gate_ctrl)
+   if (state->use_i2c_gatectrl && fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 0);
}
 
@@ -3437,6 +3442,9 @@ struct dvb_frontend *stv0367cab_attach(const struct 
stv0367_config *config,
state->fe.demodulator_priv = state;
state->chip_id = stv0367_readreg(state, 0xf000);
 
+   /* demod operation options */
+   state->use_i2c_gatectrl = 1;
+
dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id);
 
/* check if the demod is there */
-- 
2.10.2



[PATCH v2 07/12] [media] dvb-frontends/stv0367: support reading if_khz from tuner config

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

Currently, if_khz is set and provided using the configuration var in
struct stv0367_config. However, in some constellations, the value might be
different for differing channel bandwidths or even -T and -C operation.
When e.g. used in conjunction with TDA18212 tuners, the tuner frontend
might be aware of the different freqs. This factors if_khz retrieval in a
function, which checks a new flag if an automatic retrieval attempt should
be made, and if the tuner provides it, use it whenever needed.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 45 +--
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index 9370afa..74fee3f 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -94,6 +94,7 @@ struct stv0367_state {
u8 use_i2c_gatectrl;
u8 deftabs;
u8 reinit_on_setfrontend;
+   u8 auto_if_khz;
 };
 
 #define RF_LOOKUP_TABLE_SIZE  31
@@ -319,6 +320,17 @@ static void stv0367_pll_setup(struct stv0367_state *state,
stv0367_writereg(state, R367TER_PLLSETUP, 0x18);
 }
 
+static int stv0367_get_if_khz(struct stv0367_state *state, u32 *ifkhz)
+{
+   if (state->auto_if_khz && state->fe.ops.tuner_ops.get_if_frequency) {
+   state->fe.ops.tuner_ops.get_if_frequency(>fe, ifkhz);
+   *ifkhz = *ifkhz / 1000; /* hz -> khz */
+   } else
+   *ifkhz = state->config->if_khz;
+
+   return 0;
+}
+
 static int stv0367ter_gate_ctrl(struct dvb_frontend *fe, int enable)
 {
struct stv0367_state *state = fe->demodulator_priv;
@@ -992,10 +1004,12 @@ static int stv0367ter_algo(struct dvb_frontend *fe)
u8 /*constell,*/ counter;
s8 step;
s32 timing_offset = 0;
-   u32 trl_nomrate = 0, InternalFreq = 0, temp = 0;
+   u32 trl_nomrate = 0, InternalFreq = 0, temp = 0, ifkhz = 0;
 
dprintk("%s:\n", __func__);
 
+   stv0367_get_if_khz(state, );
+
ter_state->frequency = p->frequency;
ter_state->force = FE_TER_FORCENONE
+ stv0367_readbits(state, F367TER_FORCE) * 2;
@@ -1098,8 +1112,7 @@ static int stv0367ter_algo(struct dvb_frontend *fe)
stv0367_readbits(state, F367TER_GAIN_SRC_LO);
 
temp = (int)
-   ((InternalFreq - state->config->if_khz) * (1 << 16)
-   / (InternalFreq));
+   ((InternalFreq - ifkhz) * (1 << 16) / (InternalFreq));
 
dprintk("DEROT temp=0x%x\n", temp);
stv0367_writebits(state, F367TER_INC_DEROT_HI, temp / 256);
@@ -1720,6 +1733,7 @@ struct dvb_frontend *stv0367ter_attach(const struct 
stv0367_config *config,
state->use_i2c_gatectrl = 1;
state->deftabs = STV0367_DEFTAB_GENERIC;
state->reinit_on_setfrontend = 1;
+   state->auto_if_khz = 0;
 
dprintk("%s: chip_id = 0x%x\n", __func__, state->chip_id);
 
@@ -2229,7 +2243,7 @@ enum stv0367_cab_signal_type stv0367cab_algo(struct 
stv0367_state *state,
 {
struct stv0367cab_state *cab_state = state->cab_state;
enum stv0367_cab_signal_type signalType = FE_CAB_NOAGC;
-   u32 QAMFEC_Lock, QAM_Lock, u32_tmp,
+   u32 QAMFEC_Lock, QAM_Lock, u32_tmp, ifkhz,
LockTime, TRLTimeOut, AGCTimeOut, CRLSymbols,
CRLTimeOut, EQLTimeOut, DemodTimeOut, FECTimeOut;
u8  TrackAGCAccum;
@@ -2237,6 +2251,8 @@ enum stv0367_cab_signal_type stv0367cab_algo(struct 
stv0367_state *state,
 
dprintk("%s:\n", __func__);
 
+   stv0367_get_if_khz(state, );
+
/* Timeouts calculation */
/* A max lock time of 25 ms is allowed for delayed AGC */
AGCTimeOut = 25;
@@ -2315,7 +2331,7 @@ enum stv0367_cab_signal_type stv0367cab_algo(struct 
stv0367_state *state,
/* The sweep function is never used, Sweep rate must be set to 0 */
/* Set the derotator frequency in Hz */
stv0367cab_set_derot_freq(state, cab_state->adc_clk,
-   (1000 * (s32)state->config->if_khz + cab_state->derot_offset));
+   (1000 * (s32)ifkhz + cab_state->derot_offset));
/* Disable the Allpass Filter when the symbol rate is out of range */
if ((p->symbol_rate > 1080) | (p->symbol_rate < 180)) {
stv0367_writebits(state, F367CAB_ADJ_EN, 0);
@@ -2405,17 +2421,17 @@ enum stv0367_cab_signal_type stv0367cab_algo(struct 
stv0367_state *state,
F367CAB_QUAD_INV);
 #if 0
 /* not clear for me */
-   if (state->config->if_khz != 0) {
-   if (state->config->if_khz > cab_state->adc_clk / 1000) {
+   if (ifkhz != 0) {
+   if (ifkhz > cab_state->adc_clk / 1000) {
   

[PATCH v2 08/12] [media] dvb-frontends/stv0367: selectable QAM FEC Lock status register

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

In some configurations (due to different PIN config, wiring or so), the
QAM FECLock might be signalled using a different register than
F367CAB_QAMFEC_LOCK (e.g. F367CAB_DESCR_SYNCSTATE on Digital Devices hw),
so make that register selectable.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index 74fee3f..fb41c7b 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -57,6 +57,7 @@ struct stv0367cab_state {
u32 freq_khz;   /* found frequency (in kHz) */
u32 symbol_rate;/* found symbol rate (in Bds)   */
enum fe_spectral_inversion spect_inv; /* Spectrum Inversion */
+   u32 qamfec_status_reg;  /* status reg to poll for FEC Lock */
 };
 
 struct stv0367ter_state {
@@ -2145,7 +2146,8 @@ static int stv0367cab_read_status(struct dvb_frontend *fe,
 
*status = 0;
 
-   if (stv0367_readbits(state, F367CAB_QAMFEC_LOCK)) {
+   if (stv0367_readbits(state, (state->cab_state->qamfec_status_reg ?
+   state->cab_state->qamfec_status_reg : F367CAB_QAMFEC_LOCK))) {
*status |= FE_HAS_LOCK;
dprintk("%s: stv0367 has locked\n", __func__);
}
@@ -2410,7 +2412,9 @@ enum stv0367_cab_signal_type stv0367cab_algo(struct 
stv0367_state *state,
usleep_range(5000, 7000);
LockTime += 5;
QAMFEC_Lock = stv0367_readbits(state,
-   F367CAB_QAMFEC_LOCK);
+   (state->cab_state->qamfec_status_reg ?
+   state->cab_state->qamfec_status_reg :
+   F367CAB_QAMFEC_LOCK));
} while (!QAMFEC_Lock && (LockTime < FECTimeOut));
} else
QAMFEC_Lock = 0;
@@ -2849,6 +2853,7 @@ struct dvb_frontend *stv0367cab_attach(const struct 
stv0367_config *config,
state->i2c = i2c;
state->config = config;
cab_state->search_range = 28;
+   cab_state->qamfec_status_reg = F367CAB_QAMFEC_LOCK;
state->cab_state = cab_state;
state->fe.ops = stv0367cab_ops;
state->fe.demodulator_priv = state;
-- 
2.10.2



[PATCH v2 09/12] [media] dvb-frontends/stv0367: fix symbol rate conditions in cab_SetQamSize()

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

The values used for comparing symbol rates and the resulting conditional
reg writes seem wrong (rates multiplied by ten), so fix those values.
While this doesn't seem to influence operation, it should be fixed anyway.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index fb41c7b..ffc046a 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -1838,11 +1838,11 @@ static enum stv0367cab_mod stv0367cab_SetQamSize(struct 
stv0367_state *state,
case FE_CAB_MOD_QAM64:
stv0367_writereg(state, R367CAB_IQDEM_ADJ_AGC_REF, 0x82);
stv0367_writereg(state, R367CAB_AGC_PWR_REF_L, 0x5a);
-   if (SymbolRate > 4500) {
+   if (SymbolRate > 450) {
stv0367_writereg(state, R367CAB_FSM_STATE, 0xb0);
stv0367_writereg(state, R367CAB_EQU_CTR_LPF_GAIN, 0xc1);
stv0367_writereg(state, R367CAB_EQU_CRL_LPF_GAIN, 0xa5);
-   } else if (SymbolRate > 2500) {
+   } else if (SymbolRate > 250) {
stv0367_writereg(state, R367CAB_FSM_STATE, 0xa0);
stv0367_writereg(state, R367CAB_EQU_CTR_LPF_GAIN, 0xc1);
stv0367_writereg(state, R367CAB_EQU_CRL_LPF_GAIN, 0xa6);
@@ -1860,9 +1860,9 @@ static enum stv0367cab_mod stv0367cab_SetQamSize(struct 
stv0367_state *state,
stv0367_writereg(state, R367CAB_AGC_PWR_REF_L, 0x76);
stv0367_writereg(state, R367CAB_FSM_STATE, 0x90);
stv0367_writereg(state, R367CAB_EQU_CTR_LPF_GAIN, 0xb1);
-   if (SymbolRate > 4500)
+   if (SymbolRate > 450)
stv0367_writereg(state, R367CAB_EQU_CRL_LPF_GAIN, 0xa7);
-   else if (SymbolRate > 2500)
+   else if (SymbolRate > 250)
stv0367_writereg(state, R367CAB_EQU_CRL_LPF_GAIN, 0xa6);
else
stv0367_writereg(state, R367CAB_EQU_CRL_LPF_GAIN, 0x97);
@@ -1875,9 +1875,9 @@ static enum stv0367cab_mod stv0367cab_SetQamSize(struct 
stv0367_state *state,
stv0367_writereg(state, R367CAB_IQDEM_ADJ_AGC_REF, 0x94);
stv0367_writereg(state, R367CAB_AGC_PWR_REF_L, 0x5a);
stv0367_writereg(state, R367CAB_FSM_STATE, 0xa0);
-   if (SymbolRate > 4500)
+   if (SymbolRate > 450)
stv0367_writereg(state, R367CAB_EQU_CTR_LPF_GAIN, 0xc1);
-   else if (SymbolRate > 2500)
+   else if (SymbolRate > 250)
stv0367_writereg(state, R367CAB_EQU_CTR_LPF_GAIN, 0xc1);
else
stv0367_writereg(state, R367CAB_EQU_CTR_LPF_GAIN, 0xd1);
-- 
2.10.2



[PATCH v2 02/12] [media] dvb-frontends/stv0367: print CPAMP status only if stv_debug is enabled

2017-03-24 Thread Daniel Scheller
From: Daniel Scheller 

The CPAMP log lines generated in stv0367_ter_check_cpamp() are printed
everytime tuning succeeds or fails, quite cluttering the normal kernel log.
Use dprintk() instead of printk(KERN_ERR...) so that if the information is
needed, it'll be printed when the stv_debug modparam is enabled.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0367.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index fc80934..0064d9d 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -1262,9 +1262,9 @@ stv0367_ter_signal_type stv0367ter_check_cpamp(struct 
stv0367_state *state,
dprintk("**last CPAMPvalue= %d at wd=%d\n", CPAMPvalue, wd);
if (CPAMPvalue < CPAMPMin) {
CPAMPStatus = FE_TER_NOCPAMP;
-   printk(KERN_ERR "CPAMP failed\n");
+   dprintk("%s: CPAMP failed\n", __func__);
} else {
-   printk(KERN_ERR "CPAMP OK !\n");
+   dprintk("%s: CPAMP OK !\n", __func__);
CPAMPStatus = FE_TER_CPAMPOK;
}
 
-- 
2.10.2



Re: [PATCH v7 5/9] media: venus: vdec: add video decoder files

2017-03-24 Thread Nicolas Dufresne
Le vendredi 24 mars 2017 à 15:41 +0100, Hans Verkuil a écrit :
> > +static const struct venus_format vdec_formats[] = {
> > + {
> > + .pixfmt = V4L2_PIX_FMT_NV12,
> > + .num_planes = 1,
> > + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
> 
> Just curious: is NV12 the only uncompressed format supported by the
> hardware?
> Or just the only one that is implemented here?

The downstream kernel[0], from Qualcomm have:

{
.name = "UBWC YCbCr Semiplanar 4:2:0",
.description = "UBWC Y/CbCr 4:2:0",
.fourcc = V4L2_PIX_FMT_NV12_UBWC,
.num_planes = 2,
.get_frame_size = get_frame_size_nv12_ubwc,
.type = CAPTURE_PORT,
},
{
.name = "UBWC YCbCr Semiplanar 4:2:0 10bit",
.description = "UBWC Y/CbCr 4:2:0 10bit",
.fourcc = V4L2_PIX_FMT_NV12_TP10_UBWC,
.num_planes = 2,
.get_frame_size = get_frame_size_nv12_ubwc_10bit,
.type = CAPTURE_PORT,
},

I have no idea what UBWC stands for. The performance in NV12 is more
then decent from my testing. Though, there is no 10bit variant.

regards,
Nicolas

[0] https://android.googlesource.com/kernel/msm/+/android-7.1.0_r0.2/dr
ivers/media/platform/msm/vidc/msm_vdec.c#695

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


Re: [PATCH] staging: media: lirc: coding style fix use octal instead of symbolic permission

2017-03-24 Thread Sean Young
On Sun, Feb 12, 2017 at 03:39:42PM +0900, Chetan Sethi wrote:
> This is a patch to the lirc_sir.c file that fixes coding style warning
> found by checkpatch.pl
> 
> Signed-off-by: Chetan Sethi 

Another patch was merged which already fixed this, I'm sorry.

Sean

> ---
>  drivers/staging/media/lirc/lirc_sir.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/media/lirc/lirc_sir.c 
> b/drivers/staging/media/lirc/lirc_sir.c
> index c75ae43..426753e 100644
> --- a/drivers/staging/media/lirc/lirc_sir.c
> +++ b/drivers/staging/media/lirc/lirc_sir.c
> @@ -826,14 +826,14 @@ MODULE_AUTHOR("Milan Pikula");
>  #endif
>  MODULE_LICENSE("GPL");
>  
> -module_param(io, int, S_IRUGO);
> +module_param(io, int, 0444);
>  MODULE_PARM_DESC(io, "I/O address base (0x3f8 or 0x2f8)");
>  
> -module_param(irq, int, S_IRUGO);
> +module_param(irq, int, 0444);
>  MODULE_PARM_DESC(irq, "Interrupt (4 or 3)");
>  
> -module_param(threshold, int, S_IRUGO);
> +module_param(threshold, int, 0444);
>  MODULE_PARM_DESC(threshold, "space detection threshold (3)");
>  
> -module_param(debug, bool, S_IRUGO | S_IWUSR);
> +module_param(debug, bool, 0644);
>  MODULE_PARM_DESC(debug, "Enable debugging messages");
> -- 
> 2.7.4


[PATCH 2/8] [media] staging: st-cec: Use cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Use helper function to get driver private data from CEC
adapter.

Signed-off-by: Jose Abreu 
Cc: Benjamin Gaignard 
---
 drivers/staging/media/st-cec/stih-cec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/st-cec/stih-cec.c 
b/drivers/staging/media/st-cec/stih-cec.c
index 3c25638..521206d 100644
--- a/drivers/staging/media/st-cec/stih-cec.c
+++ b/drivers/staging/media/st-cec/stih-cec.c
@@ -133,7 +133,7 @@ struct stih_cec {
 
 static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-   struct stih_cec *cec = adap->priv;
+   struct stih_cec *cec = cec_get_drvdata(adap);
 
if (enable) {
/* The doc says (input TCLK_PERIOD * CEC_CLK_DIV) = 0.1ms */
@@ -189,7 +189,7 @@ static int stih_cec_adap_enable(struct cec_adapter *adap, 
bool enable)
 
 static int stih_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
 {
-   struct stih_cec *cec = adap->priv;
+   struct stih_cec *cec = cec_get_drvdata(adap);
u32 reg = readl(cec->regs + CEC_ADDR_TABLE);
 
reg |= 1 << logical_addr;
@@ -205,7 +205,7 @@ static int stih_cec_adap_log_addr(struct cec_adapter *adap, 
u8 logical_addr)
 static int stih_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
  u32 signal_free_time, struct cec_msg *msg)
 {
-   struct stih_cec *cec = adap->priv;
+   struct stih_cec *cec = cec_get_drvdata(adap);
int i;
 
/* Copy message into registers */
-- 
1.9.1




[PATCH 0/8] Add cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Hi,

This series introduces a new helper function called cec_get_drvdata() which
returns the adapter private data and can be used by drivers that use CEC.

Best regards,
Jose Miguel Abreu

Jose Abreu (8):
  [media] cec: Add cec_get_drvdata()
  [media] staging: st-cec: Use cec_get_drvdata()
  [media] staging: s5p-cec: Use cec_get_drvdata()
  [media] i2c: adv7511: Use cec_get_drvdata()
  [media] i2c: adv7604: Use cec_get_drvdata()
  [media] i2c: adv7842: Use cec_get_drvdata()
  [media] usb: pulse8-cec: Use cec_get_drvdata()
  [media] platform: vivid: Use cec_get_drvdata()

 drivers/media/i2c/adv7511.c   | 6 +++---
 drivers/media/i2c/adv7604.c   | 6 +++---
 drivers/media/i2c/adv7842.c   | 6 +++---
 drivers/media/platform/vivid/vivid-cec.c  | 4 ++--
 drivers/media/usb/pulse8-cec/pulse8-cec.c | 6 +++---
 drivers/staging/media/s5p-cec/s5p_cec.c   | 6 +++---
 drivers/staging/media/st-cec/stih-cec.c   | 6 +++---
 include/media/cec.h   | 5 +
 8 files changed, 25 insertions(+), 20 deletions(-)

-- 
1.9.1




[PATCH 5/8] [media] i2c: adv7604: Use cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Use helper function to get driver private data from CEC
adapter.

Signed-off-by: Jose Abreu 
Cc: Hans Verkuil 
---
 drivers/media/i2c/adv7604.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index d8bf435..f1fa9ce 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2050,7 +2050,7 @@ static void adv76xx_cec_isr(struct v4l2_subdev *sd, bool 
*handled)
 
 static int adv76xx_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-   struct adv76xx_state *state = adap->priv;
+   struct adv76xx_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
 
if (!state->cec_enabled_adap && enable) {
@@ -2080,7 +2080,7 @@ static int adv76xx_cec_adap_enable(struct cec_adapter 
*adap, bool enable)
 
 static int adv76xx_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
-   struct adv76xx_state *state = adap->priv;
+   struct adv76xx_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
unsigned int i, free_idx = ADV76XX_MAX_ADDRS;
 
@@ -2135,7 +2135,7 @@ static int adv76xx_cec_adap_log_addr(struct cec_adapter 
*adap, u8 addr)
 static int adv76xx_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 u32 signal_free_time, struct cec_msg *msg)
 {
-   struct adv76xx_state *state = adap->priv;
+   struct adv76xx_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
u8 len = msg->len;
unsigned int i;
-- 
1.9.1




[PATCH 4/8] [media] i2c: adv7511: Use cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Use helper function to get driver private data from CEC
adapter.

Signed-off-by: Jose Abreu 
Cc: Hans Verkuil 
---
 drivers/media/i2c/adv7511.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 8c9e289..ccc4786 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -734,7 +734,7 @@ static int adv7511_s_power(struct v4l2_subdev *sd, int on)
 #if IS_ENABLED(CONFIG_VIDEO_ADV7511_CEC)
 static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-   struct adv7511_state *state = adap->priv;
+   struct adv7511_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
 
if (state->i2c_cec == NULL)
@@ -769,7 +769,7 @@ static int adv7511_cec_adap_enable(struct cec_adapter 
*adap, bool enable)
 
 static int adv7511_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
-   struct adv7511_state *state = adap->priv;
+   struct adv7511_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
unsigned int i, free_idx = ADV7511_MAX_ADDRS;
 
@@ -824,7 +824,7 @@ static int adv7511_cec_adap_log_addr(struct cec_adapter 
*adap, u8 addr)
 static int adv7511_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 u32 signal_free_time, struct cec_msg *msg)
 {
-   struct adv7511_state *state = adap->priv;
+   struct adv7511_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
u8 len = msg->len;
unsigned int i;
-- 
1.9.1




[PATCH 3/8] [media] staging: s5p-cec: Use cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Use helper function to get driver private data from CEC
adapter.

Signed-off-by: Jose Abreu 
Cc: Kamil Debski 
---
 drivers/staging/media/s5p-cec/s5p_cec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/s5p-cec/s5p_cec.c 
b/drivers/staging/media/s5p-cec/s5p_cec.c
index 2a07968..a30b80a 100644
--- a/drivers/staging/media/s5p-cec/s5p_cec.c
+++ b/drivers/staging/media/s5p-cec/s5p_cec.c
@@ -37,7 +37,7 @@
 
 static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-   struct s5p_cec_dev *cec = adap->priv;
+   struct s5p_cec_dev *cec = cec_get_drvdata(adap);
 
if (enable) {
pm_runtime_get_sync(cec->dev);
@@ -61,7 +61,7 @@ static int s5p_cec_adap_enable(struct cec_adapter *adap, bool 
enable)
 
 static int s5p_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
-   struct s5p_cec_dev *cec = adap->priv;
+   struct s5p_cec_dev *cec = cec_get_drvdata(adap);
 
s5p_cec_set_addr(cec, addr);
return 0;
@@ -70,7 +70,7 @@ static int s5p_cec_adap_log_addr(struct cec_adapter *adap, u8 
addr)
 static int s5p_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 u32 signal_free_time, struct cec_msg *msg)
 {
-   struct s5p_cec_dev *cec = adap->priv;
+   struct s5p_cec_dev *cec = cec_get_drvdata(adap);
 
/*
 * Unclear if 0 retries are allowed by the hardware, so have 1 as
-- 
1.9.1




[PATCH 6/8] [media] i2c: adv7842: Use cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Use helper function to get driver private data from CEC
adapter.

Signed-off-by: Jose Abreu 
Cc: Hans Verkuil 
---
 drivers/media/i2c/adv7842.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 2d61f0c..303effd 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2250,7 +2250,7 @@ static void adv7842_cec_isr(struct v4l2_subdev *sd, bool 
*handled)
 
 static int adv7842_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-   struct adv7842_state *state = adap->priv;
+   struct adv7842_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
 
if (!state->cec_enabled_adap && enable) {
@@ -2279,7 +2279,7 @@ static int adv7842_cec_adap_enable(struct cec_adapter 
*adap, bool enable)
 
 static int adv7842_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
-   struct adv7842_state *state = adap->priv;
+   struct adv7842_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
unsigned int i, free_idx = ADV7842_MAX_ADDRS;
 
@@ -2334,7 +2334,7 @@ static int adv7842_cec_adap_log_addr(struct cec_adapter 
*adap, u8 addr)
 static int adv7842_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 u32 signal_free_time, struct cec_msg *msg)
 {
-   struct adv7842_state *state = adap->priv;
+   struct adv7842_state *state = cec_get_drvdata(adap);
struct v4l2_subdev *sd = >sd;
u8 len = msg->len;
unsigned int i;
-- 
1.9.1




[PATCH 7/8] [media] usb: pulse8-cec: Use cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Use helper function to get driver private data from CEC
adapter.

Signed-off-by: Jose Abreu 
Cc: Hans Verkuil 
---
 drivers/media/usb/pulse8-cec/pulse8-cec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/pulse8-cec/pulse8-cec.c 
b/drivers/media/usb/pulse8-cec/pulse8-cec.c
index 7c18dae..1dfc2de 100644
--- a/drivers/media/usb/pulse8-cec/pulse8-cec.c
+++ b/drivers/media/usb/pulse8-cec/pulse8-cec.c
@@ -461,7 +461,7 @@ static int pulse8_apply_persistent_config(struct pulse8 
*pulse8,
 
 static int pulse8_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-   struct pulse8 *pulse8 = adap->priv;
+   struct pulse8 *pulse8 = cec_get_drvdata(adap);
u8 cmd[16];
int err;
 
@@ -474,7 +474,7 @@ static int pulse8_cec_adap_enable(struct cec_adapter *adap, 
bool enable)
 
 static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
 {
-   struct pulse8 *pulse8 = adap->priv;
+   struct pulse8 *pulse8 = cec_get_drvdata(adap);
u16 mask = 0;
u16 pa = adap->phys_addr;
u8 cmd[16];
@@ -594,7 +594,7 @@ static int pulse8_cec_adap_log_addr(struct cec_adapter 
*adap, u8 log_addr)
 static int pulse8_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
u32 signal_free_time, struct cec_msg *msg)
 {
-   struct pulse8 *pulse8 = adap->priv;
+   struct pulse8 *pulse8 = cec_get_drvdata(adap);
u8 cmd[2];
unsigned int i;
int err;
-- 
1.9.1




[PATCH 8/8] [media] platform: vivid: Use cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Use helper function to get driver private data from CEC
adapter.

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

diff --git a/drivers/media/platform/vivid/vivid-cec.c 
b/drivers/media/platform/vivid/vivid-cec.c
index cb49335..653f409 100644
--- a/drivers/media/platform/vivid/vivid-cec.c
+++ b/drivers/media/platform/vivid/vivid-cec.c
@@ -135,7 +135,7 @@ static int vivid_cec_adap_log_addr(struct cec_adapter 
*adap, u8 log_addr)
 static int vivid_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
   u32 signal_free_time, struct cec_msg *msg)
 {
-   struct vivid_dev *dev = adap->priv;
+   struct vivid_dev *dev = cec_get_drvdata(adap);
struct vivid_cec_work *cw = kzalloc(sizeof(*cw), GFP_KERNEL);
long delta_jiffies = 0;
 
@@ -166,7 +166,7 @@ static int vivid_cec_adap_transmit(struct cec_adapter 
*adap, u8 attempts,
 
 static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 {
-   struct vivid_dev *dev = adap->priv;
+   struct vivid_dev *dev = cec_get_drvdata(adap);
struct cec_msg reply;
u8 dest = cec_msg_destination(msg);
u8 disp_ctl;
-- 
1.9.1




[PATCH 1/8] [media] cec: Add cec_get_drvdata()

2017-03-24 Thread Jose Abreu
Add a helper function to get driver private data from CEC
adapter. This helps the readability a little bit and allows
to change the 'priv' field name to something else without
needing to touch all drivers.

Signed-off-by: Jose Abreu 
Cc: Hans Verkuil 
---
 include/media/cec.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/media/cec.h b/include/media/cec.h
index 96a0aa7..0daff8c 100644
--- a/include/media/cec.h
+++ b/include/media/cec.h
@@ -184,6 +184,11 @@ struct cec_adapter {
char input_drv[32];
 };
 
+static inline void *cec_get_drvdata(const struct cec_adapter *adap)
+{
+   return adap->priv;
+}
+
 static inline bool cec_has_log_addr(const struct cec_adapter *adap, u8 
log_addr)
 {
return adap->log_addrs.log_addr_mask & (1 << log_addr);
-- 
1.9.1




[PATCH v2] staging: media: omap4iss: Replace a bit shift by a use of BIT.

2017-03-24 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v2
 -Remove unnecessary parenthesis

 drivers/staging/media/omap4iss/iss_csi2.c| 2 +-
 drivers/staging/media/omap4iss/iss_ipipe.c   | 2 +-
 drivers/staging/media/omap4iss/iss_ipipeif.c | 2 +-
 drivers/staging/media/omap4iss/iss_resizer.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/omap4iss/iss_csi2.c 
b/drivers/staging/media/omap4iss/iss_csi2.c
index f71d5f2f179f..f6acc541e8a2 100644
--- a/drivers/staging/media/omap4iss/iss_csi2.c
+++ b/drivers/staging/media/omap4iss/iss_csi2.c
@@ -1268,7 +1268,7 @@ static int csi2_init_entities(struct iss_csi2_device 
*csi2, const char *subname)
snprintf(name, sizeof(name), "CSI2%s", subname);
snprintf(sd->name, sizeof(sd->name), "OMAP4 ISS %s", name);
 
-   sd->grp_id = 1 << 16;   /* group ID for iss subdevs */
+   sd->grp_id = BIT(16);   /* group ID for iss subdevs */
v4l2_set_subdevdata(sd, csi2);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
diff --git a/drivers/staging/media/omap4iss/iss_ipipe.c 
b/drivers/staging/media/omap4iss/iss_ipipe.c
index d38782e8e84c..d86ef8a031f2 100644
--- a/drivers/staging/media/omap4iss/iss_ipipe.c
+++ b/drivers/staging/media/omap4iss/iss_ipipe.c
@@ -508,7 +508,7 @@ static int ipipe_init_entities(struct iss_ipipe_device 
*ipipe)
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "OMAP4 ISS ISP IPIPE", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for iss subdevs */
+   sd->grp_id = BIT(16);   /* group ID for iss subdevs */
v4l2_set_subdevdata(sd, ipipe);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
diff --git a/drivers/staging/media/omap4iss/iss_ipipeif.c 
b/drivers/staging/media/omap4iss/iss_ipipeif.c
index 23de8330731d..cb88b2bd0d82 100644
--- a/drivers/staging/media/omap4iss/iss_ipipeif.c
+++ b/drivers/staging/media/omap4iss/iss_ipipeif.c
@@ -739,7 +739,7 @@ static int ipipeif_init_entities(struct iss_ipipeif_device 
*ipipeif)
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "OMAP4 ISS ISP IPIPEIF", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for iss subdevs */
+   sd->grp_id = BIT(16);   /* group ID for iss subdevs */
v4l2_set_subdevdata(sd, ipipeif);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
diff --git a/drivers/staging/media/omap4iss/iss_resizer.c 
b/drivers/staging/media/omap4iss/iss_resizer.c
index f1d352c711d5..4bbfa20b3c38 100644
--- a/drivers/staging/media/omap4iss/iss_resizer.c
+++ b/drivers/staging/media/omap4iss/iss_resizer.c
@@ -782,7 +782,7 @@ static int resizer_init_entities(struct iss_resizer_device 
*resizer)
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "OMAP4 ISS ISP resizer", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for iss subdevs */
+   sd->grp_id = BIT(16);   /* group ID for iss subdevs */
v4l2_set_subdevdata(sd, resizer);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
-- 
2.11.0



[PATCH v2] staging: media: davinci_vpfe:Replace a bit shift.

2017-03-24 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v2
 -Remove unnecessary parenthesis.

 drivers/staging/media/davinci_vpfe/dm365_ipipe.c   |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_ipipeif.c |  2 +-
 drivers/staging/media/davinci_vpfe/dm365_isif.c| 10 +-
 drivers/staging/media/davinci_vpfe/dm365_resizer.c |  6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
index 6a3434cebd79..7eeb53217168 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c
@@ -1815,7 +1815,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct 
platform_device *pdev)
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "DAVINCI IPIPE", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
+   sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
v4l2_set_subdevdata(sd, ipipe);
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c 
b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
index 46fd2c7f69c3..c07f028dd6be 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
@@ -1021,7 +1021,7 @@ int vpfe_ipipeif_init(struct vpfe_ipipeif_device *ipipeif,
 
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "DAVINCI IPIPEIF", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
+   sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
 
v4l2_set_subdevdata(sd, ipipeif);
 
diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c 
b/drivers/staging/media/davinci_vpfe/dm365_isif.c
index 569bcdc9ce2f..74b1247203b1 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_isif.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c
@@ -821,7 +821,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
vpfe_isif_dfc *vdfc)
 
/* Correct whole line or partial */
if (vdfc->corr_whole_line)
-   val |= 1 << ISIF_VDFC_CORR_WHOLE_LN_SHIFT;
+   val |= BIT(ISIF_VDFC_CORR_WHOLE_LN_SHIFT);
 
/* level shift value */
val |= (vdfc->def_level_shift & ISIF_VDFC_LEVEL_SHFT_MASK) <<
@@ -849,7 +849,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
vpfe_isif_dfc *vdfc)
 
val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
/* set DFCMARST and set DFCMWR */
-   val |= 1 << ISIF_DFCMEMCTL_DFCMARST_SHIFT;
+   val |= BIT(ISIF_DFCMEMCTL_DFCMARST_SHIFT);
val |= 1;
isif_write(isif->isif_cfg.base_addr, val, DFCMEMCTL);
 
@@ -880,7 +880,7 @@ isif_config_dfc(struct vpfe_isif_device *isif, struct 
vpfe_isif_dfc *vdfc)
}
val = isif_read(isif->isif_cfg.base_addr, DFCMEMCTL);
/* clear DFCMARST and set DFCMWR */
-   val &= ~(1 << ISIF_DFCMEMCTL_DFCMARST_SHIFT);
+   val &= ~BIT(ISIF_DFCMEMCTL_DFCMARST_SHIFT);
val |= 1;
isif_write(isif->isif_cfg.base_addr, val, DFCMEMCTL);
 
@@ -1140,7 +1140,7 @@ static int isif_config_raw(struct v4l2_subdev *sd, int 
mode)
isif_write(isif->isif_cfg.base_addr, val, CGAMMAWD);
/* Configure DPCM compression settings */
if (params->v4l2_pix_fmt == V4L2_PIX_FMT_SGRBG10DPCM8) {
-   val =  1 << ISIF_DPCM_EN_SHIFT;
+   val =  BIT(ISIF_DPCM_EN_SHIFT);
val |= (params->dpcm_predictor &
ISIF_DPCM_PREDICTOR_MASK) << ISIF_DPCM_PREDICTOR_SHIFT;
}
@@ -2044,7 +2044,7 @@ int vpfe_isif_init(struct vpfe_isif_device *isif, struct 
platform_device *pdev)
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "DAVINCI ISIF", sizeof(sd->name));
-   sd->grp_id = 1 << 16;   /* group ID for davinci subdevs */
+   sd->grp_id = BIT(16);   /* group ID for davinci subdevs */
v4l2_set_subdevdata(sd, isif);
sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
pads[ISIF_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c 
b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
index 857b0e847c5e..3b3469adaf91 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
@@ -1903,7 +1903,7 @@ int vpfe_resizer_init(struct vpfe_resizer_device 
*vpfe_rsz,
v4l2_subdev_init(sd, _v4l2_ops);
sd->internal_ops = _v4l2_internal_ops;
strlcpy(sd->name, "DAVINCI RESIZER CROP", 

[PATCH v2] staging: media: atomisp:Replace a bit shift.

2017-03-24 Thread Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal 
---
changes in v2
 -remove the unnecessary parenthesis.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c  | 12 ++--
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c | 10 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc7938f533..8edcde282ec9 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -194,7 +194,7 @@ static int write_target_freq_to_hw(struct atomisp_device 
*isp,
if (isp_sspm1 & ISP_FREQ_VALID_MASK) {
dev_dbg(isp->dev, "clearing ISPSSPM1 valid bit.\n");
intel_mid_msgbus_write32(PUNIT_PORT, ISPSSPM1,
-   isp_sspm1 & ~(1 << ISP_FREQ_VALID_OFFSET));
+   isp_sspm1 & ~BIT(ISP_FREQ_VALID_OFFSET));
}
 
ratio = (2 * isp->hpll_freq + new_freq / 2) / new_freq - 1;
@@ -207,7 +207,7 @@ static int write_target_freq_to_hw(struct atomisp_device 
*isp,
intel_mid_msgbus_write32(PUNIT_PORT, ISPSSPM1,
   isp_sspm1
   | ratio << ISP_REQ_FREQ_OFFSET
-  | 1 << ISP_FREQ_VALID_OFFSET
+  | BIT(ISP_FREQ_VALID_OFFSET)
   | guar_ratio << ISP_REQ_GUAR_FREQ_OFFSET);
 
isp_sspm1 = intel_mid_msgbus_read32(PUNIT_PORT, ISPSSPM1);
@@ -417,10 +417,10 @@ void atomisp_msi_irq_init(struct atomisp_device *isp, 
struct pci_dev *dev)
u16 msg16;
 
pci_read_config_dword(dev, PCI_MSI_CAPID, );
-   msg32 |= 1 << MSI_ENABLE_BIT;
+   msg32 |= BIT(MSI_ENABLE_BIT);
pci_write_config_dword(dev, PCI_MSI_CAPID, msg32);
 
-   msg32 = (1 << INTR_IER) | (1 << INTR_IIR);
+   msg32 = BIT(INTR_IER) | BIT(INTR_IIR);
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, msg32);
 
pci_read_config_word(dev, PCI_COMMAND, );
@@ -435,7 +435,7 @@ void atomisp_msi_irq_uninit(struct atomisp_device *isp, 
struct pci_dev *dev)
u16 msg16;
 
pci_read_config_dword(dev, PCI_MSI_CAPID, );
-   msg32 &=  ~(1 << MSI_ENABLE_BIT);
+   msg32 &=  ~BIT(MSI_ENABLE_BIT);
pci_write_config_dword(dev, PCI_MSI_CAPID, msg32);
 
msg32 = 0x0;
@@ -536,7 +536,7 @@ static void clear_irq_reg(struct atomisp_device *isp)
 {
u32 msg_ret;
pci_read_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, _ret);
-   msg_ret |= 1 << INTR_IIR;
+   msg_ret |= BIT(INTR_IIR);
pci_write_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, msg_ret);
 }
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
index 626d2f114d8d..b1f685a841ba 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_v4l2.c
@@ -330,11 +330,11 @@ static int atomisp_mrfld_pre_power_down(struct 
atomisp_device *isp)
 * IRQ, if so, waiting for it to be served
 */
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, );
-   irq = irq & 1 << INTR_IIR;
+   irq = irq & BIT(INTR_IIR);
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
 
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, );
-   if (!(irq & (1 << INTR_IIR)))
+   if (!(irq & BIT(INTR_IIR)))
goto done;
 
atomisp_store_uint32(MRFLD_INTR_CLEAR_REG, 0x);
@@ -347,11 +347,11 @@ static int atomisp_mrfld_pre_power_down(struct 
atomisp_device *isp)
return -EAGAIN;
} else {
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, );
-   irq = irq & 1 << INTR_IIR;
+   irq = irq & BIT(INTR_IIR);
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
 
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, );
-   if (!(irq & (1 << INTR_IIR))) {
+   if (!(irq & BIT(INTR_IIR))) {
atomisp_store_uint32(MRFLD_INTR_ENABLE_REG, 0x0);
goto done;
}
@@ -370,7 +370,7 @@ static int atomisp_mrfld_pre_power_down(struct 
atomisp_device *isp)
* HW sighting:4568410.
*/
pci_read_config_dword(dev, PCI_INTERRUPT_CTRL, );
-   irq &= ~(1 << INTR_IER);
+   irq &= ~BIT(INTR_IER);
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
 
atomisp_msi_irq_uninit(isp, dev);
-- 
2.11.0



Re: [PATCH v7 9/9] media: venus: enable building of Venus video driver

2017-03-24 Thread Stanimir Varbanov
Thanks for the comments!

On 03/24/2017 04:49 PM, Hans Verkuil wrote:
> On 03/13/17 17:37, Stanimir Varbanov wrote:
>> This adds Venus driver Makefile and changes v4l2 platform
>> Makefile/Kconfig in order to enable building of the driver.
>>
>> Signed-off-by: Stanimir Varbanov 
>> ---
>>  drivers/media/platform/Kconfig | 14 ++
>>  drivers/media/platform/Makefile|  2 ++
>>  drivers/media/platform/qcom/venus/Makefile | 11 +++
>>  3 files changed, 27 insertions(+)
>>  create mode 100644 drivers/media/platform/qcom/venus/Makefile
>>
>> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
>> index 53f6f12bff0d..8a6c3d664307 100644
>> --- a/drivers/media/platform/Kconfig
>> +++ b/drivers/media/platform/Kconfig
>> @@ -447,6 +447,20 @@ config VIDEO_TI_VPE_DEBUG
>>  ---help---
>>Enable debug messages on VPE driver.
>>  
>> +config VIDEO_QCOM_VENUS
>> +tristate "Qualcomm Venus V4L2 encoder/decoder driver"
>> +depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
> 
> Can this also depend on COMPILE_TEST? And if so, please make sure it compile 
> on both
> a 32 and 64 bit environment to shake out any compiler warnings.
> 

yes I can add COMPILE_TEST, at least on -next it should be fine.

-- 
regards,
Stan


Re: [PATCH v7 9/9] media: venus: enable building of Venus video driver

2017-03-24 Thread Hans Verkuil
On 03/13/17 17:37, Stanimir Varbanov wrote:
> This adds Venus driver Makefile and changes v4l2 platform
> Makefile/Kconfig in order to enable building of the driver.
> 
> Signed-off-by: Stanimir Varbanov 
> ---
>  drivers/media/platform/Kconfig | 14 ++
>  drivers/media/platform/Makefile|  2 ++
>  drivers/media/platform/qcom/venus/Makefile | 11 +++
>  3 files changed, 27 insertions(+)
>  create mode 100644 drivers/media/platform/qcom/venus/Makefile
> 
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index 53f6f12bff0d..8a6c3d664307 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -447,6 +447,20 @@ config VIDEO_TI_VPE_DEBUG
>   ---help---
> Enable debug messages on VPE driver.
>  
> +config VIDEO_QCOM_VENUS
> + tristate "Qualcomm Venus V4L2 encoder/decoder driver"
> + depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA

Can this also depend on COMPILE_TEST? And if so, please make sure it compile on 
both
a 32 and 64 bit environment to shake out any compiler warnings.

Regards,

Hans

> + depends on ARCH_QCOM && OF
> + depends on IOMMU_DMA
> + select QCOM_MDT_LOADER
> + select VIDEOBUF2_DMA_SG
> + select V4L2_MEM2MEM_DEV
> + ---help---
> +   This is a V4L2 driver for Qualcomm Venus video accelerator
> +   hardware. It accelerates encoding and decoding operations
> +   on various Qualcomm SoCs.
> +   To compile this driver as a module choose m here.
> +
>  endif # V4L_MEM2MEM_DRIVERS
>  
>  # TI VIDEO PORT Helper Modules
> diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
> index 8959f6e6692a..bd5cae68db8a 100644
> --- a/drivers/media/platform/Makefile
> +++ b/drivers/media/platform/Makefile
> @@ -73,3 +73,5 @@ obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec/
>  obj-$(CONFIG_VIDEO_MEDIATEK_MDP) += mtk-mdp/
>  
>  obj-$(CONFIG_VIDEO_MEDIATEK_JPEG)+= mtk-jpeg/
> +
> +obj-$(CONFIG_VIDEO_QCOM_VENUS)   += qcom/venus/
> diff --git a/drivers/media/platform/qcom/venus/Makefile 
> b/drivers/media/platform/qcom/venus/Makefile
> new file mode 100644
> index ..0fe9afb83697
> --- /dev/null
> +++ b/drivers/media/platform/qcom/venus/Makefile
> @@ -0,0 +1,11 @@
> +# Makefile for Qualcomm Venus driver
> +
> +venus-core-objs += core.o helpers.o firmware.o \
> +hfi_venus.o hfi_msgs.o hfi_cmds.o hfi.o
> +
> +venus-dec-objs += vdec.o vdec_ctrls.o
> +venus-enc-objs += venc.o venc_ctrls.o
> +
> +obj-$(CONFIG_VIDEO_QCOM_VENUS) += venus-core.o
> +obj-$(CONFIG_VIDEO_QCOM_VENUS) += venus-dec.o
> +obj-$(CONFIG_VIDEO_QCOM_VENUS) += venus-enc.o
> 



Re: [PATCH v7 5/9] media: venus: vdec: add video decoder files

2017-03-24 Thread Hans Verkuil
Some comments and questions below:

On 03/13/17 17:37, Stanimir Varbanov wrote:
> This consists of video decoder implementation plus decoder
> controls.
> 
> Signed-off-by: Stanimir Varbanov 
> ---
>  drivers/media/platform/qcom/venus/vdec.c   | 1091 
> 
>  drivers/media/platform/qcom/venus/vdec.h   |   23 +
>  drivers/media/platform/qcom/venus/vdec_ctrls.c |  149 
>  3 files changed, 1263 insertions(+)
>  create mode 100644 drivers/media/platform/qcom/venus/vdec.c
>  create mode 100644 drivers/media/platform/qcom/venus/vdec.h
>  create mode 100644 drivers/media/platform/qcom/venus/vdec_ctrls.c
> 
> diff --git a/drivers/media/platform/qcom/venus/vdec.c 
> b/drivers/media/platform/qcom/venus/vdec.c
> new file mode 100644
> index ..ec5203f2ba81
> --- /dev/null
> +++ b/drivers/media/platform/qcom/venus/vdec.c
> @@ -0,0 +1,1091 @@
> +/*
> + * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
> + * Copyright (C) 2017 Linaro Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "hfi_venus_io.h"
> +#include "core.h"
> +#include "helpers.h"
> +#include "vdec.h"
> +
> +static u32 get_framesize_uncompressed(unsigned int plane, u32 width, u32 
> height)
> +{
> + u32 y_stride, uv_stride, y_plane;
> + u32 y_sclines, uv_sclines, uv_plane;
> + u32 size;
> +
> + y_stride = ALIGN(width, 128);
> + uv_stride = ALIGN(width, 128);
> + y_sclines = ALIGN(height, 32);
> + uv_sclines = ALIGN(((height + 1) >> 1), 16);
> +
> + y_plane = y_stride * y_sclines;
> + uv_plane = uv_stride * uv_sclines + SZ_4K;
> + size = y_plane + uv_plane + SZ_8K;
> +
> + return ALIGN(size, SZ_4K);
> +}
> +
> +static u32 get_framesize_compressed(unsigned int width, unsigned int height)
> +{
> + return ((width * height * 3 / 2) / 2) + 128;
> +}
> +
> +static const struct venus_format vdec_formats[] = {
> + {
> + .pixfmt = V4L2_PIX_FMT_NV12,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,

Just curious: is NV12 the only uncompressed format supported by the hardware?
Or just the only one that is implemented here?

> + }, {
> + .pixfmt = V4L2_PIX_FMT_MPEG4,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_MPEG2,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_H263,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_G,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_H264,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_VP8,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + }, {
> + .pixfmt = V4L2_PIX_FMT_XVID,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
> + },

num_planes is always 1, do you need it at all? And if it is always one,
why use _MPLANE at all? Is this for future additions?

> +};
> +
> +static const struct venus_format *find_format(u32 pixfmt, u32 type)
> +{
> + const struct venus_format *fmt = vdec_formats;
> + unsigned int size = ARRAY_SIZE(vdec_formats);
> + unsigned int i;
> +
> + for (i = 0; i < size; i++) {
> + if (fmt[i].pixfmt == pixfmt)
> + break;
> + }
> +
> + if (i == size || fmt[i].type != type)
> + return NULL;
> +
> + return [i];
> +}
> +
> +static const struct venus_format *find_format_by_index(int index, u32 type)
> +{
> + const struct venus_format *fmt = vdec_formats;
> + unsigned int size = ARRAY_SIZE(vdec_formats);
> + int i, k = 0;
> +
> + if (index < 0 || index > size)
> + return NULL;
> +
> + for (i = 0; i < size; i++) {
> + if (fmt[i].type != type)
> + 

Re: [PATCH v7 4/9] media: venus: adding core part and helper functions

2017-03-24 Thread Hans Verkuil
Some review comments below:

On 03/13/17 17:37, Stanimir Varbanov wrote:
>  * core.c has implemented the platform dirver methods, file

dirver -> driver

> operations and v4l2 registration.
> 
>  * helpers.c has implemented common helper functions for:
>- buffer management
> 
>- vb2_ops and functions for format propagation,
> 
>- functions for allocating and freeing buffers for
>internal usage. The buffer parameters describing internal
>buffers depends on current format, resolution and codec.
> 
>- functions for calculation of current load of the
>hardware. Depending on the count of instances and
>resolutions it selects the best clock rate for the video
>core.
> 
>  * firmware loader
> 
> Signed-off-by: Stanimir Varbanov 
> ---
>  drivers/media/platform/qcom/venus/core.c | 386 
>  drivers/media/platform/qcom/venus/core.h | 306 +
>  drivers/media/platform/qcom/venus/firmware.c | 107 +
>  drivers/media/platform/qcom/venus/firmware.h |  22 +
>  drivers/media/platform/qcom/venus/helpers.c  | 632 
> +++
>  drivers/media/platform/qcom/venus/helpers.h  |  41 ++
>  6 files changed, 1494 insertions(+)
>  create mode 100644 drivers/media/platform/qcom/venus/core.c
>  create mode 100644 drivers/media/platform/qcom/venus/core.h
>  create mode 100644 drivers/media/platform/qcom/venus/firmware.c
>  create mode 100644 drivers/media/platform/qcom/venus/firmware.h
>  create mode 100644 drivers/media/platform/qcom/venus/helpers.c
>  create mode 100644 drivers/media/platform/qcom/venus/helpers.h
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c 
> b/drivers/media/platform/qcom/venus/core.c
> new file mode 100644
> index ..557b6ec4cc48
> --- /dev/null
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -0,0 +1,386 @@
> +/*
> + * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
> + * Copyright (C) 2017 Linaro Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "core.h"
> +#include "vdec.h"
> +#include "venc.h"
> +#include "firmware.h"
> +
> +static const struct hfi_core_ops venus_core_ops;
> +
> +static void venus_sys_error_handler(struct work_struct *work)
> +{
> + struct venus_core *core =
> + container_of(work, struct venus_core, work.work);
> + int ret;
> +
> + dev_warn(core->dev, "system error occurred, starting recovery!\n");
> +
> + pm_runtime_get_sync(core->dev);
> +
> + hfi_core_deinit(core, true);
> +
> + hfi_destroy(core);
> +
> + mutex_lock(>lock);
> +
> + venus_shutdown(>dev_fw);
> +
> + pm_runtime_put_sync(core->dev);
> +
> + ret = hfi_create(core, _core_ops);
> +
> + pm_runtime_get_sync(core->dev);
> +
> + ret = venus_boot(core->dev, >dev_fw);
> +
> + ret = hfi_core_resume(core, true);

Why assign to ret if you're going to ignore it anyway? Either drop the 
assignment
or do something with it.

> +
> + enable_irq(core->irq);
> +
> + mutex_unlock(>lock);
> +
> + ret = hfi_core_init(core);
> + if (ret)
> + dev_err(core->dev, "hfi_core_init (%d)\n", ret);
> +
> + pm_runtime_put_sync(core->dev);
> +
> + core->sys_error = false;
> +}
> +
> +static void venus_event_notify(struct venus_core *core, u32 event)
> +{
> + struct venus_inst *inst;
> +
> + switch (event) {
> + case EVT_SYS_WATCHDOG_TIMEOUT:
> + case EVT_SYS_ERROR:
> + break;
> + default:
> + return;
> + }
> +
> + mutex_lock(>lock);
> + core->sys_error = true;
> + list_for_each_entry(inst, >instances, list)
> + inst->ops->event_notify(inst, EVT_SESSION_ERROR, NULL);
> + mutex_unlock(>lock);
> +
> + disable_irq_nosync(core->irq);
> +
> + /*
> +  * Sleep for 5 sec to ensure venus has completed any pending cache
> +  * operations. Without this sleep, we see device reset when firmware is
> +  * unloaded after a system error.
> +  */
> + schedule_delayed_work(>work, msecs_to_jiffies(100));
> +}
> +
> +static const struct hfi_core_ops venus_core_ops = {
> + .event_notify = venus_event_notify,
> +};
> +
> +static int venus_clks_get(struct venus_core *core)
> +{
> + const struct venus_resources *res = core->res;
> + struct device *dev = core->dev;
> + 

[PATCH] [media] ivtv: use for_each_sg

2017-03-24 Thread Geliang Tang
Use for_each_sg() instead of open-coding it.

Signed-off-by: Geliang Tang 
---
 drivers/media/pci/ivtv/ivtv-udma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ivtv/ivtv-udma.c 
b/drivers/media/pci/ivtv/ivtv-udma.c
index 2c9232e..3b33e87 100644
--- a/drivers/media/pci/ivtv/ivtv-udma.c
+++ b/drivers/media/pci/ivtv/ivtv-udma.c
@@ -76,7 +76,7 @@ void ivtv_udma_fill_sg_array (struct ivtv_user_dma *dma, u32 
buffer_offset, u32
int i;
struct scatterlist *sg;
 
-   for (i = 0, sg = dma->SGlist; i < dma->SG_length; i++, sg = 
sg_next(sg)) {
+   for_each_sg(dma->SGlist, sg, dma->SG_length, i) {
dma->SGarray[i].size = cpu_to_le32(sg_dma_len(sg));
dma->SGarray[i].src = cpu_to_le32(sg_dma_address(sg));
dma->SGarray[i].dst = cpu_to_le32(buffer_offset);
-- 
2.9.3



Re: [PATCH v7 0/9] Qualcomm video decoder/encoder driver

2017-03-24 Thread Hans Verkuil
On 03/24/17 15:06, Hans Verkuil wrote:
> On 03/13/17 17:37, Stanimir Varbanov wrote:
>> Hi all,
>>
>> Here is seventh version of the patch-set - no functional changes in
>> v4l2 APIs.
>>
>> The changes since v6 are.
>>   * changes in DT binding document - moved memory-region DT property
>> in video-codec node - see 2/9.
>>   * improved recovery mechanism. 
>>   * fixed various issues found during testing.
>>
>> Build dependencies:
>>   - qcom_scm_set_remote_state is merged in Linux 4.11-rc1
>>   - qcom mdt_loader is merged in Linux 4.11-rc1
>>
>> regards,
>> Stan
>>   
>> Stanimir Varbanov (9):
>>   media: v4l2-mem2mem: extend m2m APIs for more accurate buffer
>> management
> 
> I don't see this patch on linux-media. Can you post that one again?

Urgh, never mind. It's there, my mistake.

> 
> Can you also post the v4l2-compliance test results? Make sure you compile
> v4l2-compliance straight from the git repo to avoid testing with an old
> version.

This I'd still like to see.

Hans

> 
> Thanks!
> 
>   Hans
> 
>>   doc: DT: venus: binding document for Qualcomm video driver
>>   MAINTAINERS: Add Qualcomm Venus video accelerator driver
>>   media: venus: adding core part and helper functions
>>   media: venus: vdec: add video decoder files
>>   media: venus: venc: add video encoder files
>>   media: venus: hfi: add Host Firmware Interface (HFI)
>>   media: venus: hfi: add Venus HFI files
>>   media: venus: enable building of Venus video driver
>>
>>  .../devicetree/bindings/media/qcom,venus.txt   |  107 ++
>>  MAINTAINERS|8 +
>>  drivers/media/platform/Kconfig |   14 +
>>  drivers/media/platform/Makefile|2 +
>>  drivers/media/platform/qcom/venus/Makefile |   11 +
>>  drivers/media/platform/qcom/venus/core.c   |  386 +
>>  drivers/media/platform/qcom/venus/core.h   |  306 
>>  drivers/media/platform/qcom/venus/firmware.c   |  107 ++
>>  drivers/media/platform/qcom/venus/firmware.h   |   22 +
>>  drivers/media/platform/qcom/venus/helpers.c|  632 
>>  drivers/media/platform/qcom/venus/helpers.h|   41 +
>>  drivers/media/platform/qcom/venus/hfi.c|  520 +++
>>  drivers/media/platform/qcom/venus/hfi.h|  174 +++
>>  drivers/media/platform/qcom/venus/hfi_cmds.c   | 1256 
>>  drivers/media/platform/qcom/venus/hfi_cmds.h   |  304 
>>  drivers/media/platform/qcom/venus/hfi_helper.h | 1050 +
>>  drivers/media/platform/qcom/venus/hfi_msgs.c   | 1058 +
>>  drivers/media/platform/qcom/venus/hfi_msgs.h   |  283 
>>  drivers/media/platform/qcom/venus/hfi_venus.c  | 1570 
>> 
>>  drivers/media/platform/qcom/venus/hfi_venus.h  |   23 +
>>  drivers/media/platform/qcom/venus/hfi_venus_io.h   |  113 ++
>>  drivers/media/platform/qcom/venus/vdec.c   | 1091 ++
>>  drivers/media/platform/qcom/venus/vdec.h   |   23 +
>>  drivers/media/platform/qcom/venus/vdec_ctrls.c |  149 ++
>>  drivers/media/platform/qcom/venus/venc.c   | 1231 +++
>>  drivers/media/platform/qcom/venus/venc.h   |   23 +
>>  drivers/media/platform/qcom/venus/venc_ctrls.c |  258 
>>  drivers/media/v4l2-core/v4l2-mem2mem.c |   37 +
>>  include/media/v4l2-mem2mem.h   |   92 ++
>>  29 files changed, 10891 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/media/qcom,venus.txt
>>  create mode 100644 drivers/media/platform/qcom/venus/Makefile
>>  create mode 100644 drivers/media/platform/qcom/venus/core.c
>>  create mode 100644 drivers/media/platform/qcom/venus/core.h
>>  create mode 100644 drivers/media/platform/qcom/venus/firmware.c
>>  create mode 100644 drivers/media/platform/qcom/venus/firmware.h
>>  create mode 100644 drivers/media/platform/qcom/venus/helpers.c
>>  create mode 100644 drivers/media/platform/qcom/venus/helpers.h
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi.c
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi.h
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi_cmds.c
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi_cmds.h
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi_helper.h
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi_msgs.c
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi_msgs.h
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi_venus.c
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi_venus.h
>>  create mode 100644 drivers/media/platform/qcom/venus/hfi_venus_io.h
>>  create mode 100644 drivers/media/platform/qcom/venus/vdec.c
>>  create mode 100644 drivers/media/platform/qcom/venus/vdec.h
>>  create mode 100644 drivers/media/platform/qcom/venus/vdec_ctrls.c
>>  create mode 100644 drivers/media/platform/qcom/venus/venc.c
>> 

Re: [PATCH v7 0/9] Qualcomm video decoder/encoder driver

2017-03-24 Thread Hans Verkuil
On 03/13/17 17:37, Stanimir Varbanov wrote:
> Hi all,
> 
> Here is seventh version of the patch-set - no functional changes in
> v4l2 APIs.
> 
> The changes since v6 are.
>   * changes in DT binding document - moved memory-region DT property
> in video-codec node - see 2/9.
>   * improved recovery mechanism. 
>   * fixed various issues found during testing.
> 
> Build dependencies:
>   - qcom_scm_set_remote_state is merged in Linux 4.11-rc1
>   - qcom mdt_loader is merged in Linux 4.11-rc1
> 
> regards,
> Stan
>   
> Stanimir Varbanov (9):
>   media: v4l2-mem2mem: extend m2m APIs for more accurate buffer
> management

I don't see this patch on linux-media. Can you post that one again?

Can you also post the v4l2-compliance test results? Make sure you compile
v4l2-compliance straight from the git repo to avoid testing with an old
version.

Thanks!

Hans

>   doc: DT: venus: binding document for Qualcomm video driver
>   MAINTAINERS: Add Qualcomm Venus video accelerator driver
>   media: venus: adding core part and helper functions
>   media: venus: vdec: add video decoder files
>   media: venus: venc: add video encoder files
>   media: venus: hfi: add Host Firmware Interface (HFI)
>   media: venus: hfi: add Venus HFI files
>   media: venus: enable building of Venus video driver
> 
>  .../devicetree/bindings/media/qcom,venus.txt   |  107 ++
>  MAINTAINERS|8 +
>  drivers/media/platform/Kconfig |   14 +
>  drivers/media/platform/Makefile|2 +
>  drivers/media/platform/qcom/venus/Makefile |   11 +
>  drivers/media/platform/qcom/venus/core.c   |  386 +
>  drivers/media/platform/qcom/venus/core.h   |  306 
>  drivers/media/platform/qcom/venus/firmware.c   |  107 ++
>  drivers/media/platform/qcom/venus/firmware.h   |   22 +
>  drivers/media/platform/qcom/venus/helpers.c|  632 
>  drivers/media/platform/qcom/venus/helpers.h|   41 +
>  drivers/media/platform/qcom/venus/hfi.c|  520 +++
>  drivers/media/platform/qcom/venus/hfi.h|  174 +++
>  drivers/media/platform/qcom/venus/hfi_cmds.c   | 1256 
>  drivers/media/platform/qcom/venus/hfi_cmds.h   |  304 
>  drivers/media/platform/qcom/venus/hfi_helper.h | 1050 +
>  drivers/media/platform/qcom/venus/hfi_msgs.c   | 1058 +
>  drivers/media/platform/qcom/venus/hfi_msgs.h   |  283 
>  drivers/media/platform/qcom/venus/hfi_venus.c  | 1570 
> 
>  drivers/media/platform/qcom/venus/hfi_venus.h  |   23 +
>  drivers/media/platform/qcom/venus/hfi_venus_io.h   |  113 ++
>  drivers/media/platform/qcom/venus/vdec.c   | 1091 ++
>  drivers/media/platform/qcom/venus/vdec.h   |   23 +
>  drivers/media/platform/qcom/venus/vdec_ctrls.c |  149 ++
>  drivers/media/platform/qcom/venus/venc.c   | 1231 +++
>  drivers/media/platform/qcom/venus/venc.h   |   23 +
>  drivers/media/platform/qcom/venus/venc_ctrls.c |  258 
>  drivers/media/v4l2-core/v4l2-mem2mem.c |   37 +
>  include/media/v4l2-mem2mem.h   |   92 ++
>  29 files changed, 10891 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/qcom,venus.txt
>  create mode 100644 drivers/media/platform/qcom/venus/Makefile
>  create mode 100644 drivers/media/platform/qcom/venus/core.c
>  create mode 100644 drivers/media/platform/qcom/venus/core.h
>  create mode 100644 drivers/media/platform/qcom/venus/firmware.c
>  create mode 100644 drivers/media/platform/qcom/venus/firmware.h
>  create mode 100644 drivers/media/platform/qcom/venus/helpers.c
>  create mode 100644 drivers/media/platform/qcom/venus/helpers.h
>  create mode 100644 drivers/media/platform/qcom/venus/hfi.c
>  create mode 100644 drivers/media/platform/qcom/venus/hfi.h
>  create mode 100644 drivers/media/platform/qcom/venus/hfi_cmds.c
>  create mode 100644 drivers/media/platform/qcom/venus/hfi_cmds.h
>  create mode 100644 drivers/media/platform/qcom/venus/hfi_helper.h
>  create mode 100644 drivers/media/platform/qcom/venus/hfi_msgs.c
>  create mode 100644 drivers/media/platform/qcom/venus/hfi_msgs.h
>  create mode 100644 drivers/media/platform/qcom/venus/hfi_venus.c
>  create mode 100644 drivers/media/platform/qcom/venus/hfi_venus.h
>  create mode 100644 drivers/media/platform/qcom/venus/hfi_venus_io.h
>  create mode 100644 drivers/media/platform/qcom/venus/vdec.c
>  create mode 100644 drivers/media/platform/qcom/venus/vdec.h
>  create mode 100644 drivers/media/platform/qcom/venus/vdec_ctrls.c
>  create mode 100644 drivers/media/platform/qcom/venus/venc.c
>  create mode 100644 drivers/media/platform/qcom/venus/venc.h
>  create mode 100644 drivers/media/platform/qcom/venus/venc_ctrls.c
> 



Re: [PATCH] staging: media: atomisp: remove ifdef around HMM_BO_ION

2017-03-24 Thread Greg Kroah-Hartman
On Fri, Mar 24, 2017 at 02:20:24PM +0100, Arnd Bergmann wrote:
> The revert reintroduced a build failure without CONFIG_ION:
> 
> media/atomisp/pci/atomisp2/hmm/hmm.c:52:2: error: excess elements in array 
> initializer [-Werror]
> media/atomisp/pci/atomisp2/hmm/hmm.c:52:2: note: (near initialization for 
> 'hmm_bo_type_strings')
> 
> We should really be able to build in any configuration, so this tries a
> different fix to make sure the symbol is defined.
> 
> Fixes: 9ca98bd07748 ("Revert "staging: media: atomisp: fill properly 
> hmm_bo_type_strings when ION is disabled"")
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/staging/media/atomisp/pci/atomisp2/include/hmm/hmm_bo.h | 2 --
>  1 file changed, 2 deletions(-)

Ugh, Alan, what's going on here, I thought you fixed this?

totally confused,

greg k-h


[PATCH] staging: media: atomisp: remove ifdef around HMM_BO_ION

2017-03-24 Thread Arnd Bergmann
The revert reintroduced a build failure without CONFIG_ION:

media/atomisp/pci/atomisp2/hmm/hmm.c:52:2: error: excess elements in array 
initializer [-Werror]
media/atomisp/pci/atomisp2/hmm/hmm.c:52:2: note: (near initialization for 
'hmm_bo_type_strings')

We should really be able to build in any configuration, so this tries a
different fix to make sure the symbol is defined.

Fixes: 9ca98bd07748 ("Revert "staging: media: atomisp: fill properly 
hmm_bo_type_strings when ION is disabled"")
Signed-off-by: Arnd Bergmann 
---
 drivers/staging/media/atomisp/pci/atomisp2/include/hmm/hmm_bo.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/include/hmm/hmm_bo.h 
b/drivers/staging/media/atomisp/pci/atomisp2/include/hmm/hmm_bo.h
index dffd6e9cf693..513d06dff043 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/include/hmm/hmm_bo.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/include/hmm/hmm_bo.h
@@ -81,9 +81,7 @@ enum hmm_bo_type {
HMM_BO_PRIVATE,
HMM_BO_SHARE,
HMM_BO_USER,
-#ifdef CONFIG_ION
HMM_BO_ION,
-#endif
HMM_BO_LAST,
 };
 
-- 
2.9.0



Re: [PATCH 0/3] Handling of reduced FPS in V4L2

2017-03-24 Thread Hans Verkuil
On 03/24/17 13:21, Jose Abreu wrote:
> Hi Hans,
> 
> 
> On 24-03-2017 12:12, Hans Verkuil wrote:
>> On 03/24/17 12:52, Jose Abreu wrote:
>>> Hi Hans,
>>>
>>>
> Can you please review this series, when possible? And if you
> could test it on cobalt it would be great :)
 Hopefully next week. 
>>> Thanks :)
>>>
 Did you have some real-world numbers w.r.t. measured
 pixelclock frequencies and 60 vs 59.94 Hz and 24 vs 23.976 Hz?
>>> I did make some measurements but I'm afraid I didn't yet test
>>> with many sources (I mostly tested with signal generators which
>>> should have a higher precision clock than real sources). I have a
>>> bunch of players here, I will test them as soon as I can.
>>> Regarding precision: for our controller is theoretically and
>>> effectively enough: The worst case is for 640x480, and even in
>>> that case the difference between 60Hz and 59.94Hz is > 1 unit of
>>> the measuring register. This still doesn't solve the problem of
>>> having a bad source with a bad clock, but I don't know if we can
>>> do much more about that.
>> I would really like to see a table with different sources sending
>> these different framerates and the value that your HW detects.
>>
>> If there is an obvious and clear difference, then this feature makes
>> sense. If it is all over the place, then I need to think about this
>> some more.
>>
>> To be honest, I expect that you will see 'an obvious and clear'
>> difference, but that is no more than a gut feeling at the moment and
>> I would like to see some proper test results.
> 
> Ok, I will make a table. The test procedure will be like this:
> - Measure pixel clock value using certified HDMI analyzer
> - Measure pixel clock using our controller
> - Compare the values obtained from analyzer, controller and
> the values that the source is telling to send (the value
> displayed in source menu for example [though, some of them may
> not discriminate the exact frame rate, thats why analyzer should
> be used also]).
> 
> Seems ok? I will need some time, something like a week because my
> setup was "borrowed".

That sounds good. Sorry for adding to your workload, but there is no
point to have a flag that in practice is meaningless.

I'm actually very curious about the results!

Regards,

Hans

> 
> Best regards,
> Jose Miguel Abreu
> 
>>
 I do want to see that, since this patch series only makes sense if you can
 actually make use of it to reliably detect the difference.

 I will try to test that myself with cobalt, but almost certainly I won't
 be able to tell the difference; if memory serves it can't detect the freq
 with high enough precision.
>>> Ok, thanks, this would be great because I didn't test the series
>>> exactly "as is" because I'm using 4.10. I did look at vivid
>>> driver but it already handles reduced frame rate, so it kind of
>>> does what it is proposed in this series. If this helper is
>>> integrated in the v4l2 core then I can send the patch to vivid.
>> That would be nice to have in vivid.
>>
>> Regards,
>>
>>  Hans
>>
> 



Re: [PATCH 0/3] Handling of reduced FPS in V4L2

2017-03-24 Thread Jose Abreu
Hi Hans,


On 24-03-2017 12:12, Hans Verkuil wrote:
> On 03/24/17 12:52, Jose Abreu wrote:
>> Hi Hans,
>>
>>
 Can you please review this series, when possible? And if you
 could test it on cobalt it would be great :)
>>> Hopefully next week. 
>> Thanks :)
>>
>>> Did you have some real-world numbers w.r.t. measured
>>> pixelclock frequencies and 60 vs 59.94 Hz and 24 vs 23.976 Hz?
>> I did make some measurements but I'm afraid I didn't yet test
>> with many sources (I mostly tested with signal generators which
>> should have a higher precision clock than real sources). I have a
>> bunch of players here, I will test them as soon as I can.
>> Regarding precision: for our controller is theoretically and
>> effectively enough: The worst case is for 640x480, and even in
>> that case the difference between 60Hz and 59.94Hz is > 1 unit of
>> the measuring register. This still doesn't solve the problem of
>> having a bad source with a bad clock, but I don't know if we can
>> do much more about that.
> I would really like to see a table with different sources sending
> these different framerates and the value that your HW detects.
>
> If there is an obvious and clear difference, then this feature makes
> sense. If it is all over the place, then I need to think about this
> some more.
>
> To be honest, I expect that you will see 'an obvious and clear'
> difference, but that is no more than a gut feeling at the moment and
> I would like to see some proper test results.

Ok, I will make a table. The test procedure will be like this:
- Measure pixel clock value using certified HDMI analyzer
- Measure pixel clock using our controller
- Compare the values obtained from analyzer, controller and
the values that the source is telling to send (the value
displayed in source menu for example [though, some of them may
not discriminate the exact frame rate, thats why analyzer should
be used also]).

Seems ok? I will need some time, something like a week because my
setup was "borrowed".

Best regards,
Jose Miguel Abreu

>
>>> I do want to see that, since this patch series only makes sense if you can
>>> actually make use of it to reliably detect the difference.
>>>
>>> I will try to test that myself with cobalt, but almost certainly I won't
>>> be able to tell the difference; if memory serves it can't detect the freq
>>> with high enough precision.
>> Ok, thanks, this would be great because I didn't test the series
>> exactly "as is" because I'm using 4.10. I did look at vivid
>> driver but it already handles reduced frame rate, so it kind of
>> does what it is proposed in this series. If this helper is
>> integrated in the v4l2 core then I can send the patch to vivid.
> That would be nice to have in vivid.
>
> Regards,
>
>   Hans
>



Re: [PATCH 0/3] Handling of reduced FPS in V4L2

2017-03-24 Thread Hans Verkuil
On 03/24/17 12:52, Jose Abreu wrote:
> Hi Hans,
> 
> 
>>> Can you please review this series, when possible? And if you
>>> could test it on cobalt it would be great :)
>> Hopefully next week. 
> 
> Thanks :)
> 
>> Did you have some real-world numbers w.r.t. measured
>> pixelclock frequencies and 60 vs 59.94 Hz and 24 vs 23.976 Hz?
> 
> I did make some measurements but I'm afraid I didn't yet test
> with many sources (I mostly tested with signal generators which
> should have a higher precision clock than real sources). I have a
> bunch of players here, I will test them as soon as I can.
> Regarding precision: for our controller is theoretically and
> effectively enough: The worst case is for 640x480, and even in
> that case the difference between 60Hz and 59.94Hz is > 1 unit of
> the measuring register. This still doesn't solve the problem of
> having a bad source with a bad clock, but I don't know if we can
> do much more about that.

I would really like to see a table with different sources sending
these different framerates and the value that your HW detects.

If there is an obvious and clear difference, then this feature makes
sense. If it is all over the place, then I need to think about this
some more.

To be honest, I expect that you will see 'an obvious and clear'
difference, but that is no more than a gut feeling at the moment and
I would like to see some proper test results.

> 
>>
>> I do want to see that, since this patch series only makes sense if you can
>> actually make use of it to reliably detect the difference.
>>
>> I will try to test that myself with cobalt, but almost certainly I won't
>> be able to tell the difference; if memory serves it can't detect the freq
>> with high enough precision.
> 
> Ok, thanks, this would be great because I didn't test the series
> exactly "as is" because I'm using 4.10. I did look at vivid
> driver but it already handles reduced frame rate, so it kind of
> does what it is proposed in this series. If this helper is
> integrated in the v4l2 core then I can send the patch to vivid.

That would be nice to have in vivid.

Regards,

Hans



Re: [PATCH 0/3] Handling of reduced FPS in V4L2

2017-03-24 Thread Jose Abreu
Hi Hans,


>> Can you please review this series, when possible? And if you
>> could test it on cobalt it would be great :)
> Hopefully next week. 

Thanks :)

> Did you have some real-world numbers w.r.t. measured
> pixelclock frequencies and 60 vs 59.94 Hz and 24 vs 23.976 Hz?

I did make some measurements but I'm afraid I didn't yet test
with many sources (I mostly tested with signal generators which
should have a higher precision clock than real sources). I have a
bunch of players here, I will test them as soon as I can.
Regarding precision: for our controller is theoretically and
effectively enough: The worst case is for 640x480, and even in
that case the difference between 60Hz and 59.94Hz is > 1 unit of
the measuring register. This still doesn't solve the problem of
having a bad source with a bad clock, but I don't know if we can
do much more about that.

>
> I do want to see that, since this patch series only makes sense if you can
> actually make use of it to reliably detect the difference.
>
> I will try to test that myself with cobalt, but almost certainly I won't
> be able to tell the difference; if memory serves it can't detect the freq
> with high enough precision.

Ok, thanks, this would be great because I didn't test the series
exactly "as is" because I'm using 4.10. I did look at vivid
driver but it already handles reduced frame rate, so it kind of
does what it is proposed in this series. If this helper is
integrated in the v4l2 core then I can send the patch to vivid.

Best regards,
Jose Miguel Abreu

>
> Regards,
>
>   Hans



Re: [PATCH 0/3] Handling of reduced FPS in V4L2

2017-03-24 Thread Hans Verkuil
On 03/24/17 12:03, Jose Abreu wrote:
> Hi Hans,
> 
> 
> On 21-03-2017 11:49, Jose Abreu wrote:
>> Hi all,
>>
>> This is a follow up patch from this discussion [1]. It should be
>> seen more as a starting point to introduce better handling of
>> time per frame in v4l2. Quoting Hans Verkuil from [1]:
>>
>> 1) "Add a flag V4L2_DV_FL_CAN_DETECT_REDUCED_FPS. If set,
>> then the hw can detect the difference between regular fps
>> and 1000/1001 fps. Note: this is only valid for timings of
>> VIC codes with the V4L2_DV_FL_CAN_REDUCE_FPS flag set."
>>
>> 2) "Allow V4L2_DV_FL_REDUCED_FPS to be used for receivers
>> if V4L2_DV_FL_CAN_DETECT_REDUCED_FPS is set."
>>
>> 3) "For standard VIC codes the pixelclock returned by
>> query_dv_timings is that of the corresponding VIC timing,
>> not what is measured. This will ensure fixed fps values"
>>
>> 4) "g_parm should calculate the fps based on the v4l2_bt_timings
>> struct, looking at the REDUCES_FPS flags. For those receivers that
>> cannot detect the difference, the fps will be 24/30/60 Hz, for
>> those that can detect the difference g_parm can check if both
>> V4L2_DV_FL_CAN_DETECT_REDUCED_FPS and V4L2_DV_FL_REDUCED_FPS are
>> set and reduce the fps by 1000/1001."
>>
>> ---
>> In terms of implementation:
>>  - Point 1) is done in patch 1/3
>>  - Point 2) and 3) should be done by a HDMI Receiver driver
>>  (I think?).
>>  - Point 4) is done in patch 2/3.
>>  - The patch 3/3 is a simple implementation (which was not
>>  tested) in the cobalt driver
>> ---
>>  
>> [1] https://patchwork.kernel.org/patch/9609441/
>>
>> Best regards,
>> Jose Miguel Abreu
>>
>> Cc: Carlos Palminha 
>> Cc: Mauro Carvalho Chehab 
>> Cc: Hans Verkuil 
>> Cc: linux-media@vger.kernel.org
>> Cc: linux-ker...@vger.kernel.org
>>
>> Jose Abreu (3):
>>   [media] videodev2.h: Add new DV flag CAN_DETECT_REDUCED_FPS
>>   [media] v4l2-dv-timings: Introduce v4l2_calc_timeperframe helper
>>   [media] cobalt: Use v4l2_calc_timeperframe helper
>>
>>  drivers/media/pci/cobalt/cobalt-v4l2.c|  9 +--
>>  drivers/media/v4l2-core/v4l2-dv-timings.c | 39 
>> +++
>>  include/media/v4l2-dv-timings.h   | 11 +
>>  include/uapi/linux/videodev2.h|  7 ++
>>  4 files changed, 64 insertions(+), 2 deletions(-)
>>
> 
> Can you please review this series, when possible? And if you
> could test it on cobalt it would be great :)

Hopefully next week. Did you have some real-world numbers w.r.t. measured
pixelclock frequencies and 60 vs 59.94 Hz and 24 vs 23.976 Hz?

I do want to see that, since this patch series only makes sense if you can
actually make use of it to reliably detect the difference.

I will try to test that myself with cobalt, but almost certainly I won't
be able to tell the difference; if memory serves it can't detect the freq
with high enough precision.

Regards,

Hans


Re: [PATCH 0/3] Handling of reduced FPS in V4L2

2017-03-24 Thread Jose Abreu
Hi Hans,


On 21-03-2017 11:49, Jose Abreu wrote:
> Hi all,
>
> This is a follow up patch from this discussion [1]. It should be
> seen more as a starting point to introduce better handling of
> time per frame in v4l2. Quoting Hans Verkuil from [1]:
>
> 1) "Add a flag V4L2_DV_FL_CAN_DETECT_REDUCED_FPS. If set,
> then the hw can detect the difference between regular fps
> and 1000/1001 fps. Note: this is only valid for timings of
> VIC codes with the V4L2_DV_FL_CAN_REDUCE_FPS flag set."
>
> 2) "Allow V4L2_DV_FL_REDUCED_FPS to be used for receivers
> if V4L2_DV_FL_CAN_DETECT_REDUCED_FPS is set."
>
> 3) "For standard VIC codes the pixelclock returned by
> query_dv_timings is that of the corresponding VIC timing,
> not what is measured. This will ensure fixed fps values"
>
> 4) "g_parm should calculate the fps based on the v4l2_bt_timings
> struct, looking at the REDUCES_FPS flags. For those receivers that
> cannot detect the difference, the fps will be 24/30/60 Hz, for
> those that can detect the difference g_parm can check if both
> V4L2_DV_FL_CAN_DETECT_REDUCED_FPS and V4L2_DV_FL_REDUCED_FPS are
> set and reduce the fps by 1000/1001."
>
> ---
> In terms of implementation:
>   - Point 1) is done in patch 1/3
>   - Point 2) and 3) should be done by a HDMI Receiver driver
>   (I think?).
>   - Point 4) is done in patch 2/3.
>   - The patch 3/3 is a simple implementation (which was not
>   tested) in the cobalt driver
> ---
>   
> [1] https://patchwork.kernel.org/patch/9609441/
>
> Best regards,
> Jose Miguel Abreu
>
> Cc: Carlos Palminha 
> Cc: Mauro Carvalho Chehab 
> Cc: Hans Verkuil 
> Cc: linux-media@vger.kernel.org
> Cc: linux-ker...@vger.kernel.org
>
> Jose Abreu (3):
>   [media] videodev2.h: Add new DV flag CAN_DETECT_REDUCED_FPS
>   [media] v4l2-dv-timings: Introduce v4l2_calc_timeperframe helper
>   [media] cobalt: Use v4l2_calc_timeperframe helper
>
>  drivers/media/pci/cobalt/cobalt-v4l2.c|  9 +--
>  drivers/media/v4l2-core/v4l2-dv-timings.c | 39 
> +++
>  include/media/v4l2-dv-timings.h   | 11 +
>  include/uapi/linux/videodev2.h|  7 ++
>  4 files changed, 64 insertions(+), 2 deletions(-)
>

Can you please review this series, when possible? And if you
could test it on cobalt it would be great :)

Best regards,
Jose Miguel Abreu


[GIT PULL for v4.11-rc4] media fixes

2017-03-24 Thread Mauro Carvalho Chehab
Hi Linus,

Please pull from:
  git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
tags/media/v4.11-3

for a series of fixes:
   - dvb-usb-firmware: don't do DMA on stack
   - coda/imx-vdoa: platform_driver should not be const
   - bdisp: Clean up file handle in open() error path
   - exynos-gsc: Do not swap cb/cr for semi planar formats

Thanks!
Mauro


The following changes since commit 8c71fff434e5ecf5ff27bd61db1bc9ac4c2b2a1b:

  [media] v4l: vsp1: Adapt vsp1_du_setup_lif() interface to use a structure 
(2017-03-07 13:34:11 -0300)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media 
tags/media/v4.11-3

for you to fetch changes up to 24a47426066c8ba16a4db1b20a41d63187281195:

  [media] exynos-gsc: Do not swap cb/cr for semi planar formats (2017-03-22 
09:50:07 -0300)


media fixes for v4.11-rc4


Arnd Bergmann (1):
  [media] coda/imx-vdoa: platform_driver should not be const

Shailendra Verma (1):
  [media] bdisp: Clean up file handle in open() error path

Stefan Brüns (1):
  [media] dvb-usb-firmware: don't do DMA on stack

Thibault Saunier (1):
  [media] exynos-gsc: Do not swap cb/cr for semi planar formats

 drivers/media/platform/coda/imx-vdoa.c|  2 +-
 drivers/media/platform/exynos-gsc/gsc-core.c  |  2 --
 drivers/media/platform/sti/bdisp/bdisp-v4l2.c |  2 +-
 drivers/media/usb/dvb-usb/dvb-usb-firmware.c  | 22 --
 4 files changed, 14 insertions(+), 14 deletions(-)



Re: JVC camera and Hauppauge PVR-150 framegrabber.

2017-03-24 Thread Mauro Carvalho Chehab
Em Thu, 23 Mar 2017 17:04:21 -0700
pe...@easthope.ca escreveu:

> With a manual setting of the device path and ID, the V4L2 Test Bench 
> produced this image from a JVC TK-1070U camera on a microscope.  
> http://easthope.ca/JVCtoPVR150screen.jpg
> 
> Setting the device in the Test Bench each time it is opened becomes 
> tedious and no /etc/*v4l* exists.  Can the default configuration be 
> adjusted permanently without recompiling?  How?
> 
> Although too dark, the image from the microscope slide is faintly 
> visible. The upper half of the image is on the bottom of the screen 
> and the lower half is at the top.  On a VCR I might try adjusting 
> vertical sync.  Is there an equivalent in the Test Bench?

You could use v4l2-ctl to set all parameters you need in order to
get a good quality image.

It is possible to automatically call it by adding a udev rule.
This link explains how to do things like that (although their
examples are for different use cases):

https://www.mythtv.org/wiki/Device_Filenames_and_udev

Some of examples have a directive like:
PROGRAM="..."

With basically makes udev to run a program or script when the device
gets detected.


Thanks,
Mauro


Re: [PATCH] drivers/staging/media: atomisp: Removing redundant information from dev_err

2017-03-24 Thread Dan Carpenter
On Fri, Mar 24, 2017 at 11:18:33AM +0530, Pushkar Jambhlekar wrote:
> Removing hardcoded function name as code is already using __func__
> 
> Signed-off-by: Pushkar Jambhlekar 
> ---
>  drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c 
> b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
> index d1a609d2..a51a27b 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c
> @@ -64,7 +64,7 @@ struct hmm_buffer_object *__bo_alloc(struct kmem_cache 
> *bo_cache)
>  
>   bo = kmem_cache_alloc(bo_cache, GFP_KERNEL);
>   if (!bo)
> - dev_err(atomisp_dev, "%s: __bo_alloc failed!\n", __func__);
> + dev_err(atomisp_dev, "%s: failed!\n", __func__);

The whole printk can be removed.  kmem_cache_alloc() has its own better
printks.

regards,
dan carpenter