Re: [PATCH v2 2/2] x86/mm/pat, drivers/media/ivtv: move pat warn and replace WARN() with pr_warn()

2015-06-24 Thread Ingo Molnar

* Luis R. Rodriguez  wrote:

> From: "Luis R. Rodriguez" 
> 
> On built-in kernels this warning will always splat as this is part
> of the module init. Fix that by shifting the PAT requirement check
> out under the code that does the "quasi-probe" for the device. This
> device driver relies on an existing driver to find its own devices,
> it looks for that device driver and its own found devices, then
> uses driver_for_each_device() to try to see if it can probe each of
> those devices as a frambuffer device with ivtvfb_init_card(). We
> tuck the PAT requiremenet check then on the ivtvfb_init_card()
> call making the check at least require an ivtv device present
> before complaining.
> 
> Reported-by: Fengguang Wu  [0-day test robot]
> Signed-off-by: Luis R. Rodriguez 
> ---
>  drivers/media/pci/ivtv/ivtvfb.c | 15 +--
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
> index 4cb365d..8b95eef 100644
> --- a/drivers/media/pci/ivtv/ivtvfb.c
> +++ b/drivers/media/pci/ivtv/ivtvfb.c
> @@ -38,6 +38,8 @@
>  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include 
>  #include 
>  #include 
> @@ -1171,6 +1173,13 @@ static int ivtvfb_init_card(struct ivtv *itv)
>  {
>   int rc;
>  
> +#ifdef CONFIG_X86_64
> + if (pat_enabled()) {
> + pr_warn("ivtvfb needs PAT disabled, boot with nopat kernel 
> parameter\n");
> + return -ENODEV;
> + }
> +#endif
> +
>   if (itv->osd_info) {
>   IVTVFB_ERR("Card %d already initialised\n", ivtvfb_card_id);
>   return -EBUSY;

Same argument as for ipath: why not make arch_phys_wc_add() fail on PAT and 
return 
-1, and check it in arch_phys_wc_del()?

That way we don't do anything drastic, the remaining few drivers still keep 
working (albeit suboptimally - can be worked around with the 'nopat' boot 
option) 
- yet we've reduced the use of MTRRs drastically.

Thanks,

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


Re: [PATCH v2 1/2] x86/mm/pat, drivers/infiniband/ipath: replace WARN() with pr_warn()

2015-06-24 Thread Ingo Molnar

* Luis R. Rodriguez  wrote:

> From: "Luis R. Rodriguez" 
> 
> WARN() may confuse users, fix that. ipath_init_one() is part the
> device's probe so this would only be triggered if a corresponding
> device was found.
> 
> Signed-off-by: Luis R. Rodriguez 
> ---
>  drivers/infiniband/hw/ipath/ipath_driver.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c 
> b/drivers/infiniband/hw/ipath/ipath_driver.c
> index 2d7e503..871dbe5 100644
> --- a/drivers/infiniband/hw/ipath/ipath_driver.c
> +++ b/drivers/infiniband/hw/ipath/ipath_driver.c
> @@ -31,6 +31,8 @@
>   * SOFTWARE.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include 
>  #include 
>  #include 
> @@ -399,8 +401,8 @@ static int ipath_init_one(struct pci_dev *pdev, const 
> struct pci_device_id *ent)
>   u32 bar0 = 0, bar1 = 0;
>  
>  #ifdef CONFIG_X86_64
> - if (WARN(pat_enabled(),
> -  "ipath needs PAT disabled, boot with nopat kernel 
> parameter\n")) {
> + if (pat_enabled()) {
> + pr_warn("ipath needs PAT disabled, boot with nopat kernel 
> parameter\n");
>   ret = -ENODEV;
>   goto bail;
>   }

So driver init will always fail with this on modern kernels.

Btw., on a second thought, ipath uses MTRRs to enable WC:

ret = ipath_enable_wc(dd);
if (ret)
ret = 0;

Note how it ignores any failures - the driver still works even if WC was not 
enabled.

So why don't you simply extend ipath_enable_wc() to generate the warning 
message 
and return -EINVAL - which still keeps the driver working on modern kernels?

Just inform the user about 'nopat' if he wants WC for this driver.

Thanks,

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


cron job: media_tree daily build: OK

2015-06-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:   Thu Jun 25 04:00:30 CEST 2015
git branch: test
git hash:   faebbd8f134f0c054f372982c8ddd1bbcc41b440
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0-44-g40791b9
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:4.0.0-3.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin-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.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
linux-3.19-i686: OK
linux-4.0-i686: OK
linux-4.1-rc1-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-x86_64: OK
linux-4.1-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH 02/12] [media] dvb-pll: Add support for THOMSON DTT7546X tuner.

2015-06-24 Thread Joe Perches
On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
> This is used in conjunction with the STV0367 demodulator on
> the STV0367-NIM-V1.0 NIM card which can be used with the STi
> STB SoC's.

Barely associated to this specific patch, but for
dvb-pll.c, another thing that seems possible is to
convert the struct dvb_pll_desc uses to const and
change the "entries" fixed array size from 12 to []

It'd save a couple KB overall and remove ~5KB of data.

$ size drivers/media/dvb-frontends/dvb-pll.o*
   textdata bss dec hex filename
   852015522120   121922fa0 
drivers/media/dvb-frontends/dvb-pll.o.new
   562463632120   14107371b 
drivers/media/dvb-frontends/dvb-pll.o.old
---
 drivers/media/dvb-frontends/dvb-pll.c | 50 +--
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/media/dvb-frontends/dvb-pll.c 
b/drivers/media/dvb-frontends/dvb-pll.c
index 6d8fe88..53089e1 100644
--- a/drivers/media/dvb-frontends/dvb-pll.c
+++ b/drivers/media/dvb-frontends/dvb-pll.c
@@ -34,7 +34,7 @@ struct dvb_pll_priv {
struct i2c_adapter *i2c;
 
/* the PLL descriptor */
-   struct dvb_pll_desc *pll_desc;
+   const struct dvb_pll_desc *pll_desc;
 
/* cached frequency/bandwidth */
u32 frequency;
@@ -57,7 +57,7 @@ MODULE_PARM_DESC(id, "force pll id to use (DEBUG ONLY)");
 /* --- */
 
 struct dvb_pll_desc {
-   char *name;
+   const char *name;
u32  min;
u32  max;
u32  iffreq;
@@ -71,13 +71,13 @@ struct dvb_pll_desc {
u32 stepsize;
u8  config;
u8  cb;
-   } entries[12];
+   } entries[];
 };
 
 /* --- */
 /* descriptions*/
 
-static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
+static const struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
.name  = "Thomson dtt7579",
.min   = 17700,
.max   = 85800,
@@ -99,7 +99,7 @@ static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 
*buf)
buf[3] |= 0x10;
 }
 
-static struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
+static const struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
.name  = "Thomson dtt759x",
.min   = 17700,
.max   = 89600,
@@ -123,7 +123,7 @@ static void thomson_dtt7520x_bw(struct dvb_frontend *fe, u8 
*buf)
buf[3] ^= 0x10;
 }
 
-static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
+static const struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
.name  = "Thomson dtt7520x",
.min   = 18500,
.max   = 9,
@@ -141,7 +141,7 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
},
 };
 
-static struct dvb_pll_desc dvb_pll_lg_z201 = {
+static const struct dvb_pll_desc dvb_pll_lg_z201 = {
.name  = "LG z201",
.min   = 17400,
.max   = 86200,
@@ -157,7 +157,7 @@ static struct dvb_pll_desc dvb_pll_lg_z201 = {
},
 };
 
-static struct dvb_pll_desc dvb_pll_unknown_1 = {
+static const struct dvb_pll_desc dvb_pll_unknown_1 = {
.name  = "unknown 1", /* used by dntv live dvb-t */
.min   = 17400,
.max   = 86200,
@@ -179,7 +179,7 @@ static struct dvb_pll_desc dvb_pll_unknown_1 = {
 /* Infineon TUA6010XS
  * used in Thomson Cable Tuner
  */
-static struct dvb_pll_desc dvb_pll_tua6010xs = {
+static const struct dvb_pll_desc dvb_pll_tua6010xs = {
.name  = "Infineon TUA6010XS",
.min   =  4425,
.max   = 85800,
@@ -193,7 +193,7 @@ static struct dvb_pll_desc dvb_pll_tua6010xs = {
 };
 
 /* Panasonic env57h1xd5 (some Philips PLL ?) */
-static struct dvb_pll_desc dvb_pll_env57h1xd5 = {
+static const struct dvb_pll_desc dvb_pll_env57h1xd5 = {
.name  = "Panasonic ENV57H1XD5",
.min   =  4425,
.max   = 85800,
@@ -217,7 +217,7 @@ static void tda665x_bw(struct dvb_frontend *fe, u8 *buf)
buf[3] |= 0x08;
 }
 
-static struct dvb_pll_desc dvb_pll_tda665x = {
+static const struct dvb_pll_desc dvb_pll_tda665x = {
.name  = "Philips TDA6650/TDA6651",
.min   =  4425,
.max   = 85800,
@@ -251,7 +251,7 @@ static void tua6034_bw(struct dvb_frontend *fe, u8 *buf)
buf[3] |= 0x08;
 }
 
-static struct dvb_pll_desc dvb_pll_tua6034 = {
+static const struct dvb_pll_desc dvb_pll_tua6034 = {
.name  = "Infineon TUA6034",
.min   =  4425,
.max   = 85800,
@@ -275,7 +275,7 @@ static void tded4_bw(struct dvb_frontend *fe, u8 *buf)
buf[3] |= 0x04;
 }
 
-static struct dvb_pll_desc dvb_pll_tded4 = {
+static const struct dvb_pll_desc dvb_pll_tded4 = {
.name = "ALPS TDED4",
.min = 4700,
.max = 86300,
@@ -293,7 +293,7 @@ static struct dvb_pll_desc dvb_pll_tded4

[PATCH v2 2/2] x86/mm/pat, drivers/media/ivtv: move pat warn and replace WARN() with pr_warn()

2015-06-24 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

On built-in kernels this warning will always splat as this is part
of the module init. Fix that by shifting the PAT requirement check
out under the code that does the "quasi-probe" for the device. This
device driver relies on an existing driver to find its own devices,
it looks for that device driver and its own found devices, then
uses driver_for_each_device() to try to see if it can probe each of
those devices as a frambuffer device with ivtvfb_init_card(). We
tuck the PAT requiremenet check then on the ivtvfb_init_card()
call making the check at least require an ivtv device present
before complaining.

Reported-by: Fengguang Wu  [0-day test robot]
Signed-off-by: Luis R. Rodriguez 
---
 drivers/media/pci/ivtv/ivtvfb.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c
index 4cb365d..8b95eef 100644
--- a/drivers/media/pci/ivtv/ivtvfb.c
+++ b/drivers/media/pci/ivtv/ivtvfb.c
@@ -38,6 +38,8 @@
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -1171,6 +1173,13 @@ static int ivtvfb_init_card(struct ivtv *itv)
 {
int rc;
 
+#ifdef CONFIG_X86_64
+   if (pat_enabled()) {
+   pr_warn("ivtvfb needs PAT disabled, boot with nopat kernel 
parameter\n");
+   return -ENODEV;
+   }
+#endif
+
if (itv->osd_info) {
IVTVFB_ERR("Card %d already initialised\n", ivtvfb_card_id);
return -EBUSY;
@@ -1265,12 +1274,6 @@ static int __init ivtvfb_init(void)
int registered = 0;
int err;
 
-#ifdef CONFIG_X86_64
-   if (WARN(pat_enabled(),
-"ivtvfb needs PAT disabled, boot with nopat kernel 
parameter\n")) {
-   return -ENODEV;
-   }
-#endif
 
if (ivtvfb_card_id < -1 || ivtvfb_card_id >= IVTV_MAX_CARDS) {
printk(KERN_ERR "ivtvfb:  ivtvfb_card_id parameter is out of 
range (valid range: -1 - %d)\n",
-- 
2.3.2.209.gd67f9d5.dirty

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


[PATCH v2 1/2] x86/mm/pat, drivers/infiniband/ipath: replace WARN() with pr_warn()

2015-06-24 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

WARN() may confuse users, fix that. ipath_init_one() is part the
device's probe so this would only be triggered if a corresponding
device was found.

Signed-off-by: Luis R. Rodriguez 
---
 drivers/infiniband/hw/ipath/ipath_driver.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c 
b/drivers/infiniband/hw/ipath/ipath_driver.c
index 2d7e503..871dbe5 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -31,6 +31,8 @@
  * SOFTWARE.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
@@ -399,8 +401,8 @@ static int ipath_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
u32 bar0 = 0, bar1 = 0;
 
 #ifdef CONFIG_X86_64
-   if (WARN(pat_enabled(),
-"ipath needs PAT disabled, boot with nopat kernel 
parameter\n")) {
+   if (pat_enabled()) {
+   pr_warn("ipath needs PAT disabled, boot with nopat kernel 
parameter\n");
ret = -ENODEV;
goto bail;
}
-- 
2.3.2.209.gd67f9d5.dirty

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


[PATCH v2 0/2] x86/mm/pat: modify nopat requirement warning

2015-06-24 Thread Luis R. Rodriguez
From: "Luis R. Rodriguez" 

The 0-day robot found that the notpat requirement warning was
being triggered on the ivtv driver on the module init path,
that will always trigger on built-in devices. We want that warning
to trigger only if real hardware is found so this moves the ivtv
warning out under its quasi-probe routine. The ipath driver already
had the warning issued on its probe so no shift of code is needed
there. Upon further thought though we decided WARN() messages would
confuse people so instead just change these to sensible single
pr_warn() messages for both drivers.

This goes build and load tested.

Luis R. Rodriguez (2):
  x86/mm/pat, drivers/infiniband/ipath: replace WARN() with pr_warn()
  x86/mm/pat, drivers/media/ivtv: move pat warn and replace WARN() with
pr_warn()

 drivers/infiniband/hw/ipath/ipath_driver.c |  6 --
 drivers/media/pci/ivtv/ivtvfb.c| 15 +--
 2 files changed, 13 insertions(+), 8 deletions(-)

-- 
2.3.2.209.gd67f9d5.dirty

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


[PATCH 5/5] [media] adv7842: Deliver resolution change events to userspace

2015-06-24 Thread Lars-Peter Clausen
Use the new v4l2_subdev_notify_event() helper function to deliver the
resolution change event to userspace via the v4l2 subdev event queue as
well as to the bridge driver using the callback notify mechanism.

This allows userspace applications to react to changes in resolution. This
is useful and often necessary for video pipelines where there is no direct
1-to-1 relationship between the subdevice converter and the video capture
device and hence it does not make sense to directly forward the event to
the video capture device node.

Signed-off-by: Lars-Peter Clausen 
---
 drivers/media/i2c/adv7842.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index ffc0655..ed51aa7 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -1981,8 +1981,7 @@ static int adv7842_s_routing(struct v4l2_subdev *sd,
select_input(sd, state->vid_std_select);
enable_input(sd);
 
-   v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT,
-  (void *)&adv7842_ev_fmt);
+   v4l2_subdev_notify_event(sd, &adv7842_ev_fmt);
 
return 0;
 }
@@ -2215,8 +2214,7 @@ static int adv7842_isr(struct v4l2_subdev *sd, u32 
status, bool *handled)
 "%s: fmt_change_cp = 0x%x, fmt_change_digital = 0x%x, 
fmt_change_sdp = 0x%x\n",
 __func__, fmt_change_cp, fmt_change_digital,
 fmt_change_sdp);
-   v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT,
-  (void *)&adv7842_ev_fmt);
+   v4l2_subdev_notify_event(sd, &adv7842_ev_fmt);
if (handled)
*handled = true;
}
@@ -3006,6 +3004,20 @@ static long adv7842_ioctl(struct v4l2_subdev *sd, 
unsigned int cmd, void *arg)
return -ENOTTY;
 }
 
+static int adv7842_subscribe_event(struct v4l2_subdev *sd,
+  struct v4l2_fh *fh,
+  struct v4l2_event_subscription *sub)
+{
+   switch (sub->type) {
+   case V4L2_EVENT_SOURCE_CHANGE:
+   return v4l2_src_change_event_subdev_subscribe(sd, fh, sub);
+   case V4L2_EVENT_CTRL:
+   return v4l2_event_subdev_unsubscribe(sd, fh, sub);
+   default:
+   return -EINVAL;
+   }
+}
+
 /* --- */
 
 static const struct v4l2_ctrl_ops adv7842_ctrl_ops = {
@@ -3016,7 +3028,7 @@ static const struct v4l2_subdev_core_ops adv7842_core_ops 
= {
.log_status = adv7842_log_status,
.ioctl = adv7842_ioctl,
.interrupt_service_routine = adv7842_isr,
-   .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+   .subscribe_event = adv7842_subscribe_event,
.unsubscribe_event = v4l2_event_subdev_unsubscribe,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.g_register = adv7842_g_register,
-- 
2.1.4

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


[PATCH 2/5] [media] adv7842: Add support for control event notifications

2015-06-24 Thread Lars-Peter Clausen
Allow userspace applications to subscribe to control change events. This
can e.g. be used to monitor the 5V detect control to be notified when a
source is connected or disconnected.

Signed-off-by: Lars-Peter Clausen 
---
 drivers/media/i2c/adv7842.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 4cf79b2..ffc0655 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3015,6 +3016,8 @@ static const struct v4l2_subdev_core_ops adv7842_core_ops 
= {
.log_status = adv7842_log_status,
.ioctl = adv7842_ioctl,
.interrupt_service_routine = adv7842_isr,
+   .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+   .unsubscribe_event = v4l2_event_subdev_unsubscribe,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.g_register = adv7842_g_register,
.s_register = adv7842_s_register,
@@ -3210,7 +3213,7 @@ static int adv7842_probe(struct i2c_client *client,
 
sd = &state->sd;
v4l2_i2c_subdev_init(sd, client, &adv7842_ops);
-   sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+   sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
state->mode = pdata->mode;
 
state->hdmi_port_a = pdata->input == ADV7842_SELECT_HDMI_PORT_A;
-- 
2.1.4

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


[PATCH 4/5] [media] adv7604: Deliver resolution change events to userspace

2015-06-24 Thread Lars-Peter Clausen
Use the new v4l2_subdev_notify_event() helper function to deliver the
resolution change event to userspace via the v4l2 subdev event queue as
well as to the bridge driver using the callback notify mechanism.

This allows userspace applications to react to changes in resolution. This
is useful and often necessary for video pipelines where there is no direct
1-to-1 relationship between the subdevice converter and the video capture
device and hence it does not make sense to directly forward the event to
the video capture device node.

Signed-off-by: Lars-Peter Clausen 
---
 drivers/media/i2c/adv7604.c | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index cf1cb5a..b66f63e3 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1761,8 +1761,8 @@ static int adv76xx_s_routing(struct v4l2_subdev *sd,
select_input(sd);
enable_input(sd);
 
-   v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT,
-  (void *)&adv76xx_ev_fmt);
+   v4l2_subdev_notify_event(sd, &adv76xx_ev_fmt);
+
return 0;
 }
 
@@ -1929,8 +1929,7 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 
status, bool *handled)
"%s: fmt_change = 0x%x, fmt_change_digital = 0x%x\n",
__func__, fmt_change, fmt_change_digital);
 
-   v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT,
-  (void *)&adv76xx_ev_fmt);
+   v4l2_subdev_notify_event(sd, &adv76xx_ev_fmt);
 
if (handled)
*handled = true;
@@ -2348,6 +2347,20 @@ static int adv76xx_log_status(struct v4l2_subdev *sd)
return 0;
 }
 
+static int adv76xx_subscribe_event(struct v4l2_subdev *sd,
+  struct v4l2_fh *fh,
+  struct v4l2_event_subscription *sub)
+{
+   switch (sub->type) {
+   case V4L2_EVENT_SOURCE_CHANGE:
+   return v4l2_src_change_event_subdev_subscribe(sd, fh, sub);
+   case V4L2_EVENT_CTRL:
+   return v4l2_event_subdev_unsubscribe(sd, fh, sub);
+   default:
+   return -EINVAL;
+   }
+}
+
 /* --- */
 
 static const struct v4l2_ctrl_ops adv76xx_ctrl_ops = {
@@ -2357,7 +2370,7 @@ static const struct v4l2_ctrl_ops adv76xx_ctrl_ops = {
 static const struct v4l2_subdev_core_ops adv76xx_core_ops = {
.log_status = adv76xx_log_status,
.interrupt_service_routine = adv76xx_isr,
-   .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+   .subscribe_event = adv76xx_subscribe_event,
.unsubscribe_event = v4l2_event_subdev_unsubscribe,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.g_register = adv76xx_g_register,
-- 
2.1.4

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


[PATCH 3/5] [media] Add helper function for subdev event notifications

2015-06-24 Thread Lars-Peter Clausen
Add a new helper function called v4l2_subdev_notify_event() which will
deliver the specified event to both the v4l2 subdev event queue as well as
to the notify callback. The former is typically used by userspace
applications to listen to notification events while the later is used by
bridge drivers. Combining both into the same function avoids boilerplate
code in subdev drivers.

Signed-off-by: Lars-Peter Clausen 
---
 drivers/media/v4l2-core/v4l2-subdev.c | 18 ++
 include/media/v4l2-subdev.h   |  4 
 2 files changed, 22 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index 6359606..83615b8 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -588,3 +588,21 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct 
v4l2_subdev_ops *ops)
 #endif
 }
 EXPORT_SYMBOL(v4l2_subdev_init);
+
+/**
+ * v4l2_subdev_notify_event() - Delivers event notification for subdevice
+ * @sd: The subdev for which to deliver the event
+ * @ev: The event to deliver
+ *
+ * Will deliver the specified event to all userspace event listeners which are
+ * subscribed to the v42l subdev event queue as well as to the bridge driver
+ * using the notify callback. The notification type for the notify callback
+ * will be V4L2_DEVICE_NOTIFY_EVENT.
+ */
+void v4l2_subdev_notify_event(struct v4l2_subdev *sd,
+ const struct v4l2_event *ev)
+{
+   v4l2_event_queue(sd->devnode, ev);
+   v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT, (void *)ev);
+}
+EXPORT_SYMBOL_GPL(v4l2_subdev_notify_event);
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index dc20102..65d4a5f 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -44,6 +44,7 @@
 
 struct v4l2_device;
 struct v4l2_ctrl_handler;
+struct v4l2_event;
 struct v4l2_event_subscription;
 struct v4l2_fh;
 struct v4l2_subdev;
@@ -693,4 +694,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
 #define v4l2_subdev_has_op(sd, o, f) \
((sd)->ops->o && (sd)->ops->o->f)
 
+void v4l2_subdev_notify_event(struct v4l2_subdev *sd,
+ const struct v4l2_event *ev);
+
 #endif
-- 
2.1.4

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


[PATCH 1/5] [media] adv7604: Add support for control event notifications

2015-06-24 Thread Lars-Peter Clausen
Allow userspace applications to subscribe to control change events. This
can e.g. be used to monitor the 5V detect control to be notified when a
source is connected or disconnected.

Signed-off-by: Lars-Peter Clausen 
---
 drivers/media/i2c/adv7604.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 808360f..cf1cb5a 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -2356,6 +2357,8 @@ static const struct v4l2_ctrl_ops adv76xx_ctrl_ops = {
 static const struct v4l2_subdev_core_ops adv76xx_core_ops = {
.log_status = adv76xx_log_status,
.interrupt_service_routine = adv76xx_isr,
+   .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+   .unsubscribe_event = v4l2_event_subdev_unsubscribe,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
.g_register = adv76xx_g_register,
.s_register = adv76xx_s_register,
@@ -2833,7 +2836,7 @@ static int adv76xx_probe(struct i2c_client *client,
snprintf(sd->name, sizeof(sd->name), "%s %d-%04x",
id->name, i2c_adapter_id(client->adapter),
client->addr);
-   sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+   sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
 
/*
 * Verify that the chip is present. On ADV7604 the RD_INFO register only
-- 
2.1.4

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


RE: [patch] [media] v4l: xilinx: missing error code

2015-06-24 Thread Hyun Kwon
Hi Dan,

Thanks for the patch.

> -Original Message-
> From: Dan Carpenter [mailto:dan.carpen...@oracle.com]
> Sent: Wednesday, June 24, 2015 7:29 AM
> To: Hyun Kwon
> Cc: Laurent Pinchart; Mauro Carvalho Chehab; Michal Simek; Soren Brinkmann;
> linux-media@vger.kernel.org; kernel-janit...@vger.kernel.org
> Subject: [patch] [media] v4l: xilinx: missing error code
>
> We should set "ret" on this error path instead of returning success.
>
> Fixes: df3305156f98 ('[media] v4l: xilinx: Add Xilinx Video IP core')
> Signed-off-by: Dan Carpenter 

Acked-by: Hyun Kwon 

Thanks,
-hyun



This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.

N�r��yb�X��ǧv�^�)޺{.n�+{���bj)w*jg����ݢj/���z�ޖ��2�ޙ&�)ߡ�a�����G���h��j:+v���w��٥

Re: [PATCH 02/13] dmaengine: Introduce dma_request_slave_channel_compat_reason()

2015-06-24 Thread Vinod Koul
On Mon, Jun 22, 2015 at 02:31:00PM +0300, Peter Ujfalusi wrote:
> On 06/12/2015 03:58 PM, Vinod Koul wrote:
> > Sorry this slipped thru
> 
> I was away for a week anyways ;)
> 
> > Thinking about it again, I think we should coverge to two APIs and mark the
> > legacy depracuated and look to convert folks and phase that out
> 
> Currently, w/o this series we have these APIs:
> /* to be used with DT/ACPI */
> dma_request_slave_channel(dev, name)  /* NULL on failure */
> dma_request_slave_channel_reason(dev, name)   /* error code on failure */
> 
> /* Legacy mode only - no DT/ACPI lookup */
> dma_request_channel(mask, fn, fn_param) /* NULL on failure */
> 
> /* to be used with DT/ACPI or legacy boot */
> dma_request_slave_channel_compat(mask, fn, fn_param, dev, name)   /* NULL 
> on
> failure */
> 
> To request _any_ channel to be used for memcpy one has to use
> dma_request_channel(mask, NULL, NULL);
> 
> If I did not missed something.
I dont think so :)

> As we need different types of parameters for DT/ACPI and legacy (non DT/ACPI
> lookup) and the good API names are already taken, we might need to settle:
> 
> /* to be used with DT/ACPI */
> dma_request_slave_channel(dev, name) /* error code on failure */
> - Convert users to check IS_ERR_OR_NULL() instead against NULL
> - Mark dma_request_slave_channel_reason() deprecated and convert the current 
> users
> 
> /* to be used with DT/ACPI or legacy boot */
> dma_request_slave_channel_compat(mask, fn, fn_param, dev, name) /* error code
> on failure */
> - Convert users to check IS_ERR_OR_NULL() instead against NULL
> - Do not try legacy mode if either OF or ACPI failed because of real error
Should we keep the filter fn and an API for this, I am still not too sure
about that part. Anyway users should be on DT/ACPI. if someone wants filter
then let them use dma_request_channel()

> 
> /* Legacy mode only - no DT/ACPI lookup */
> dma_request_channel_legacy(mask, fn, fn_param) /* error code on failure */
> - convert users of dma_request_channel()
> - mark dma_request_channel() deprecated
Why should we create a new API, how about marking dma_request_channel() as
legacy and generic memcpy API and let other users be migrated?
> 
> /* to be used to get a channel for memcpy for example */
> dma_request_any_channel(mask) /* error code on failure */
> - Convert current dma_request_channel(mask, NULL, NULL) users
> I know, any of the other function could be prepared to handle this when
> parameters are missing, but it is a bit cleaner to have separate API for this.
Though it has merits but adds another API. We cna have internal
_dma_request_xxx API where parameters are missing and clean but to users
single API might be a better idea
> 
> It would be nice to find another name for the
> dma_request_slave_channel_compat() so with the new name we could have chance
> to rearrange the parameters: (dev, name, mask, fn, fn_param)
> 
> We would end up with the following APIs, all returning with error code on 
> failure:
> dma_request_slave_channel(dev, name);
> dma_request_channel_legacy(mask, fn, fn_param);
> dma_request_slave_channel_compat(mask, fn, fn_param, dev, name);
> dma_request_any_channel(mask);
This is good idea but still we end up with 4 APIs. Why not just converge to
two API, one legacy + memcpy + filer fn and one untimate API for slave?

Internally we may have 4 APIs for cleaner handling...

Thoughts... ??

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


[PATCH 11/12] [media] tsin: c8sectpfe: Add Kconfig and Makefile for the driver.

2015-06-24 Thread Peter Griffin
This patch adds the Kconfig and Makefile for the c8sectpfe driver
so it will be built. It also selects additional demodulator and tuners
which are required by the supported NIM cards.

Signed-off-by: Peter Griffin 
---
 drivers/media/Kconfig |  1 +
 drivers/media/Makefile|  1 +
 drivers/media/tsin/c8sectpfe/Kconfig  | 26 ++
 drivers/media/tsin/c8sectpfe/Makefile | 11 +++
 4 files changed, 39 insertions(+)
 create mode 100644 drivers/media/tsin/c8sectpfe/Kconfig
 create mode 100644 drivers/media/tsin/c8sectpfe/Makefile

diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 1570992..82bc1dc 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -170,6 +170,7 @@ source "drivers/media/pci/Kconfig"
 source "drivers/media/platform/Kconfig"
 source "drivers/media/mmc/Kconfig"
 source "drivers/media/radio/Kconfig"
+source "drivers/media/tsin/c8sectpfe/Kconfig"
 
 comment "Supported FireWire (IEEE 1394) Adapters"
depends on DVB_CORE && FIREWIRE
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index e608bbc..0a567b8 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -29,5 +29,6 @@ obj-y += rc/
 #
 
 obj-y += common/ platform/ pci/ usb/ mmc/ firewire/
+obj-$(CONFIG_DVB_C8SECTPFE) += tsin/c8sectpfe/
 obj-$(CONFIG_VIDEO_DEV) += radio/
 
diff --git a/drivers/media/tsin/c8sectpfe/Kconfig 
b/drivers/media/tsin/c8sectpfe/Kconfig
new file mode 100644
index 000..8d99a87
--- /dev/null
+++ b/drivers/media/tsin/c8sectpfe/Kconfig
@@ -0,0 +1,26 @@
+config DVB_C8SECTPFE
+   tristate "STMicroelectronics C8SECTPFE DVB support"
+   depends on DVB_CORE && I2C && (ARCH_STI || ARCH_MULTIPLATFORM)
+   select DVB_LNBP21 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV090x if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STB6100 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV6110 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV0900 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
+
+   ---help---
+ This adds support for DVB front-end cards connected
+ to TS inputs of STiH407/410 SoC.
+
+ The driver currently supports C8SECTPFE's TS input block,
+ memdma engine, and HW PID filtering.
+
+ Supported DVB front-end cards are:
+ - STMicroelectronics DVB-T B2100A (STV0367 + TDA18212)
+ - STMicroelectronics DVB-T STV0367 PLL board (STV0367 + DTT7546X)
+ - STMicroelectronics DVB-S/S2 STV0903 + STV6110 + LNBP24 board
+
+ To compile this driver as a module, choose M here: the
+ module will be called c8sectpfe.
diff --git a/drivers/media/tsin/c8sectpfe/Makefile 
b/drivers/media/tsin/c8sectpfe/Makefile
new file mode 100644
index 000..777f06d
--- /dev/null
+++ b/drivers/media/tsin/c8sectpfe/Makefile
@@ -0,0 +1,11 @@
+c8sectpfe-y += c8sectpfe-core.o c8sectpfe-common.o c8sectpfe-dvb.o
+
+obj-$(CONFIG_DVB_C8SECTPFE) += c8sectpfe.o
+
+ifneq ($(CONFIG_DVB_C8SECTPFE),)
+   c8sectpfe-y += c8sectpfe-debugfs.o
+endif
+
+ccflags-y += -Idrivers/media/i2c
+ccflags-y += -Idrivers/media/common
+ccflags-y += -Idrivers/media/dvb-core/ -Idrivers/media/dvb-frontends/ 
-Idrivers/media/tuners/
-- 
1.9.1

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


[PATCH 00/12] Add c8sectpfe LinuxDVB demux driver

2015-06-24 Thread Peter Griffin
Hi Maruro,

This patchset adds support for a LinuxDVB demux driver for the
ST STB stih407 family SoC's. It is what I spoke to you about
when we met at ELC-E in Dusseldorf last year.

One advantage of having a upstream demux driver implementation for ST
SoC's is that it will be easier to add support and maintain existing support
for the ST demodulators and tuners which are upstream. As this driver allows
ST NIM daughter boards (which typically have a tuner/demod combination)
to be used with a upstream kernel.

This initial patchset adds support for the following demux HW called c8sectpfe: 
-
* Input Block HW
* HW PID filtering
* memdma engine (moves TS from sram to RAM)

The driver creates one Linux DVB adapter, and each tsin channel which is
described in DT has a set of LDVB dev nodes.

Currently the driver supports 7 tsin channels. This driver has been tested with
the stih407-b2120 board and stih410-b2120 reference design boards, and currently
we support the following DVB fronend cards:
 - STMicroelectronics DVB-T B2100A (STV0367 + TDA18212)
 - STMicroelectronics DVB-T STV0367 PLL board (STV0367 + DTT7546X)
 - STMicroelectronics DVB-S/S2 STV0903 + STV6110 + LNBP24 board

There are also some small changes to dvb-pll.c and stv0367.c to get these
NIM daughterboards working correctly.

regards,

Peter.

p.s. The series which adds pinctrl config used by this driver is
https://lkml.org/lkml/2015/6/10/377

Peter Griffin (12):
  ARM: DT: STi: stihxxx-b2120: Add pulse-width properties to ssc2 & ssc3
  [media] dvb-pll: Add support for THOMSON DTT7546X tuner.
  [media] stv0367: Refine i2c error trace to include i2c address
  [media] stv0367: Add support for 16Mhz reference clock
  [media] tsin: c8sectpfe: Add DT bindings documentation for c8sectpfe
driver.
  ARM: DT: STi: STiH407: Add c8sectpfe LinuxDVB DT node.
  [media] tsin: c8sectpfe: STiH407/10 Linux DVB demux support
  [media] tsin: c8sectpfe: Add LDVB helper functions.
  [media] tsin: c8sectpfe: Add support for various ST NIM cards.
  [media] tsin: c8sectpfe: Add c8sectpfe debugfs support.
  [media] tsin: c8sectpfe: Add Kconfig and Makefile for the driver.
  MAINTAINERS: Add c8sectpfe driver directory to STi section

 .../bindings/media/stih407-c8sectpfe.txt   |   90 ++
 MAINTAINERS|1 +
 arch/arm/boot/dts/stihxxx-b2120.dtsi   |   60 +-
 drivers/media/Kconfig  |1 +
 drivers/media/Makefile |1 +
 drivers/media/dvb-frontends/dvb-pll.c  |   74 +-
 drivers/media/dvb-frontends/dvb-pll.h  |1 +
 drivers/media/dvb-frontends/stv0367.c  |   17 +-
 drivers/media/tsin/c8sectpfe/Kconfig   |   26 +
 drivers/media/tsin/c8sectpfe/Makefile  |   11 +
 drivers/media/tsin/c8sectpfe/c8sectpfe-common.c|  266 +
 drivers/media/tsin/c8sectpfe/c8sectpfe-common.h|   66 ++
 drivers/media/tsin/c8sectpfe/c8sectpfe-core.c  | 1105 
 drivers/media/tsin/c8sectpfe/c8sectpfe-core.h  |  288 +
 drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.c   |  271 +
 drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.h   |   26 +
 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c   |  296 ++
 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.h   |   20 +
 include/dt-bindings/media/c8sectpfe.h  |   14 +
 19 files changed, 2617 insertions(+), 17 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
 create mode 100644 drivers/media/tsin/c8sectpfe/Kconfig
 create mode 100644 drivers/media/tsin/c8sectpfe/Makefile
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-common.c
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-common.h
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-core.h
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.c
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.h
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.h
 create mode 100644 include/dt-bindings/media/c8sectpfe.h

-- 
1.9.1

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


[PATCH 06/12] ARM: DT: STi: STiH407: Add c8sectpfe LinuxDVB DT node.

2015-06-24 Thread Peter Griffin
This patch adds in the required DT node for the c8sectpfe
Linux DVB demux driver which allows the tsin channels
to be used on an upstream kernel.

Signed-off-by: Peter Griffin 
---
 arch/arm/boot/dts/stihxxx-b2120.dtsi | 50 
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/boot/dts/stihxxx-b2120.dtsi 
b/arch/arm/boot/dts/stihxxx-b2120.dtsi
index 1f27589..ece2ede 100644
--- a/arch/arm/boot/dts/stihxxx-b2120.dtsi
+++ b/arch/arm/boot/dts/stihxxx-b2120.dtsi
@@ -6,6 +6,10 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
+#include 
+#include 
+
 / {
soc {
sbc_serial0: serial@953 {
@@ -72,5 +76,51 @@
st,osc-force-ext;
};
};
+
+   c8sectpfe@08a2 {
+   compatible = "st,stih407-c8sectpfe";
+   status = "okay";
+   reg = <0x08a2 0x1>, <0x08a0 0x4000>;
+   reg-names = "c8sectpfe", "c8sectpfe-ram";
+
+   interrupts = <0 34 0>, <0 35 0>;
+   interrupt-names = "c8sectpfe-error-irq",
+ "c8sectpfe-idle-irq";
+
+   pinctrl-names   = "tsin0-serial", "tsin0-parallel",
+ "tsin3-serial", "tsin4-serial",
+ "tsin5-serial";
+
+   pinctrl-0   = <&pinctrl_tsin0_serial>;
+   pinctrl-1   = <&pinctrl_tsin0_parallel>;
+   pinctrl-2   = <&pinctrl_tsin3_serial>;
+   pinctrl-3   = <&pinctrl_tsin4_serial_alt3>;
+   pinctrl-4   = <&pinctrl_tsin5_serial_alt1>;
+
+   clocks = <&clk_s_c0_flexgen CLK_PROC_STFE>;
+   clock-names = "c8sectpfe";
+
+   /* tsin0 is TSA on NIMA */
+   tsin0: port@0 {
+
+   tsin-num = <0>;
+   serial-not-parallel;
+   i2c-bus = <&ssc2>;
+   rst-gpio = <&pio15 4 0>;
+
+   dvb-card = ;
+   };
+
+   /* tsin3 is TSB on NIMB */
+   tsin3: port@3 {
+
+   tsin-num = <3>;
+   serial-not-parallel;
+   i2c-bus = <&ssc3>;
+   rst-gpio = <&pio15 7 0>;
+
+   dvb-card = ;
+   };
+   };
};
 };
-- 
1.9.1

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


[PATCH 08/12] [media] tsin: c8sectpfe: Add LDVB helper functions.

2015-06-24 Thread Peter Griffin
These functions are used by the core code for creating the LDVB
devices and adapter.

Addtionally some older SoC's (and potentially newer ones) have different
frontend HW which would allow those devices to be easily supported
in the future by keeping the code specific to the IP separate from the
more generic code.

Signed-off-by: Peter Griffin 
---
 drivers/media/tsin/c8sectpfe/c8sectpfe-common.c | 266 
 drivers/media/tsin/c8sectpfe/c8sectpfe-common.h |  66 ++
 2 files changed, 332 insertions(+)
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-common.c
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-common.h

diff --git a/drivers/media/tsin/c8sectpfe/c8sectpfe-common.c 
b/drivers/media/tsin/c8sectpfe/c8sectpfe-common.c
new file mode 100644
index 000..c8d607d
--- /dev/null
+++ b/drivers/media/tsin/c8sectpfe/c8sectpfe-common.c
@@ -0,0 +1,266 @@
+/*
+ * c8sectpfe-common.c - C8SECTPFE STi DVB driver
+ *
+ * Copyright (c) STMicroelectronics 2015
+ *
+ *   Author: Peter Griffin 
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License as
+ *  published by the Free Software Foundation; either version 2 of
+ *  the License, or (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#include "c8sectpfe-common.h"
+#include "c8sectpfe-core.h"
+#include "c8sectpfe-dvb.h"
+
+static int register_dvb(struct stdemux *demux, struct dvb_adapter *adap,
+   void *start_feed, void *stop_feed,
+   struct c8sectpfei *fei)
+{
+   int result;
+
+   demux->dvb_demux.dmx.capabilities = DMX_TS_FILTERING |
+   DMX_SECTION_FILTERING |
+   DMX_MEMORY_BASED_FILTERING;
+
+   demux->dvb_demux.priv = demux;
+   demux->dvb_demux.filternum = C8SECTPFE_MAXCHANNEL;
+   demux->dvb_demux.feednum = C8SECTPFE_MAXCHANNEL;
+
+   demux->dvb_demux.start_feed = start_feed;
+   demux->dvb_demux.stop_feed = stop_feed;
+   demux->dvb_demux.write_to_decoder = NULL;
+
+   result = dvb_dmx_init(&demux->dvb_demux);
+   if (result < 0) {
+   dev_err(fei->dev, "dvb_dmx_init failed (errno = %d)\n",
+   result);
+   goto err_dmx;
+   }
+
+   demux->dmxdev.filternum = demux->dvb_demux.filternum;
+   demux->dmxdev.demux = &demux->dvb_demux.dmx;
+   demux->dmxdev.capabilities = 0;
+
+   result = dvb_dmxdev_init(&demux->dmxdev, adap);
+   if (result < 0) {
+   dev_err(fei->dev, "dvb_dmxdev_init failed (errno = %d)\n",
+   result);
+
+   goto err_dmxdev;
+   }
+
+   demux->hw_frontend.source = DMX_FRONTEND_0 + demux->tsin_index;
+
+   result = demux->dvb_demux.dmx.add_frontend(&demux->dvb_demux.dmx,
+   &demux->hw_frontend);
+   if (result < 0) {
+   dev_err(fei->dev, "add_frontend failed (errno = %d)\n", result);
+   goto err_fe_hw;
+   }
+
+   demux->mem_frontend.source = DMX_MEMORY_FE;
+   result = demux->dvb_demux.dmx.add_frontend(&demux->dvb_demux.dmx,
+   &demux->mem_frontend);
+   if (result < 0) {
+   dev_err(fei->dev, "add_frontend failed (%d)\n", result);
+   goto err_fe_mem;
+   }
+
+   result = demux->dvb_demux.dmx.connect_frontend(&demux->dvb_demux.dmx,
+   &demux->hw_frontend);
+   if (result < 0) {
+   dev_err(fei->dev, "connect_frontend (%d)\n", result);
+   goto err_fe_con;
+   }
+
+   return 0;
+
+err_fe_con:
+   demux->dvb_demux.dmx.remove_frontend(&demux->dvb_demux.dmx,
+&demux->mem_frontend);
+err_fe_mem:
+   demux->dvb_demux.dmx.remove_frontend(&demux->dvb_demux.dmx,
+&demux->hw_frontend);
+err_fe_hw:
+   dvb_dmxdev_release(&demux->dmxdev);
+err_dmxdev:
+   dvb_dmx_release(&demux->dvb_demux);
+err_dmx:
+   return result;
+
+}
+
+static void unregister_dvb(struct stdemux *demux)
+{
+
+   demux->dvb_demux.dmx.remove_frontend(&demux->dvb_demux.dmx,
+&demux->mem_frontend);
+
+   demux->dvb_demux.dmx.remove_frontend(&demux->dvb_demux.dmx,
+&demux->hw_frontend);
+
+   dvb_dmxdev_release(&demux->dmxdev);
+
+   dvb_dmx_release(&demux->dvb_demux);
+}
+
+static struct c8sectpfe *c8sectpfe_create(

[PATCH 10/12] [media] tsin: c8sectpfe: Add c8sectpfe debugfs support.

2015-06-24 Thread Peter Griffin
Some basic debugfs support to dump the IP registers. Further
statistics could easily be added in the future for example for
each enabled tsin channel we could expose number of corrupt packets
received etc.

Signed-off-by: Peter Griffin 
---
 drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.c | 271 +++
 drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.h |  26 +++
 2 files changed, 297 insertions(+)
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.c
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.h

diff --git a/drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.c 
b/drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.c
new file mode 100644
index 000..e9ba13d
--- /dev/null
+++ b/drivers/media/tsin/c8sectpfe/c8sectpfe-debugfs.c
@@ -0,0 +1,271 @@
+/*
+ * c8sectpfe-debugfs.c - C8SECTPFE STi DVB driver
+ *
+ * Copyright (c) STMicroelectronics 2015
+ *
+ * Author: Peter Griffin 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License 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 "c8sectpfe-debugfs.h"
+
+#define dump_register(nm ...)  \
+{  \
+   .name   = #nm,  \
+   .offset = nm,   \
+}
+
+static const struct debugfs_reg32 fei_sys_regs[] = {
+   dump_register(SYS_INPUT_ERR_STATUS),
+   dump_register(SYS_OTHER_ERR_STATUS),
+   dump_register(SYS_INPUT_ERR_MASK),
+   dump_register(SYS_DMA_ROUTE),
+   dump_register(SYS_INPUT_CLKEN),
+   dump_register(IBENABLE_MASK),
+   dump_register(SYS_OTHER_CLKEN),
+   dump_register(SYS_CFG_NUM_IB),
+   dump_register(SYS_CFG_NUM_MIB),
+   dump_register(SYS_CFG_NUM_SWTS),
+   dump_register(SYS_CFG_NUM_TSOUT),
+   dump_register(SYS_CFG_NUM_CCSC),
+   dump_register(SYS_CFG_NUM_RAM),
+   dump_register(SYS_CFG_NUM_TP),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(0)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(0)),
+   dump_register(C8SECTPFE_IB_PID_SET(0)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(0)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(0)),
+   dump_register(C8SECTPFE_IB_BUFF_END(0)),
+   dump_register(C8SECTPFE_IB_READ_PNT(0)),
+   dump_register(C8SECTPFE_IB_WRT_PNT(0)),
+   dump_register(C8SECTPFE_IB_PRI_THRLD(0)),
+   dump_register(C8SECTPFE_IB_STAT(0)),
+   dump_register(C8SECTPFE_IB_MASK(0)),
+   dump_register(C8SECTPFE_IB_SYS(0)),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(1)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(1)),
+   dump_register(C8SECTPFE_IB_PID_SET(1)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(1)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(1)),
+   dump_register(C8SECTPFE_IB_BUFF_END(1)),
+   dump_register(C8SECTPFE_IB_READ_PNT(1)),
+   dump_register(C8SECTPFE_IB_WRT_PNT(1)),
+   dump_register(C8SECTPFE_IB_PRI_THRLD(1)),
+   dump_register(C8SECTPFE_IB_STAT(1)),
+   dump_register(C8SECTPFE_IB_MASK(1)),
+   dump_register(C8SECTPFE_IB_SYS(1)),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(2)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(2)),
+   dump_register(C8SECTPFE_IB_PID_SET(2)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(2)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(2)),
+   dump_register(C8SECTPFE_IB_BUFF_END(2)),
+   dump_register(C8SECTPFE_IB_READ_PNT(2)),
+   dump_register(C8SECTPFE_IB_WRT_PNT(2)),
+   dump_register(C8SECTPFE_IB_PRI_THRLD(2)),
+   dump_register(C8SECTPFE_IB_STAT(2)),
+   dump_register(C8SECTPFE_IB_MASK(2)),
+   dump_register(C8SECTPFE_IB_SYS(2)),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(3)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(3)),
+   dump_register(C8SECTPFE_IB_PID_SET(3)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(3)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(3)),
+   dump_register(C8SECTPFE_IB_BUFF_END(3)),
+   dump_register(C8SECTPFE_IB_READ_PNT(3)),
+   dump_register(C8SECTPFE_IB_WRT_PNT(3)),
+   dump_register(C8SECTPFE_IB_PRI_THRLD(3)),
+   dump_register(C8SECTPFE_IB_STAT(3)),
+   dump_register(C8SECTPFE_IB_MASK(3)),
+   dump_register(C8SECTPFE_IB_SYS(3)),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(4)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(4)),
+   dump_register(C8SECTPFE_IB_PID_SET(4)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(4)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(4)),
+   dump_register(C8SECTPFE_IB_BUFF_END(4)),
+   dump_r

[PATCH 09/12] [media] tsin: c8sectpfe: Add support for various ST NIM cards.

2015-06-24 Thread Peter Griffin
This patch adds support for the following 3 NIM cards: -
1) STV0367-NIM (stv0367 demod with Thompson PLL)
2) B2100A (2x stv0367 demods & 2x NXP tda18212 tuners)
3) STV0903-6110NIM (stv0903 demod + 6110 tuner, lnb24)

Signed-off-by: Peter Griffin 
---
 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c | 296 +++
 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.h |  20 ++
 2 files changed, 316 insertions(+)
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.h

diff --git a/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c 
b/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
new file mode 100644
index 000..5c4ecb4
--- /dev/null
+++ b/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
@@ -0,0 +1,296 @@
+/*
+ *  c8sectpfe-dvb.c - C8SECTPFE STi DVB driver
+ *
+ * Copyright (c) STMicroelectronics 2015
+ *
+ *  Author Peter Griffin 
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  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 "c8sectpfe-common.h"
+#include "c8sectpfe-core.h"
+#include "c8sectpfe-dvb.h"
+
+#include "dvb-pll.h"
+#include "lnbh24.h"
+#include "stv0367.h"
+#include "stv0367_priv.h"
+#include "stv6110x.h"
+#include "stv090x.h"
+#include "tda18212.h"
+
+static inline const char *dvb_card_str(unsigned int c)
+{
+   switch (c) {
+   case STV0367_PLL_BOARD_NIMA:return "STV0367_PLL_BOARD_NIMA";
+   case STV0367_PLL_BOARD_NIMB:return "STV0367_PLL_BOARD_NIMB";
+   case STV0367_TDA18212_NIMA_1:   return "STV0367_TDA18212_NIMA_1";
+   case STV0367_TDA18212_NIMA_2:   return "STV0367_TDA18212_NIMA_2";
+   case STV0367_TDA18212_NIMB_1:   return "STV0367_TDA18212_NIMB_1";
+   case STV0367_TDA18212_NIMB_2:   return "STV0367_TDA18212_NIMB_2";
+   case STV0903_6110_LNB24_NIMA:   return "STV0903_6110_LNB24_NIMA";
+   case STV0903_6110_LNB24_NIMB:   return "STV0903_6110_LNB24_NIMB";
+   default:return "unknown dvb frontend card";
+   }
+}
+
+static struct stv090x_config stv090x_config = {
+   .device = STV0903,
+   .demod_mode = STV090x_SINGLE,
+   .clk_mode   = STV090x_CLK_EXT,
+   .xtal   = 1600,
+   .address= 0x69,
+
+   .ts1_mode   = STV090x_TSMODE_SERIAL_CONTINUOUS,
+   .ts2_mode   = STV090x_TSMODE_SERIAL_CONTINUOUS,
+
+   .repeater_level = STV090x_RPTLEVEL_64,
+
+   .tuner_init = NULL,
+   .tuner_set_mode = NULL,
+   .tuner_set_frequency= NULL,
+   .tuner_get_frequency= NULL,
+   .tuner_set_bandwidth= NULL,
+   .tuner_get_bandwidth= NULL,
+   .tuner_set_bbgain   = NULL,
+   .tuner_get_bbgain   = NULL,
+   .tuner_set_refclk   = NULL,
+   .tuner_get_status   = NULL,
+};
+
+static struct stv6110x_config stv6110x_config = {
+   .addr   = 0x60,
+   .refclk = 1600,
+};
+
+#define NIMA 0
+#define NIMB 1
+
+static struct stv0367_config stv0367_pll_config[] = {
+   {
+   .demod_address = 0x1c,
+   .xtal = 2700,
+   .if_khz = 36166,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   }, {
+   .demod_address = 0x1d,
+   .xtal = 2700,
+   .if_khz = 36166,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   },
+};
+
+static struct stv0367_config stv0367_tda18212_config[] = {
+   {
+   .demod_address = 0x1c,
+   .xtal = 1600,
+   .if_khz = 4500,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   }, {
+   .demod_address = 0x1d,
+   .xtal = 1600,
+   .if_khz = 4500,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   }, {
+   .demod_address = 0x1e,
+   .xtal = 1600,
+   .if_khz = 4500,
+   .if_iq_mode =

[PATCH 07/12] [media] tsin: c8sectpfe: STiH407/10 Linux DVB demux support

2015-06-24 Thread Peter Griffin
This patch adds support for the c8sectpfe input HW found on
STiH407/410 SoC's.

It currently supports the TS input block, memdma engine
and hw PID filtering blocks of the C8SECTPFE subsystem.

The driver creates one LinuxDVB adapter, and a
demux/dvr/frontend set of devices for each tsin channel
which is specificed in the DT. It has been tested with
multiple tsin channels tuned, locked, and grabbing TS
simultaneously.

Signed-off-by: Peter Griffin 
---
 drivers/media/tsin/c8sectpfe/c8sectpfe-core.c | 1105 +
 drivers/media/tsin/c8sectpfe/c8sectpfe-core.h |  288 +++
 2 files changed, 1393 insertions(+)
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
 create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-core.h

diff --git a/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c 
b/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
new file mode 100644
index 000..fbbe323
--- /dev/null
+++ b/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
@@ -0,0 +1,1105 @@
+/*
+ * c8sectpfe-core.c - C8SECTPFE STi DVB driver
+ *
+ * Copyright (c) STMicroelectronics 2015
+ *
+ *   Author:Peter Bennett 
+ * Peter Griffin 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "c8sectpfe-core.h"
+#include "c8sectpfe-common.h"
+#include "c8sectpfe-debugfs.h"
+#include "dmxdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "dvb_net.h"
+
+#define FIRMWARE_MEMDMA "pti_memdma_h407.elf"
+MODULE_FIRMWARE(FIRMWARE_MEMDMA);
+
+#define PID_TABLE_SIZE 1024
+#define POLL_20_HZ_DIV 20 /* poll at 20 Hz */
+
+static int load_slim_core_fw(struct c8sectpfei *fei);
+
+#define TS_PKT_SIZE 188
+#define HEADER_SIZE (4)
+#define PACKET_SIZE (TS_PKT_SIZE+HEADER_SIZE)
+
+#define FEI_ALIGNMENT (32)
+/* hw requires minimum of 8*PACKET_SIZE and padded to 8byte boundary */
+#define FEI_BUFFER_SIZE (8*PACKET_SIZE*340)
+
+#define FIFO_LEN 1024
+
+static void c8sectpfe_timer_interrupt(unsigned long ac8sectpfei)
+{
+   struct c8sectpfei *fei = (struct c8sectpfei *)ac8sectpfei;
+   struct channel_info *channel;
+   int chan_num;
+
+   /* iterate through input block channels */
+   for (chan_num = 0; chan_num < fei->tsin_count; chan_num++) {
+   channel = fei->channel_data[chan_num];
+
+   /* is this descriptor initialised and TP enabled */
+   if (channel->irec && readl((void __iomem *)
+   &channel->irec->tp_enable))
+   tasklet_schedule(&channel->tsklet);
+   }
+
+   fei->timer.expires = jiffies + (HZ / POLL_20_HZ_DIV);
+   add_timer(&fei->timer);
+}
+
+static void channel_swdemux_tsklet(unsigned long data)
+{
+   struct channel_info *channel = (struct channel_info *)data;
+   struct c8sectpfei *fei = channel->fei;
+   struct tpentry *ptrblk;
+   unsigned long wp, rp;
+   int pos, num_packets, n, size;
+   u8 *buf;
+
+   BUG_ON(!channel);
+   BUG_ON(!channel->irec);
+
+   ptrblk = &channel->irec->ptr_data[0];
+
+   wp = readl((void __iomem *)&ptrblk->dma_bus_wp);
+   rp = readl((void __iomem *)&ptrblk->dma_bus_rp);
+
+   pos = rp - channel->back_buffer_busaddr;
+
+   /* has it wrapped */
+   if (wp < rp)
+   wp = channel->back_buffer_busaddr + FEI_BUFFER_SIZE;
+
+   size = wp - rp;
+   num_packets = size / PACKET_SIZE;
+
+   /* manage cache so data is visible to CPU */
+   dma_sync_single_for_cpu(fei->dev,
+   rp,
+   size,
+   DMA_FROM_DEVICE);
+
+   buf = (u8 *) channel->back_buffer_aligned;
+
+   dev_dbg(fei->dev,
+   "chan=%d channel=%p num_packets = %d, buf = %p, pos = 0x%x\n\t"
+   "rp=0x%lx, wp=0x%lx\n",
+   channel->tsin_id, channel, num_packets, buf, pos, rp, wp);
+
+   for (n = 0; n < num_packets; n++) {
+   dvb_dmx_swfilter_packets(
+   &fei->c8sectpfe[0]->
+   demux[channel->demux_mapping].dvb_demux,
+   &buf[pos], 1);
+
+   pos += PACKET_SIZE;
+   }
+
+   /* advance the read pointer */
+   if (wp == (channel->back_buffer_busaddr + FEI_BUFFER_SIZE))
+   writel(channel->back_buffer_busaddr,
+   (void __iomem *)&ptrblk->dma_bus_rp);
+   else
+   writel(wp, (void __iomem *)&ptrblk->dma_bus_rp);
+}
+
+static int c8sectpfe_start_feed(struct d

[PATCH 02/12] [media] dvb-pll: Add support for THOMSON DTT7546X tuner.

2015-06-24 Thread Peter Griffin
This is used in conjunction with the STV0367 demodulator on
the STV0367-NIM-V1.0 NIM card which can be used with the STi
STB SoC's.

This tuner has a fifth register, so some changes have been made
to accommodate this.

Signed-off-by: Peter Griffin 
---
 drivers/media/dvb-frontends/dvb-pll.c | 74 +--
 drivers/media/dvb-frontends/dvb-pll.h |  1 +
 2 files changed, 64 insertions(+), 11 deletions(-)

diff --git a/drivers/media/dvb-frontends/dvb-pll.c 
b/drivers/media/dvb-frontends/dvb-pll.c
index 6d8fe88..f7381c7 100644
--- a/drivers/media/dvb-frontends/dvb-pll.c
+++ b/drivers/media/dvb-frontends/dvb-pll.c
@@ -141,6 +141,35 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
},
 };
 
+static void thomson_dtt7546x_bw(struct dvb_frontend *fe, u8 *buf)
+{
+   /* set CB2 reg - set ATC, XTO */
+   buf[4] = 0xc3;
+}
+
+static struct dvb_pll_desc dvb_pll_thomson_dtt7546x = {
+   .name  = "Thomson dtt7546x",
+   .min   = 4425,
+   .max   = 86325,
+   .set   = thomson_dtt7546x_bw,
+   .iffreq= 3617,
+   .count = 12,
+   .entries = {
+   {  12100, 17, 0x88, 0x01 },
+   {  14100, 17, 0x88, 0x41 },
+   {  16600, 17, 0x88, 0x81 },
+   {  18200, 17, 0x88, 0xc1 },
+   {  28600, 17, 0x88, 0x02 },
+   {  38600, 17, 0x88, 0x42 },
+   {  44600, 17, 0x88, 0x82 },
+   {  46600, 17, 0x88, 0xc2 },
+   {  50600, 17, 0x88, 0x08 },
+   {  76100, 17, 0x88, 0x48 },
+   {  84600, 17, 0x88, 0x88 },
+   {  90500, 17, 0x88, 0xc8 },
+   },
+};
+
 static struct dvb_pll_desc dvb_pll_lg_z201 = {
.name  = "LG z201",
.min   = 17400,
@@ -537,6 +566,7 @@ static struct dvb_pll_desc dvb_pll_alps_tdee4 = {
 static struct dvb_pll_desc *pll_list[] = {
[DVB_PLL_UNDEFINED]  = NULL,
[DVB_PLL_THOMSON_DTT7579]= &dvb_pll_thomson_dtt7579,
+   [DVB_PLL_THOMSON_DTT7546X]   = &dvb_pll_thomson_dtt7546x,
[DVB_PLL_THOMSON_DTT759X]= &dvb_pll_thomson_dtt759x,
[DVB_PLL_THOMSON_DTT7520X]   = &dvb_pll_thomson_dtt7520x,
[DVB_PLL_LG_Z201]= &dvb_pll_lg_z201,
@@ -561,7 +591,7 @@ static struct dvb_pll_desc *pll_list[] = {
 /* code*/
 
 static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
-const u32 frequency)
+   const u32 frequency, const u32 len)
 {
struct dvb_pll_priv *priv = fe->tuner_priv;
struct dvb_pll_desc *desc = priv->pll_desc;
@@ -593,11 +623,15 @@ static int dvb_pll_configure(struct dvb_frontend *fe, u8 
*buf,
if (desc->set)
desc->set(fe, buf);
 
-   if (debug)
-   printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
-  desc->name, div, buf[0], buf[1], buf[2], buf[3]);
+   if (debug) {
+   printk(KERN_DEBUG "pll: %s: div=%d | buf=", desc->name, div);
+   for (i = 0; i < len; i++)
+   printk(KERN_DEBUG "0x%02x,", buf[i]);
 
-   // calculate the frequency we set it to
+   printk(KERN_DEBUG "\n");
+   }
+
+   /* calculate the frequency we set it to */
return (div * desc->entries[i].stepsize) - desc->iffreq;
 }
 
@@ -634,21 +668,39 @@ static int dvb_pll_sleep(struct dvb_frontend *fe)
return -EINVAL;
 }
 
+static int dvb_pll_get_num_regs(struct dvb_pll_priv *priv)
+{
+   int num_regs = 4;
+
+   if (strncmp(priv->pll_desc->name, "Thomson dtt7546x", 16) == 0)
+   num_regs = 5;
+
+   return num_regs;
+}
+
 static int dvb_pll_set_params(struct dvb_frontend *fe)
 {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct dvb_pll_priv *priv = fe->tuner_priv;
-   u8 buf[4];
-   struct i2c_msg msg =
-   { .addr = priv->pll_i2c_address, .flags = 0,
- .buf = buf, .len = sizeof(buf) };
+   struct i2c_msg msg;
+   u8 *bufp;
int result;
u32 frequency = 0;
 
+   bufp = kzalloc(dvb_pll_get_num_regs(priv), GFP_KERNEL);
+
+   if (!bufp)
+   return -ENOMEM;
+
+   msg.addr = priv->pll_i2c_address;
+   msg.flags = 0;
+   msg.buf = bufp;
+   msg.len = dvb_pll_get_num_regs(priv);
+
if (priv->i2c == NULL)
return -EINVAL;
 
-   result = dvb_pll_configure(fe, buf, c->frequency);
+   result = dvb_pll_configure(fe, bufp, c->frequency, msg.len);
if (result < 0)
return result;
else
@@ -677,7 +729,7 @@ static int dvb_pll_calc_regs(struct dvb_frontend *fe,
if (buf_len < 5)
return -EINVAL;
 
-   result = dvb_pll_configure(fe, buf + 1, c->f

[PATCH 12/12] MAINTAINERS: Add c8sectpfe driver directory to STi section

2015-06-24 Thread Peter Griffin
Add the new c8sectpfe demux driver to the STi section of the
MAINTAINERS file.

Signed-off-by: Peter Griffin 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d8afd29..49c8963 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1481,6 +1481,7 @@ F:arch/arm/boot/dts/sti*
 F: drivers/clocksource/arm_global_timer.c
 F: drivers/i2c/busses/i2c-st.c
 F: drivers/media/rc/st_rc.c
+F: drivers/media/tsin/c8sectpfe/
 F: drivers/mmc/host/sdhci-st.c
 F: drivers/phy/phy-miphy28lp.c
 F: drivers/phy/phy-miphy365x.c
-- 
1.9.1

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


[PATCH 04/12] [media] stv0367: Add support for 16Mhz reference clock

2015-06-24 Thread Peter Griffin
The B2100A dvb NIM card from ST has 2x stv0367 demodulators
and 2x TDA18212 silicon tuners, with a 16Mhz crystal. To
get this working properly with the upstream driver we need
to add support for the 16Mhz reference clock.

Signed-off-by: Peter Griffin 
---
 drivers/media/dvb-frontends/stv0367.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index c3b7e6c..ad7cab7 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -1554,6 +1554,11 @@ static int stv0367ter_init(struct dvb_frontend *fe)
 
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);
-- 
1.9.1

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


[PATCH 03/12] [media] stv0367: Refine i2c error trace to include i2c address

2015-06-24 Thread Peter Griffin
When using stv0367 demodulator with STi STB platforms,
we can have easily have four or more stv0367 demods running
in the system at one time.

As typically the b2120 reference design ships with a b2004a daughter
board, which can accept two dvb NIM cards, and each b2100A NIM
has 2x stv0367 demods and 2x NXPs tuner on it.

In such circumstances it is useful to print the i2c address
on error messages to know which one is failing due to I2C issues.

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

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index b31ff26..c3b7e6c 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -791,11 +791,13 @@ int stv0367_writeregs(struct stv0367_state *state, u16 
reg, u8 *data, int len)
memcpy(buf + 2, data, len);
 
if (i2cdebug)
-   printk(KERN_DEBUG "%s: %02x: %02x\n", __func__, reg, buf[2]);
+   printk(KERN_DEBUG "%s: [%02x] %02x: %02x\n", __func__,
+   state->config->demod_address, reg, buf[2]);
 
ret = i2c_transfer(state->i2c, &msg, 1);
if (ret != 1)
-   printk(KERN_ERR "%s: i2c write error!\n", __func__);
+   printk(KERN_ERR "%s: i2c write error! ([%02x] %02x: %02x)\n",
+   __func__, state->config->demod_address, reg, buf[2]);
 
return (ret != 1) ? -EREMOTEIO : 0;
 }
@@ -829,10 +831,12 @@ static u8 stv0367_readreg(struct stv0367_state *state, 
u16 reg)
 
ret = i2c_transfer(state->i2c, msg, 2);
if (ret != 2)
-   printk(KERN_ERR "%s: i2c read error\n", __func__);
+   printk(KERN_ERR "%s: i2c read error ([%02x] %02x: %02x)\n",
+   __func__, state->config->demod_address, reg, b1[0]);
 
if (i2cdebug)
-   printk(KERN_DEBUG "%s: %02x: %02x\n", __func__, reg, b1[0]);
+   printk(KERN_DEBUG "%s: [%02x] %02x: %02x\n", __func__,
+   state->config->demod_address, reg, b1[0]);
 
return b1[0];
 }
-- 
1.9.1

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


[PATCH 05/12] [media] tsin: c8sectpfe: Add DT bindings documentation for c8sectpfe driver.

2015-06-24 Thread Peter Griffin
This patch adds the DT bindings documentation for the c8sectpfe LinuxDVB
demux driver whose IP is in the STiH407 family silicon SoC's.

Signed-off-by: Peter Griffin 
---
 .../bindings/media/stih407-c8sectpfe.txt   | 90 ++
 include/dt-bindings/media/c8sectpfe.h  | 14 
 2 files changed, 104 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
 create mode 100644 include/dt-bindings/media/c8sectpfe.h

diff --git a/Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt 
b/Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
new file mode 100644
index 000..1ed4b12
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
@@ -0,0 +1,90 @@
+STMicroelectronics STi c8sectpfe binding
+
+
+This document describes the c8sectpfe device bindings that is used to get 
transport
+stream data into the SoC on the TS pins, and into DDR for further processing.
+
+It is typically used in conjunction with one or more demodulator and tuner 
devices
+which converts from the RF to digital domain. Demodulators and tuners are 
usually
+located on an external DVB frontend card connected to SoC TS input pins.
+
+Currently 7 TS input (tsin) channels are supported on the stih407 family SoC.
+
+Required properties (controller (parent) node):
+- compatible   : Should be "stih407-c8sectpfe"
+
+- reg  : Address and length of register sets for each device in
+ "reg-names"
+
+- reg-names: The names of the register addresses corresponding to the
+ registers filled in "reg":
+   - c8sectpfe: c8sectpfe registers
+   - c8sectpfe-ram: c8sectpfe internal sram
+
+- clocks   : phandle list of c8sectpfe clocks
+- clock-names  : should be "c8sectpfe"
+See: Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+- pinctrl-names: a pinctrl state named tsin%d-serial or 
tsin%d-parallel (where %d is tsin-num)
+  must be defined for each tsin child node.
+- pinctrl-0: phandle referencing pin configuration for this tsin 
configuration
+See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
+
+
+Required properties (tsin (child) node):
+
+- tsin-num : tsin id of the InputBlock (must be between 0 to 6)
+- i2c-bus  : phandle to the I2C bus DT node which the demodulators & 
tuners on this tsin channel are connected.
+- rst-gpio : reset gpio for this tsin channel.
+
+Optional properties (tsin (child) node):
+
+- invert-ts-clk: Bool property to control sense of ts input 
clock (data stored on falling edge of clk).
+- serial-not-parallel  : Bool property to configure input bus width (serial on 
ts_data<7>).
+- async-not-sync   : Bool property to control if data is received in 
asynchronous mode
+  (all bits/bytes with ts_valid or ts_packet asserted 
are valid).
+
+- dvb-card : Describes the NIM card connected to this tsin channel.
+
+Example:
+
+/* stih410 SoC b2120 + b2004a + stv0367-pll(NIMB) + stv0367-tda18212 (NIMA) DT 
example) */
+
+   c8sectpfe@08a2 {
+   compatible = "st,stih407-c8sectpfe";
+   status = "okay";
+   reg = <0x08a2 0x1>, <0x08a0 0x4000>;
+   reg-names = "stfe", "stfe-ram";
+   interrupts = <0 34 0>, <0 35 0>;
+   interrupt-names = "stfe-error-irq", "stfe-idle-irq";
+
+   pinctrl-names   = "tsin0-serial", "tsin0-parallel", 
"tsin3-serial",
+   "tsin4-serial", "tsin5-serial";
+
+   pinctrl-0   = <&pinctrl_tsin0_serial>;
+   pinctrl-1   = <&pinctrl_tsin0_parallel>;
+   pinctrl-2   = <&pinctrl_tsin3_serial>;
+   pinctrl-3   = <&pinctrl_tsin4_serial_alt3>;
+   pinctrl-4   = <&pinctrl_tsin5_serial_alt1>;
+
+   clocks = <&clk_s_c0_flexgen CLK_PROC_STFE>;
+   clock-names = "stfe";
+
+   /* tsin0 is TSA on NIMA */
+   tsin0: port@0 {
+   tsin-num= <0>;
+   serial-not-parallel;
+   i2c-bus = <&ssc2>;
+   rst-gpio= <&pio15 4 0>;
+   dvb-card= ;
+   };
+
+   /* tsin3 is TSB on NIMB */
+   tsin3: port@3 {
+   tsin-num= <3>;
+   serial-not-parallel;
+   i2c-bus = <&ssc3>;
+   rst-gpio= <&pio15 7 0>;
+   dvb-card= ;
+   };
+   };
diff --git a/include/dt-bindings/media/c8sectpfe.h 
b/include/dt-bindings/media/c8sectpfe.h
new file mode 100644
index 000..45ad0

[PATCH 01/12] ARM: DT: STi: stihxxx-b2120: Add pulse-width properties to ssc2 & ssc3

2015-06-24 Thread Peter Griffin
Adding these properties makes the I2C bus to the demodulators much
more reliable, and we no longer suffer from I2C errors when tuning.

Signed-off-by: Peter Griffin 
---
 arch/arm/boot/dts/stihxxx-b2120.dtsi | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/stihxxx-b2120.dtsi 
b/arch/arm/boot/dts/stihxxx-b2120.dtsi
index c1d8590..1f27589 100644
--- a/arch/arm/boot/dts/stihxxx-b2120.dtsi
+++ b/arch/arm/boot/dts/stihxxx-b2120.dtsi
@@ -27,12 +27,18 @@
};
};
 
-   i2c@9842000 {
+   ssc2: i2c@9842000 {
status = "okay";
+   clock-frequency = <10>;
+   st,i2c-min-scl-pulse-width-us = <0>;
+   st,i2c-min-sda-pulse-width-us = <5>;
};
 
-   i2c@9843000 {
+   ssc3: i2c@9843000 {
status = "okay";
+   clock-frequency = <10>;
+   st,i2c-min-scl-pulse-width-us = <0>;
+   st,i2c-min-sda-pulse-width-us = <5>;
};
 
i2c@9844000 {
-- 
1.9.1

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


[patch] [media] v4l: xilinx: missing error code

2015-06-24 Thread Dan Carpenter
We should set "ret" on this error path instead of returning success.

Fixes: df3305156f98 ('[media] v4l: xilinx: Add Xilinx Video IP core')
Signed-off-by: Dan Carpenter 

diff --git a/drivers/media/platform/xilinx/xilinx-dma.c 
b/drivers/media/platform/xilinx/xilinx-dma.c
index 98e50e4..e779c93 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -699,8 +699,10 @@ int xvip_dma_init(struct xvip_composite_device *xdev, 
struct xvip_dma *dma,
 
/* ... and the buffers queue... */
dma->alloc_ctx = vb2_dma_contig_init_ctx(dma->xdev->dev);
-   if (IS_ERR(dma->alloc_ctx))
+   if (IS_ERR(dma->alloc_ctx)) {
+   ret = PTR_ERR(dma->alloc_ctx);
goto error;
+   }
 
/* Don't enable VB2_READ and VB2_WRITE, as using the read() and write()
 * V4L2 APIs would be inefficient. Testing on the command line with a
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH v2 0/2] utils/v4l2-ctl/v4l2-ctl-modes.cpp

2015-06-24 Thread Prashant Laddha
Posting v2 again.

Change compared to v1:
Updated function description that was missed in v1

Prashant Laddha (2):
  v4l2-utils: add support for reduced fps in cvt modeline
  v4l2-utils: extend set-dv-timings to support reduced fps

 utils/v4l2-ctl/v4l2-ctl-modes.cpp |  7 ++-
 utils/v4l2-ctl/v4l2-ctl-stds.cpp  | 14 --
 utils/v4l2-ctl/v4l2-ctl.h |  3 ++-
 3 files changed, 20 insertions(+), 4 deletions(-)

-- 
1.9.1

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


[RFC PATCH v2 2/2] v4l2-utils: extend set-dv-timings to support reduced fps

2015-06-24 Thread Prashant Laddha
Extended command line option for set-dv-timings to support timings
calculations for reduced fps. This will allow supporting NTSC frame
rates like 29.97 or 59.94.

Cc: Hans Verkuil 
Signed-off-by: Prashant Laddha 
---
 utils/v4l2-ctl/v4l2-ctl-stds.cpp | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
index e969d08..3987ba1 100644
--- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
@@ -41,11 +41,15 @@ void stds_usage(void)
   " index=: use the index as provided 
by --list-dv-timings\n"
   " or specify timings using cvt/gtf options 
as follows:\n"
   " 
cvt/gtf,width=,height=,fps=\n"
-  " 
interlaced=<0/1>,reduced-blanking=<0/1/2>\n"
+  " 
interlaced=<0/1>,reduced-blanking=<0/1/2>,reduced-fps=<0/1>\n"
   " The value of reduced-blanking, if greater 
than 0, indicates\n"
   " that reduced blanking is to be used and 
the value indicate the\n"
   " version. For gtf, there is no version 2 
for reduced blanking, and\n"
   " the value 1 or 2 will give same results.\n"
+  " reduced-fps = 1, slows down pixel clock by 
factor of 1000 / 1001, allowing\n"
+  " to support NTSC frame rates like 29.97 or 
59.94.\n"
+  " Reduced fps flag takes effect only with 
reduced blanking version 2 and,\n"
+  " when refresh rate is an integer multiple 
of 6, say, fps = 24,30,60 etc.\n"
   " or give a fully specified timings:\n"
   " 
width=,height=,interlaced=<0/1>,\n"
   " polarities=,pixelclock=,\n"
@@ -152,6 +156,7 @@ enum timing_opts {
GTF,
FPS,
REDUCED_BLANK,
+   REDUCED_FPS,
 };
 
 static int parse_timing_subopt(char **subopt_str, int *value)
@@ -179,6 +184,7 @@ static int parse_timing_subopt(char **subopt_str, int 
*value)
"gtf",
"fps",
"reduced-blanking",
+   "reduced-fps",
NULL
};
 
@@ -209,6 +215,7 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
int fps = 0;
int r_blank = 0;
int interlaced = 0;
+   bool reduced_fps = false;
bool timings_valid = false;
 
char *subopt_str = subopt;
@@ -234,6 +241,9 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
case INTERLACED:
interlaced = opt_val;
break;
+   case REDUCED_FPS:
+   reduced_fps = (opt_val == 1) ? true : false;
+   break;
default:
break;
}
@@ -241,7 +251,7 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
 
if (standard == V4L2_DV_BT_STD_CVT) {
timings_valid = calc_cvt_modeline(width, height, fps, r_blank,
- interlaced == 1 ? true : 
false, false, bt);
+ interlaced == 1 ? true : 
false, reduced_fps, bt);
} else {
timings_valid = calc_gtf_modeline(width, height, fps, r_blank,
  interlaced == 1 ? true : 
false, bt);
-- 
1.9.1

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


[RFC PATCH v2 1/2] v4l2-utils: add support for reduced fps in cvt modeline

2015-06-24 Thread Prashant Laddha
Added reduced fps option in cvt timings calculation. In this case,
pixel clock is slowed down by a factor of 1000 / 1001 and all other
timing parameters are unchanged. With reduced fps option one could
generate timings for refresh rates like 29.97 or 59.94. Pixel clock
in this case needs better precision, in the order of 0.001 Khz and
hence reduced fps option can be supported only when reduced blanking
V2 is enabled. Reduced fps is applicable only to nominal refresh
rates which are integer multiple of 6, say 24, 30, 60 etc.

Cc: Hans Verkuil 
Signed-off-by: Prashant Laddha 
---
 utils/v4l2-ctl/v4l2-ctl-modes.cpp | 7 ++-
 utils/v4l2-ctl/v4l2-ctl-stds.cpp  | 2 +-
 utils/v4l2-ctl/v4l2-ctl.h | 3 ++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-modes.cpp 
b/utils/v4l2-ctl/v4l2-ctl-modes.cpp
index 88f7b6a..9439b51 100644
--- a/utils/v4l2-ctl/v4l2-ctl-modes.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-modes.cpp
@@ -122,6 +122,7 @@ static int v_sync_from_aspect_ratio(int width, int height)
  * @reduced_blanking: This value, if greater than 0, indicates that
  * reduced blanking is to be used and value indicates the version.
  * @interlaced: whether to compute an interlaced mode
+ * @reduced_fps: reduce fps by factor of 1000 / 1001
  * @cvt: stores results of cvt timing calculation
  *
  * Returns:
@@ -131,7 +132,8 @@ static int v_sync_from_aspect_ratio(int width, int height)
 
 bool calc_cvt_modeline(int image_width, int image_height,
   int refresh_rate, int reduced_blanking,
-  bool interlaced, struct v4l2_bt_timings *cvt)
+  bool interlaced, bool reduced_fps,
+  struct v4l2_bt_timings *cvt)
 {
int h_sync;
int v_sync;
@@ -295,6 +297,9 @@ bool calc_cvt_modeline(int image_width, int image_height,
 
pixel_clock = v_refresh * total_h_pixel *
  (2 * total_v_lines + interlace) / 2;
+   if (reduced_fps && v_refresh % 6 == 0)
+   pixel_clock = ((long long)pixel_clock * 1000) / 1001;
+
pixel_clock -= pixel_clock  % clk_gran;
}
 
diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
index aea46c9..e969d08 100644
--- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
@@ -241,7 +241,7 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
 
if (standard == V4L2_DV_BT_STD_CVT) {
timings_valid = calc_cvt_modeline(width, height, fps, r_blank,
- interlaced == 1 ? true : 
false, bt);
+ interlaced == 1 ? true : 
false, false, bt);
} else {
timings_valid = calc_gtf_modeline(width, height, fps, r_blank,
  interlaced == 1 ? true : 
false, bt);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index de65900..113f348 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -351,7 +351,8 @@ void edid_get(int fd);
 /* v4l2-ctl-modes.cpp */
 bool calc_cvt_modeline(int image_width, int image_height,
   int refresh_rate, int reduced_blanking,
-  bool interlaced, struct v4l2_bt_timings *cvt);
+  bool interlaced, bool reduced_fps,
+  struct v4l2_bt_timings *cvt);
 
 bool calc_gtf_modeline(int image_width, int image_height,
   int refresh_rate, int reduced_blanking,
-- 
1.9.1

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


Re: [RFC PATCH v2 0/2] Support for reduced fps in v4l2-utils

2015-06-24 Thread Prashant Laddha (prladdha)
Please ignore v2 patches. By mistake I posted v1 again.

On 24/06/15 7:22 pm, "Prashant Laddha (prladdha)" 
wrote:

>Change compared to v1:
>Updated function description that was missed in v1.
>
>Prashant Laddha (2):
>  v4l2-utils: add support for reduced fps in cvt modeline
>  v4l2-utils: extend set-dv-timings to support reduced fps
>
> utils/v4l2-ctl/v4l2-ctl-modes.cpp |  6 +-
> utils/v4l2-ctl/v4l2-ctl-stds.cpp  | 14 --
> utils/v4l2-ctl/v4l2-ctl.h |  3 ++-
> 3 files changed, 19 insertions(+), 4 deletions(-)
>
>-- 
>1.9.1
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-media" in
>the body of a message to majord...@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


[RFC PATCH v2 0/2] Support for reduced fps in v4l2-utils

2015-06-24 Thread Prashant Laddha
Change compared to v1:
Updated function description that was missed in v1.

Prashant Laddha (2):
  v4l2-utils: add support for reduced fps in cvt modeline
  v4l2-utils: extend set-dv-timings to support reduced fps

 utils/v4l2-ctl/v4l2-ctl-modes.cpp |  6 +-
 utils/v4l2-ctl/v4l2-ctl-stds.cpp  | 14 --
 utils/v4l2-ctl/v4l2-ctl.h |  3 ++-
 3 files changed, 19 insertions(+), 4 deletions(-)

-- 
1.9.1

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


[RFC PATCH v2 2/2] v4l2-utils: extend set-dv-timings to support reduced fps

2015-06-24 Thread Prashant Laddha
Extended command line option for set-dv-timings to support timings
calculations for reduced fps. This will allow supporting NTSC frame
rates like 29.97 or 59.94.

Cc: Hans Verkuil 
Signed-off-by: Prashant Laddha 
---
 utils/v4l2-ctl/v4l2-ctl-stds.cpp | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
index e969d08..3987ba1 100644
--- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
@@ -41,11 +41,15 @@ void stds_usage(void)
   " index=: use the index as provided 
by --list-dv-timings\n"
   " or specify timings using cvt/gtf options 
as follows:\n"
   " 
cvt/gtf,width=,height=,fps=\n"
-  " 
interlaced=<0/1>,reduced-blanking=<0/1/2>\n"
+  " 
interlaced=<0/1>,reduced-blanking=<0/1/2>,reduced-fps=<0/1>\n"
   " The value of reduced-blanking, if greater 
than 0, indicates\n"
   " that reduced blanking is to be used and 
the value indicate the\n"
   " version. For gtf, there is no version 2 
for reduced blanking, and\n"
   " the value 1 or 2 will give same results.\n"
+  " reduced-fps = 1, slows down pixel clock by 
factor of 1000 / 1001, allowing\n"
+  " to support NTSC frame rates like 29.97 or 
59.94.\n"
+  " Reduced fps flag takes effect only with 
reduced blanking version 2 and,\n"
+  " when refresh rate is an integer multiple 
of 6, say, fps = 24,30,60 etc.\n"
   " or give a fully specified timings:\n"
   " 
width=,height=,interlaced=<0/1>,\n"
   " polarities=,pixelclock=,\n"
@@ -152,6 +156,7 @@ enum timing_opts {
GTF,
FPS,
REDUCED_BLANK,
+   REDUCED_FPS,
 };
 
 static int parse_timing_subopt(char **subopt_str, int *value)
@@ -179,6 +184,7 @@ static int parse_timing_subopt(char **subopt_str, int 
*value)
"gtf",
"fps",
"reduced-blanking",
+   "reduced-fps",
NULL
};
 
@@ -209,6 +215,7 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
int fps = 0;
int r_blank = 0;
int interlaced = 0;
+   bool reduced_fps = false;
bool timings_valid = false;
 
char *subopt_str = subopt;
@@ -234,6 +241,9 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
case INTERLACED:
interlaced = opt_val;
break;
+   case REDUCED_FPS:
+   reduced_fps = (opt_val == 1) ? true : false;
+   break;
default:
break;
}
@@ -241,7 +251,7 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
 
if (standard == V4L2_DV_BT_STD_CVT) {
timings_valid = calc_cvt_modeline(width, height, fps, r_blank,
- interlaced == 1 ? true : 
false, false, bt);
+ interlaced == 1 ? true : 
false, reduced_fps, bt);
} else {
timings_valid = calc_gtf_modeline(width, height, fps, r_blank,
  interlaced == 1 ? true : 
false, bt);
-- 
1.9.1

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


[RFC PATCH v2 1/2] v4l2-utils: add support for reduced fps in cvt modeline

2015-06-24 Thread Prashant Laddha
Added reduced fps option in cvt timings calculation. In this case,
pixel clock is slowed down by a factor of 1000 / 1001 and all other
timing parameters are unchanged. With reduced fps option one could
generate timings for refresh rates like 29.97 or 59.94. Pixel clock
in this case needs better precision, in the order of 0.001 Khz and
hence reduced fps option can be supported only when reduced blanking
V2 is enabled. Reduced fps is applicable only to nominal refresh
rates which are integer multiple of 6, say 24, 30, 60 etc.

Cc: Hans Verkuil 
Signed-off-by: Prashant Laddha 
---
 utils/v4l2-ctl/v4l2-ctl-modes.cpp | 6 +-
 utils/v4l2-ctl/v4l2-ctl-stds.cpp  | 2 +-
 utils/v4l2-ctl/v4l2-ctl.h | 3 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-modes.cpp 
b/utils/v4l2-ctl/v4l2-ctl-modes.cpp
index 88f7b6a..1912238 100644
--- a/utils/v4l2-ctl/v4l2-ctl-modes.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-modes.cpp
@@ -131,7 +131,8 @@ static int v_sync_from_aspect_ratio(int width, int height)
 
 bool calc_cvt_modeline(int image_width, int image_height,
   int refresh_rate, int reduced_blanking,
-  bool interlaced, struct v4l2_bt_timings *cvt)
+  bool interlaced, bool reduced_fps,
+  struct v4l2_bt_timings *cvt)
 {
int h_sync;
int v_sync;
@@ -295,6 +296,9 @@ bool calc_cvt_modeline(int image_width, int image_height,
 
pixel_clock = v_refresh * total_h_pixel *
  (2 * total_v_lines + interlace) / 2;
+   if (reduced_fps && v_refresh % 6 == 0)
+   pixel_clock = ((long long)pixel_clock * 1000) / 1001;
+
pixel_clock -= pixel_clock  % clk_gran;
}
 
diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
index aea46c9..e969d08 100644
--- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
@@ -241,7 +241,7 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
 
if (standard == V4L2_DV_BT_STD_CVT) {
timings_valid = calc_cvt_modeline(width, height, fps, r_blank,
- interlaced == 1 ? true : 
false, bt);
+ interlaced == 1 ? true : 
false, false, bt);
} else {
timings_valid = calc_gtf_modeline(width, height, fps, r_blank,
  interlaced == 1 ? true : 
false, bt);
diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h
index de65900..113f348 100644
--- a/utils/v4l2-ctl/v4l2-ctl.h
+++ b/utils/v4l2-ctl/v4l2-ctl.h
@@ -351,7 +351,8 @@ void edid_get(int fd);
 /* v4l2-ctl-modes.cpp */
 bool calc_cvt_modeline(int image_width, int image_height,
   int refresh_rate, int reduced_blanking,
-  bool interlaced, struct v4l2_bt_timings *cvt);
+  bool interlaced, bool reduced_fps,
+  struct v4l2_bt_timings *cvt);
 
 bool calc_gtf_modeline(int image_width, int image_height,
   int refresh_rate, int reduced_blanking,
-- 
1.9.1

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


Re: [PATCH v10.1] media: Add registration helpers for V4L2 flash sub-devices

2015-06-24 Thread Sakari Ailus
On Fri, Jun 19, 2015 at 09:31:47AM +0200, Jacek Anaszewski wrote:
> This patch adds helper functions for registering/unregistering
> LED Flash class devices as V4L2 sub-devices. The functions should
> be called from the LED subsystem device driver. In case the
> support for V4L2 Flash sub-devices is disabled in the kernel
> config the functions' empty versions will be used.
> 
> Signed-off-by: Jacek Anaszewski 
> Acked-by: Kyungmin Park 
> Cc: Sakari Ailus 
> Cc: Hans Verkuil 

Acked-by: Sakari Ailus 

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v10.1] leds: aat1290: add support for V4L2 Flash sub-device

2015-06-24 Thread Sakari Ailus
On Fri, Jun 19, 2015 at 09:33:22AM +0200, Jacek Anaszewski wrote:
> Add support for V4L2 Flash sub-device to the aat1290 LED Flash class
> driver. The support allows for V4L2 Flash sub-device to take the control
> of the LED Flash class device.
> 
> Signed-off-by: Jacek Anaszewski 
> Acked-by: Kyungmin Park 
> Cc: Bryan Wu 
> Cc: Richard Purdie 
> Cc: Sakari Ailus 

Acked-by: Sakari Ailus 

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] leds: aat1290: Add 'static' modifier to init_mm_current_scale

2015-06-24 Thread Sakari Ailus
On Fri, Jun 19, 2015 at 09:32:44AM +0200, Jacek Anaszewski wrote:
> Fix sparse warning by adding static modifier to the function
> init_mm_current_scale.
> 
> Signed-off-by: Jacek Anaszewski 

Acked-by: Sakari Ailus 

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/7] [media] use CONFIG_PM_SLEEP for suspend/resume

2015-06-24 Thread Maxime Coquelin



On 06/24/2015 12:49 PM, Mauro Carvalho Chehab wrote:

Using CONFIG_PM_SLEEP suppress the warnings when the driver is
compiled without PM sleep functions:

drivers/media/rc/st_rc.c:338:12: warning: ‘st_rc_suspend’ defined but not used 
[-Wunused-function]
drivers/media/rc/st_rc.c:359:12: warning: ‘st_rc_resume’ defined but not used 
[-Wunused-function]

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
index 979b40561b3a..37d040158dff 100644
--- a/drivers/media/rc/st_rc.c
+++ b/drivers/media/rc/st_rc.c
@@ -334,7 +334,7 @@ err:
return ret;
  }
  
-#ifdef CONFIG_PM

+#ifdef CONFIG_PM_SLEEP
  static int st_rc_suspend(struct device *dev)
  {
struct st_rc_device *rc_dev = dev_get_drvdata(dev);

Acked-by: Maxime Coquelin 

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


[PATCH v2] [media] lmedm04: fix the range for relative measurements

2015-06-24 Thread Mauro Carvalho Chehab
Relative measurements are typically between 0 and 0x. However,
for some tuners (TUNER_S7395 and TUNER_S0194), the range were from
0 to 0xff00, with means that 100% is never archived.
Also, TUNER_RS2000 uses a more complex math.

So, create a macro that does the conversion using bit operations
and use it for all conversions.

The code is also easier to read with is a bonus.

While here, remove a bogus comment.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c 
b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index fcef2a33ef3d..4cc55b3a0558 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -257,6 +257,9 @@ static int lme2510_enable_pid(struct dvb_usb_device *d, u8 
index, u16 pid_out)
return ret;
 }
 
+/* Convert range from 0x00-0xff to 0x-0x */
+#define reg_to_16bits(x)   ((x) | ((x) << 8))
+
 static void lme2510_update_stats(struct dvb_usb_adapter *adap)
 {
struct lme2510_state *st = adap_to_priv(adap);
@@ -288,23 +291,17 @@ static void lme2510_update_stats(struct dvb_usb_adapter 
*adap)
 
switch (st->tuner_config) {
case TUNER_LG:
-   s_tmp = 0xff - st->signal_level;
-   s_tmp |= s_tmp << 8;
-
-   c_tmp = 0xff - st->signal_sn;
-   c_tmp |= c_tmp << 8;
+   s_tmp = reg_to_16bits(0xff - st->signal_level);
+   c_tmp = reg_to_16bits(0xff - st->signal_sn);
break;
-   /* fall through */
case TUNER_S7395:
case TUNER_S0194:
s_tmp = 0x - (((st->signal_level * 2) << 8) * 5 / 4);
-
-   c_tmp = ((0xff - st->signal_sn - 0xa1) * 3) << 8;
+   c_tmp = reg_to_16bits((0xff - st->signal_sn - 0xa1) * 3);
break;
case TUNER_RS2000:
-   s_tmp = st->signal_level * 0x / 0xff;
-
-   c_tmp = st->signal_sn * 0x / 0x7f;
+   s_tmp = reg_to_16bits(st->signal_level);
+   c_tmp = reg_to_16bits(st->signal_sn);
}
 
c->strength.len = 1;
-- 
2.4.3

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


[PATCH 4/7] [media] saa7134: fix page size on some archs

2015-06-24 Thread Mauro Carvalho Chehab
On some archs, like tile, the PAGE_SIZE is not 4K. In the case
of tile arch, it can be either 16KB or 64KB.

Due to that, a warning is produced:
drivers/media/pci/saa7134/saa7134.h:678:43: warning: large integer 
implicitly truncated to unsigned type [-Woverflow]

This is actually an error, as it will write trach to the DMA size
registers. The logic at saa7134-ts already does the right thing:

saa_writeb(SAA7134_TS_DMA0, ((dev->ts.nr_packets-1)&0xff));
saa_writeb(SAA7134_TS_DMA1, (((dev->ts.nr_packets-1)>>8)&0xff));
/* TSNOPIT=0, TSCOLAP=0 */
saa_writeb(SAA7134_TS_DMA2,
dev->ts.nr_packets-1)>>16)&0x3f) | 0x00));

So, fix the driver to take larger page sizes into account.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c 
b/drivers/media/pci/saa7134/saa7134-go7007.c
index da7c4be4bed2..8a2abb34186b 100644
--- a/drivers/media/pci/saa7134/saa7134-go7007.c
+++ b/drivers/media/pci/saa7134/saa7134-go7007.c
@@ -289,9 +289,9 @@ static int saa7134_go7007_stream_start(struct go7007 *go)
 
/* Set up transfer block size */
saa_writeb(SAA7134_TS_PARALLEL_SERIAL, 128 - 1);
-   saa_writeb(SAA7134_TS_DMA0, (PAGE_SIZE >> 7) - 1);
-   saa_writeb(SAA7134_TS_DMA1, 0);
-   saa_writeb(SAA7134_TS_DMA2, 0);
+   saa_writeb(SAA7134_TS_DMA0, ((PAGE_SIZE >> 7) - 1) & 0xff);
+   saa_writeb(SAA7134_TS_DMA1, (PAGE_SIZE >> 15) & 0xff);
+   saa_writeb(SAA7134_TS_DMA2, (PAGE_SIZE >> 31) & 0x3f);
 
/* Enable video streaming mode */
saa_writeb(SAA7134_GPIO_GPSTATUS2, GPIO_COMMAND_VIDEO);
-- 
2.4.3

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


[PATCH 1/7] [media] si470x: cleanup define namespace

2015-06-24 Thread Mauro Carvalho Chehab
Some architectures already use CHIPID defines:

drivers/media/radio/si470x/radio-si470x.h:57:0: warning: "CHIPID" 
redefined [enabled by default]
drivers/media/radio/si470x/radio-si470x.h:57:0: warning: "CHIPID" 
redefined [enabled by default]
drivers/media/radio/si470x/radio-si470x.h:57:0: warning: "CHIPID" 
redefined [enabled by default]

So, use SI_foo namespace to avoid conflicts.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c 
b/drivers/media/radio/si470x/radio-si470x-i2c.c
index 49fe8453e218..471d6a8ae8a4 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -384,14 +384,14 @@ static int si470x_i2c_probe(struct i2c_client *client,
goto err_radio;
}
dev_info(&client->dev, "DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
-   radio->registers[DEVICEID], radio->registers[CHIPID]);
-   if ((radio->registers[CHIPID] & CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
+   radio->registers[DEVICEID], 
radio->registers[SI_CHIPID]);
+   if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < 
RADIO_FW_VERSION) {
dev_warn(&client->dev,
"This driver is known to work with "
"firmware version %hu,\n", RADIO_FW_VERSION);
dev_warn(&client->dev,
"but the device has firmware version %hu.\n",
-   radio->registers[CHIPID] & CHIPID_FIRMWARE);
+   radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE);
version_warning = 1;
}
 
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c 
b/drivers/media/radio/si470x/radio-si470x-usb.c
index 57f0bc3b60e7..091d793f6583 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -686,14 +686,14 @@ static int si470x_usb_driver_probe(struct usb_interface 
*intf,
goto err_ctrl;
}
dev_info(&intf->dev, "DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
-   radio->registers[DEVICEID], radio->registers[CHIPID]);
-   if ((radio->registers[CHIPID] & CHIPID_FIRMWARE) < RADIO_FW_VERSION) {
+   radio->registers[DEVICEID], 
radio->registers[SI_CHIPID]);
+   if ((radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE) < 
RADIO_FW_VERSION) {
dev_warn(&intf->dev,
"This driver is known to work with "
"firmware version %hu,\n", RADIO_FW_VERSION);
dev_warn(&intf->dev,
"but the device has firmware version %hu.\n",
-   radio->registers[CHIPID] & CHIPID_FIRMWARE);
+   radio->registers[SI_CHIPID] & SI_CHIPID_FIRMWARE);
version_warning = 1;
}
 
diff --git a/drivers/media/radio/si470x/radio-si470x.h 
b/drivers/media/radio/si470x/radio-si470x.h
index 4b7660470e2f..6c0ca900702e 100644
--- a/drivers/media/radio/si470x/radio-si470x.h
+++ b/drivers/media/radio/si470x/radio-si470x.h
@@ -54,10 +54,10 @@
 #define DEVICEID_PN0xf000  /* bits 15..12: Part Number */
 #define DEVICEID_MFGID 0x0fff  /* bits 11..00: Manufacturer ID */
 
-#define CHIPID 1   /* Chip ID */
-#define CHIPID_REV 0xfc00  /* bits 15..10: Chip Version */
-#define CHIPID_DEV 0x0200  /* bits 09..09: Device */
-#define CHIPID_FIRMWARE0x01ff  /* bits 08..00: Firmware 
Version */
+#define SI_CHIPID  1   /* Chip ID */
+#define SI_CHIPID_REV  0xfc00  /* bits 15..10: Chip Version */
+#define SI_CHIPID_DEV  0x0200  /* bits 09..09: Device */
+#define SI_CHIPID_FIRMWARE 0x01ff  /* bits 08..00: Firmware Version */
 
 #define POWERCFG   2   /* Power Configuration */
 #define POWERCFG_DSMUTE0x8000  /* bits 15..15: Softmute 
Disable */
-- 
2.4.3

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


[PATCH 3/7] [media] use CONFIG_PM_SLEEP for suspend/resume

2015-06-24 Thread Mauro Carvalho Chehab
Using CONFIG_PM_SLEEP suppress the warnings when the driver is
compiled without PM sleep functions:

drivers/media/rc/st_rc.c:338:12: warning: ‘st_rc_suspend’ defined but not used 
[-Wunused-function]
drivers/media/rc/st_rc.c:359:12: warning: ‘st_rc_resume’ defined but not used 
[-Wunused-function]

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
index 979b40561b3a..37d040158dff 100644
--- a/drivers/media/rc/st_rc.c
+++ b/drivers/media/rc/st_rc.c
@@ -334,7 +334,7 @@ err:
return ret;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int st_rc_suspend(struct device *dev)
 {
struct st_rc_device *rc_dev = dev_get_drvdata(dev);
-- 
2.4.3

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


[PATCH 5/7] [media] omap3isp: remove unused var

2015-06-24 Thread Mauro Carvalho Chehab
drivers/media/platform/omap3isp/isppreview.c:932:6: warning: variable 
‘features’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/platform/omap3isp/isppreview.c 
b/drivers/media/platform/omap3isp/isppreview.c
index 15cb254ccc39..13803270d104 100644
--- a/drivers/media/platform/omap3isp/isppreview.c
+++ b/drivers/media/platform/omap3isp/isppreview.c
@@ -929,14 +929,10 @@ static void preview_setup_hw(struct isp_prev_device 
*prev, u32 update,
 u32 active)
 {
unsigned int i;
-   u32 features;
 
if (update == 0)
return;
 
-   features = (prev->params.params[0].features & active)
-| (prev->params.params[1].features & ~active);
-
for (i = 0; i < ARRAY_SIZE(update_attrs); i++) {
const struct preview_update *attr = &update_attrs[i];
struct prev_params *params;
-- 
2.4.3

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


[PATCH 6/7] [media] lmedm04: use u32 instead of u64 for relative stats

2015-06-24 Thread Mauro Carvalho Chehab
Cleanup this sparse warning:
drivers/media/usb/dvb-usb-v2/lmedm04.c:302 lme2510_update_stats() warn: 
should '((255 - st->signal_sn - 161) * 3) << 8' be a 64 bit type?

Both c_tmp and s_tmp actually stores a u16 stat. Using a u64 data
there is a waste, specially on u32 archs, as 64 ints there are more
expensive.

So, change the types to u32 and do the typecast only when storing
the result.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c 
b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 57fb184184bf..fcef2a33ef3d 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -262,7 +262,7 @@ static void lme2510_update_stats(struct dvb_usb_adapter 
*adap)
struct lme2510_state *st = adap_to_priv(adap);
struct dvb_frontend *fe = adap->fe[0];
struct dtv_frontend_properties *c;
-   u64 s_tmp = 0, c_tmp = 0;
+   u32 s_tmp = 0, c_tmp = 0;
 
if (!fe)
return;
@@ -309,11 +309,11 @@ static void lme2510_update_stats(struct dvb_usb_adapter 
*adap)
 
c->strength.len = 1;
c->strength.stat[0].scale = FE_SCALE_RELATIVE;
-   c->strength.stat[0].uvalue = s_tmp;
+   c->strength.stat[0].uvalue = (u64)s_tmp;
 
c->cnr.len = 1;
c->cnr.stat[0].scale = FE_SCALE_RELATIVE;
-   c->cnr.stat[0].uvalue = c_tmp;
+   c->cnr.stat[0].uvalue = (u64)c_tmp;
 }
 
 static void lme2510_int_response(struct urb *lme_urb)
-- 
2.4.3

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


[PATCH 7/7] [media] lmedm04: fix the range for relative measurements

2015-06-24 Thread Mauro Carvalho Chehab
Relative measurements are typically between 0 and 0x. However,
for some tuners (TUNER_S7395 and TUNER_S0194), the range were from
0 to 0xff00, with means that 100% is never archived.
Also, TUNER_RS2000 uses a more complex math.

So, create a macro that does the conversion using bit operations
and use it for all conversions.

The code is also easier to read with is a bonus.

While here, remove a bogus comment.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c 
b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index fcef2a33ef3d..befcf97662ca 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -257,6 +257,9 @@ static int lme2510_enable_pid(struct dvb_usb_device *d, u8 
index, u16 pid_out)
return ret;
 }
 
+/* Convert range from 0x00-0xff to 0x-0x */
+#define reg_to_16bits(x)   ((x) | ((x) << 8)
+
 static void lme2510_update_stats(struct dvb_usb_adapter *adap)
 {
struct lme2510_state *st = adap_to_priv(adap);
@@ -288,23 +291,17 @@ static void lme2510_update_stats(struct dvb_usb_adapter 
*adap)
 
switch (st->tuner_config) {
case TUNER_LG:
-   s_tmp = 0xff - st->signal_level;
-   s_tmp |= s_tmp << 8;
-
-   c_tmp = 0xff - st->signal_sn;
-   c_tmp |= c_tmp << 8;
+   s_tmp = reg_to_16bits(0xff - st->signal_level);
+   c_tmp = reg_to_16bits(0xff - st->signal_sn);
break;
-   /* fall through */
case TUNER_S7395:
case TUNER_S0194:
s_tmp = 0x - (((st->signal_level * 2) << 8) * 5 / 4);
-
-   c_tmp = ((0xff - st->signal_sn - 0xa1) * 3) << 8;
+   c_tmp = reg_to_16bits((0xff - st->signal_sn - 0xa1) * 3);
break;
case TUNER_RS2000:
-   s_tmp = st->signal_level * 0x / 0xff;
-
-   c_tmp = st->signal_sn * 0x / 0x7f;
+   s_tmp = reg_to_16bits(st->signal_level);
+   c_tmp = reg_to_16bits(st->signal_sn);
}
 
c->strength.len = 1;
-- 
2.4.3

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


[PATCH 2/7] [media] tuner-i2c: be consistent with I2C declaration

2015-06-24 Thread Mauro Carvalho Chehab
On alpha, gcc warns a log about signed/unsigned ballance, with
produces 3185 warnings. Ok, this is bogus, but it indicates that
the declaration at V4L2 side is not consistent with the one at
I2C.

With this trivial patch, the number of errors reduce to 2959
warnings. Still too much, but it is 7.1% less. So let's do it.

Signed-off-by: Mauro Carvalho Chehab 

diff --git a/drivers/media/tuners/tuner-i2c.h b/drivers/media/tuners/tuner-i2c.h
index 18f005634c67..bda67a5a76f2 100644
--- a/drivers/media/tuners/tuner-i2c.h
+++ b/drivers/media/tuners/tuner-i2c.h
@@ -33,7 +33,8 @@ struct tuner_i2c_props {
char *name;
 };
 
-static inline int tuner_i2c_xfer_send(struct tuner_i2c_props *props, char 
*buf, int len)
+static inline int tuner_i2c_xfer_send(struct tuner_i2c_props *props,
+ unsigned char *buf, int len)
 {
struct i2c_msg msg = { .addr = props->addr, .flags = 0,
   .buf = buf, .len = len };
@@ -42,7 +43,8 @@ static inline int tuner_i2c_xfer_send(struct tuner_i2c_props 
*props, char *buf,
return (ret == 1) ? len : ret;
 }
 
-static inline int tuner_i2c_xfer_recv(struct tuner_i2c_props *props, char 
*buf, int len)
+static inline int tuner_i2c_xfer_recv(struct tuner_i2c_props *props,
+ unsigned char *buf, int len)
 {
struct i2c_msg msg = { .addr = props->addr, .flags = I2C_M_RD,
   .buf = buf, .len = len };
@@ -52,8 +54,8 @@ static inline int tuner_i2c_xfer_recv(struct tuner_i2c_props 
*props, char *buf,
 }
 
 static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
-  char *obuf, int olen,
-  char *ibuf, int ilen)
+  unsigned char *obuf, int olen,
+  unsigned char *ibuf, int ilen)
 {
struct i2c_msg msg[2] = { { .addr = props->addr, .flags = 0,
.buf = obuf, .len = olen },
-- 
2.4.3

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


Re: userspace media util repository

2015-06-24 Thread Mauro Carvalho Chehab
Em Wed, 24 Jun 2015 14:58:12 +0900
"Kim, Heung Jun"  escreveu:

> Thank you for reply, Guennadi.
> 
> I'm not sure of it. In my memory it was capable of making "ps" file shows
> the relationship between entities of media devices. And, in my quick glance
> I can not find that codes in it (yet).
> 
> Am I right that such user application working like this exists? In fact, my
> memory can be wrong.
> 
> Any comments are welcome and very helpful, and I'd appreciated in advance.
> 
> ps. Sorry for some corrupted characters in my previous mail by unsetting
> mail client yet.


ps doesn't show the media controller entities. The tool that does that
is media-ctl. This tool is there at v4l-utils package.

Regards,
Mauro

> 
> 
> 2015-06-24 14:37 GMT+09:00 Guennadi Liakhovetski :
> 
> > Do you mean this?
> >
> > http://git.linuxtv.org/cgit.cgi/v4l-utils.git/
> >
> > Regards
> > Guennadi
> >
> > On Wed, 24 Jun 2015, Kim, Heung Jun wrote:
> >
> > > Hi all,
> > >
> > > Iâ  m looking for official repository for user space media utils. For
> > testing
> > > media device status on target I was about to use it, but I couldnâ  t
> > find it
> > > now on linuxtv.org site which Iâ  ve seen about some years ago.
> > >
> > > Would anyone please let me inform where it is?
> > >
> > > Regards,
> > > HeungJun (Jeremy) Kim
> > >
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] v4l2-utils: use boolean for interlaced flag

2015-06-24 Thread Prashant Laddha
This change does not affect functionality. A minor change so that
the options that flags are captured as booleans and look consistent
with other flags.

Cc: Hans Verkuil 
Signed-off-by: Prashant Laddha 
---
 utils/v4l2-ctl/v4l2-ctl-stds.cpp | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/utils/v4l2-ctl/v4l2-ctl-stds.cpp b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
index 3987ba1..26cb08b 100644
--- a/utils/v4l2-ctl/v4l2-ctl-stds.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-stds.cpp
@@ -214,7 +214,7 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
int height = 0;
int fps = 0;
int r_blank = 0;
-   int interlaced = 0;
+   bool interlaced = false;
bool reduced_fps = false;
bool timings_valid = false;
 
@@ -239,7 +239,7 @@ static void get_cvt_gtf_timings(char *subopt, int standard,
r_blank = opt_val;
break;
case INTERLACED:
-   interlaced = opt_val;
+   interlaced = (opt_val == 1) ? true : false;
break;
case REDUCED_FPS:
reduced_fps = (opt_val == 1) ? true : false;
@@ -249,13 +249,12 @@ static void get_cvt_gtf_timings(char *subopt, int 
standard,
}
}
 
-   if (standard == V4L2_DV_BT_STD_CVT) {
+   if (standard == V4L2_DV_BT_STD_CVT)
timings_valid = calc_cvt_modeline(width, height, fps, r_blank,
- interlaced == 1 ? true : 
false, reduced_fps, bt);
-   } else {
+ interlaced, reduced_fps, bt);
+   else
timings_valid = calc_gtf_modeline(width, height, fps, r_blank,
- interlaced == 1 ? true : 
false, bt);
-   }
+ interlaced, bt);
 
if (!timings_valid) {
stds_usage();
-- 
1.9.1

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