cron job: media_tree daily build: OK

2015-07-16 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:   Fri Jul 17 04:00:19 CEST 2015
git branch: test
git hash:   8783b9c50400c6279d7c3b716637b98e83d3c933
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0-51-ga53cea2
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.1-i686: OK
linux-4.2-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.1-x86_64: OK
linux-4.2-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Friday.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] [media]: Fix compilation when CONFIG_VIDEO_V4L2_SUBDEV_API is not set

2015-07-16 Thread Adam Majer
On Thu, Jul 16, 2015 at 06:20:55PM -0500, Adam Majer wrote:
> When CONFIG_VIDEO_V4L2_SUBDEV_API is unset, some drivers fail to
> compile as they use unavailable API.
> 
>   drivers/media/i2c/adv7511.c:968:3: error: implicit declaration of
>   function ‘v4l2_subdev_get_try_format’
>   [-Werror=implicit-function-declaration]


oops, maybe this is unnecessary. Seems I had CONFIG_COBALT set which
was causing problems.

warning: (VIDEO_COBALT) selects VIDEO_ADV7511 which has unmet direct
dependencies (MEDIA_SUPPORT && VIDEO_V4L2 && I2C &&
VIDEO_V4L2_SUBDEV_API)


so please ignore.

- Adam


-- 
Adam Majer
ad...@zombino.com
--
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]: Fix compilation when CONFIG_VIDEO_V4L2_SUBDEV_API is not set

2015-07-16 Thread Adam Majer
When CONFIG_VIDEO_V4L2_SUBDEV_API is unset, some drivers fail to
compile as they use unavailable API.

  drivers/media/i2c/adv7511.c:968:3: error: implicit declaration of
  function ‘v4l2_subdev_get_try_format’
  [-Werror=implicit-function-declaration]
---
 drivers/media/i2c/adv7511.c | 8 
 drivers/media/i2c/adv7604.c | 8 
 drivers/media/i2c/adv7842.c | 8 
 3 files changed, 24 insertions(+)

diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c
index 95bcd40..e3f5ecb 100644
--- a/drivers/media/i2c/adv7511.c
+++ b/drivers/media/i2c/adv7511.c
@@ -963,6 +963,7 @@ static int adv7511_get_fmt(struct v4l2_subdev *sd,
adv7511_fill_format(state, &format->format);
 
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
struct v4l2_mbus_framefmt *fmt;
 
fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
@@ -971,6 +972,9 @@ static int adv7511_get_fmt(struct v4l2_subdev *sd,
format->format.ycbcr_enc = fmt->ycbcr_enc;
format->format.quantization = fmt->quantization;
format->format.xfer_func = fmt->xfer_func;
+#else
+   return -ENOTTY;
+#endif
} else {
format->format.code = state->fmt_code;
format->format.colorspace = state->colorspace;
@@ -1016,6 +1020,7 @@ static int adv7511_set_fmt(struct v4l2_subdev *sd,
 
adv7511_fill_format(state, &format->format);
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
struct v4l2_mbus_framefmt *fmt;
 
fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
@@ -1025,6 +1030,9 @@ static int adv7511_set_fmt(struct v4l2_subdev *sd,
fmt->quantization = format->format.quantization;
fmt->xfer_func = format->format.xfer_func;
return 0;
+#else
+   return -ENOTTY;
+#endif
}
 
switch (format->format.code) {
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 808360f..c080bca 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -1856,10 +1856,14 @@ static int adv76xx_get_format(struct v4l2_subdev *sd,
adv76xx_fill_format(state, &format->format);
 
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
struct v4l2_mbus_framefmt *fmt;
 
fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
format->format.code = fmt->code;
+#else
+   return -ENOTTY;
+#endif
} else {
format->format.code = state->format->code;
}
@@ -1885,10 +1889,14 @@ static int adv76xx_set_format(struct v4l2_subdev *sd,
format->format.code = info->code;
 
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
struct v4l2_mbus_framefmt *fmt;
 
fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
fmt->code = format->format.code;
+#else
+   return -ENOTTY;
+#endif
} else {
state->format = info;
adv76xx_setup_format(state);
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 4cf79b2..5e50b85 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2088,10 +2088,14 @@ static int adv7842_get_format(struct v4l2_subdev *sd,
adv7842_fill_format(state, &format->format);
 
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
struct v4l2_mbus_framefmt *fmt;
 
fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
format->format.code = fmt->code;
+#else
+   return -ENOTTY;
+#endif
} else {
format->format.code = state->format->code;
}
@@ -2120,10 +2124,14 @@ static int adv7842_set_format(struct v4l2_subdev *sd,
format->format.code = info->code;
 
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
struct v4l2_mbus_framefmt *fmt;
 
fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
fmt->code = format->format.code;
+#else
+   return -ENOTTY;
+#endif
} else {
state->format = info;
adv7842_setup_format(state);
-- 
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 v3 4/5] [media] imx-ipu: Add ipu media common code

2015-07-16 Thread Philipp Zabel
From: Sascha Hauer 

Add video4linux API routines common to drivers for units that
accept or provide video data via the i.MX IPU IDMAC channels,
such as scaler or deinterlacer drivers.

Signed-off-by: Sascha Hauer 
Signed-off-by: Lucas Stach 
Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/Kconfig   |   2 +
 drivers/media/platform/Makefile  |   1 +
 drivers/media/platform/imx/Kconfig   |   2 +
 drivers/media/platform/imx/Makefile  |   1 +
 drivers/media/platform/imx/imx-ipu.c | 313 +++
 drivers/media/platform/imx/imx-ipu.h |  35 
 6 files changed, 354 insertions(+)
 create mode 100644 drivers/media/platform/imx/Kconfig
 create mode 100644 drivers/media/platform/imx/Makefile
 create mode 100644 drivers/media/platform/imx/imx-ipu.c
 create mode 100644 drivers/media/platform/imx/imx-ipu.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f6bed19..66c8d91 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -29,6 +29,8 @@ config VIDEO_VIA_CAMERA
 
 source "drivers/media/platform/davinci/Kconfig"
 
+source "drivers/media/platform/imx/Kconfig"
+
 source "drivers/media/platform/omap/Kconfig"
 
 source "drivers/media/platform/blackfin/Kconfig"
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 114f9ab..c3438c2 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_SOC_CAMERA)  += soc_camera/
 
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1/
 
+obj-y  += imx/
 obj-y  += omap/
 
 obj-$(CONFIG_VIDEO_AM437X_VPFE)+= am437x/
diff --git a/drivers/media/platform/imx/Kconfig 
b/drivers/media/platform/imx/Kconfig
new file mode 100644
index 000..a90c973
--- /dev/null
+++ b/drivers/media/platform/imx/Kconfig
@@ -0,0 +1,2 @@
+config VIDEO_IMX_IPU_COMMON
+   tristate
diff --git a/drivers/media/platform/imx/Makefile 
b/drivers/media/platform/imx/Makefile
new file mode 100644
index 000..5de119c
--- /dev/null
+++ b/drivers/media/platform/imx/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o
diff --git a/drivers/media/platform/imx/imx-ipu.c 
b/drivers/media/platform/imx/imx-ipu.c
new file mode 100644
index 000..c1b8637
--- /dev/null
+++ b/drivers/media/platform/imx/imx-ipu.c
@@ -0,0 +1,313 @@
+/*
+ * i.MX IPUv3 common v4l2 support
+ *
+ * Copyright (C) 2011 Sascha Hauer, Pengutronix
+ *
+ * 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 "imx-ipu.h"
+
+static struct ipu_fmt ipu_fmt_yuv[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_YUV420,
+   .name = "YUV 4:2:0 planar, YCbCr",
+   .bytes_per_pixel = 1,
+   }, {
+   .fourcc = V4L2_PIX_FMT_YVU420,
+   .name = "YUV 4:2:0 planar, YCrCb",
+   .bytes_per_pixel = 1,
+   }, {
+   .fourcc = V4L2_PIX_FMT_YUV422P,
+   .name = "YUV 4:2:2 planar, YCbCr",
+   .bytes_per_pixel = 1,
+   }, {
+   .fourcc = V4L2_PIX_FMT_NV12,
+   .name = "YUV 4:2:0 partial interleaved, YCbCr",
+   .bytes_per_pixel = 1,
+   }, {
+   .fourcc = V4L2_PIX_FMT_UYVY,
+   .name = "4:2:2, packed, UYVY",
+   .bytes_per_pixel = 2,
+   }, {
+   .fourcc = V4L2_PIX_FMT_YUYV,
+   .name = "4:2:2, packed, YUYV",
+   .bytes_per_pixel = 2,
+   },
+};
+
+static struct ipu_fmt ipu_fmt_rgb[] = {
+   {
+   .fourcc = V4L2_PIX_FMT_RGB32,
+   .name = "RGB888",
+   .bytes_per_pixel = 4,
+   }, {
+   .fourcc = V4L2_PIX_FMT_RGB24,
+   .name = "RGB24",
+   .bytes_per_pixel = 3,
+   }, {
+   .fourcc = V4L2_PIX_FMT_BGR24,
+   .name = "BGR24",
+   .bytes_per_pixel = 3,
+   }, {
+   .fourcc = V4L2_PIX_FMT_RGB565,
+   .name = "RGB565",
+   .bytes_per_pixel = 2,
+   },
+   {
+   .fourcc = V4L2_PIX_FMT_BGR32,
+   .name = "BGR888",
+   .bytes_per_pixel = 4,
+   },
+};
+
+struct ipu_fmt *ipu_find_fmt_yuv(unsigned int pixelformat)
+{
+   struct ipu_fmt *fmt;
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(ipu_fmt_yuv); i++) {
+   fmt = &ipu_fmt_yuv[i];
+   if (fmt->fourcc == pixelformat)
+

[PATCH v3 2/5] gpu: ipu-v3: Add mem2mem image conversion support to IC

2015-07-16 Thread Philipp Zabel
This patch adds support for mem2mem scaling and colorspace conversion
using the IC module's post-processing task.

Scaling images larger than 1024x1024 is supported by tiling over multiple
IC scaling runs. Since the IDMAC and IC units have interesting and
different alignment limitations for buffer base addresses (left edges)
and burst size (row lengths), depending on input and output pixel formats,
the tile rectangles and scaling coefficients are chosen to minimize
distortion. Due to possible overlap, the tiles have to be rendered right
to left and bottom to top. Up to 7 pixels (depending on frame sizes and
scaling factor) have to be available after the end of the frame if the
width is not burst size aligned. The tiling code has a parameter to
optionally round frame sizes up or down and avoid overdraw in
compositing scenarios.

Signed-off-by: Sascha Hauer 
Signed-off-by: Lucas Stach 
Signed-off-by: Philipp Zabel 
---
Changes since v2:
 - Limit downscaling to 4:1
 - Dropped currently unused rotator and deinterlacer channels
---
 drivers/gpu/ipu-v3/ipu-ic.c | 754 +++-
 include/video/imx-ipu-v3.h  |  34 +-
 2 files changed, 771 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-ic.c b/drivers/gpu/ipu-v3/ipu-ic.c
index 1dcb96c..7a79e46 100644
--- a/drivers/gpu/ipu-v3/ipu-ic.c
+++ b/drivers/gpu/ipu-v3/ipu-ic.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "ipu-prv.h"
@@ -96,6 +97,11 @@ struct ic_task_bitfields {
u32 ic_cmb_galpha_bit;
 };
 
+struct ic_task_channels {
+   u8 in;
+   u8 out;
+};
+
 static const struct ic_task_regoffs ic_task_reg[IC_NUM_TASKS] = {
[IC_TASK_ENCODER] = {
.rsc = IC_PRP_ENC_RSC,
@@ -138,12 +144,41 @@ static const struct ic_task_bitfields 
ic_task_bit[IC_NUM_TASKS] = {
},
 };
 
+static const struct ic_task_channels ic_task_ch[IC_NUM_TASKS] = {
+   [IC_TASK_ENCODER] = {
+   .in = IPUV3_CHANNEL_MEM_IC_PRP_VF,
+   .out = IPUV3_CHANNEL_IC_PRP_ENC_MEM,
+   },
+   [IC_TASK_VIEWFINDER] = {
+   .in = IPUV3_CHANNEL_MEM_VDI_CUR,
+   .out = IPUV3_CHANNEL_IC_PRP_VF_MEM,
+   },
+   [IC_TASK_POST_PROCESSOR] = {
+   .in = IPUV3_CHANNEL_MEM_IC_PP,
+   .out = IPUV3_CHANNEL_IC_PP_MEM,
+   },
+};
+
+struct image_convert_ctx {
+   void (*complete)(void *ctx, int err);
+   void *complete_context;
+
+   struct list_head list;
+   struct ipu_image in;
+   struct ipu_image out;
+
+   void *freep;
+
+   u32 rsc;
+};
+
 struct ipu_ic_priv;
 
 struct ipu_ic {
enum ipu_ic_task task;
const struct ic_task_regoffs *reg;
const struct ic_task_bitfields *bit;
+   const struct ic_task_channels *ch;
 
enum ipu_color_space in_cs, g_in_cs;
enum ipu_color_space out_cs;
@@ -152,6 +187,15 @@ struct ipu_ic {
bool in_use;
 
struct ipu_ic_priv *priv;
+
+   struct ipuv3_channel *input_channel;
+   struct ipuv3_channel *output_channel;
+
+   struct list_head image_list;
+
+   struct workqueue_struct *workqueue;
+   struct work_struct work;
+   struct completion complete;
 };
 
 struct ipu_ic_priv {
@@ -168,7 +212,8 @@ static inline u32 ipu_ic_read(struct ipu_ic *ic, unsigned 
offset)
return readl(ic->priv->base + offset);
 }
 
-static inline void ipu_ic_write(struct ipu_ic *ic, u32 value, unsigned offset)
+static inline void ipu_ic_write(struct ipu_ic *ic, u32 value,
+   unsigned offset)
 {
writel(value, ic->priv->base + offset);
 }
@@ -446,32 +491,35 @@ int ipu_ic_task_init(struct ipu_ic *ic,
 int in_width, int in_height,
 int out_width, int out_height,
 enum ipu_color_space in_cs,
-enum ipu_color_space out_cs)
+enum ipu_color_space out_cs,
+u32 rsc)
 {
struct ipu_ic_priv *priv = ic->priv;
-   u32 reg, downsize_coeff, resize_coeff;
+   u32 downsize_coeff, resize_coeff;
unsigned long flags;
int ret = 0;
 
-   /* Setup vertical resizing */
-   ret = calc_resize_coeffs(ic, in_height, out_height,
-&resize_coeff, &downsize_coeff);
-   if (ret)
-   return ret;
+   if (!rsc) {
+   /* Setup vertical resizing */
+   ret = calc_resize_coeffs(ic, in_height, out_height,
+&resize_coeff, &downsize_coeff);
+   if (ret)
+   return ret;
 
-   reg = (downsize_coeff << 30) | (resize_coeff << 16);
+   rsc = (downsize_coeff << 30) | (resize_coeff << 16);
 
-   /* Setup horizontal resizing */
-   ret = calc_resize_coeffs(ic, in_width, out_width,
-&resize_coeff, &downsize_coeff);
-   if (ret)
-

[PATCH v3 5/5] [media] imx-ipu: Add i.MX IPUv3 scaler driver

2015-07-16 Thread Philipp Zabel
From: Sascha Hauer 

This patch adds support for hardware accelerated scaling and color
space conversion between memory buffers using the IPUv3 IC.
Since the maximum output size of the IC unit is 1024x1024 pixels, multiple
IC tasks with overlapping tiles are used internally to scale and convert
larger frames.

The IC operates with a burst size of at least 8 pixels. Depending on the
frame width and scaling factor, up to 7 junk pixels may be written after
the end of the frame. The sizeimage is increased accordingly.

Signed-off-by: Sascha Hauer 
Signed-off-by: Michael Olbrich 
Signed-off-by: Philipp Zabel 
---
Changes since v2:
 - Disabled USERPTR memory, hardware doesn't support it.
 - Embedded struct video_device in ipu_scale_dev.
 - Set icc pointer to NULL on error.
 - Fixed module description.
---
 drivers/media/platform/imx/Kconfig  |   9 +
 drivers/media/platform/imx/Makefile |   1 +
 drivers/media/platform/imx/imx-ipu-scaler.c | 859 
 drivers/media/platform/imx/imx-ipu.c|   2 +-
 drivers/media/platform/imx/imx-ipu.h|   1 +
 5 files changed, 871 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/imx/imx-ipu-scaler.c

diff --git a/drivers/media/platform/imx/Kconfig 
b/drivers/media/platform/imx/Kconfig
index a90c973..4694367 100644
--- a/drivers/media/platform/imx/Kconfig
+++ b/drivers/media/platform/imx/Kconfig
@@ -1,2 +1,11 @@
 config VIDEO_IMX_IPU_COMMON
tristate
+
+config VIDEO_IMX_IPU_SCALER
+   tristate "i.MX5/6 IPUv3 based image scaler driver"
+   depends on VIDEO_DEV && IMX_IPUV3_CORE
+   select VIDEOBUF2_DMA_CONTIG
+   select VIDEO_IMX_IPU_COMMON
+   select V4L2_MEM2MEM_DEV
+   ---help---
+ This is a v4l2 scaler video driver for the IPUv3 on i.MX5/6.
diff --git a/drivers/media/platform/imx/Makefile 
b/drivers/media/platform/imx/Makefile
index 5de119c..f20aa0b 100644
--- a/drivers/media/platform/imx/Makefile
+++ b/drivers/media/platform/imx/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_VIDEO_IMX_IPU_COMMON) += imx-ipu.o
+obj-$(CONFIG_VIDEO_IMX_IPU_SCALER) += imx-ipu-scaler.o
diff --git a/drivers/media/platform/imx/imx-ipu-scaler.c 
b/drivers/media/platform/imx/imx-ipu-scaler.c
new file mode 100644
index 000..6c6d0aa
--- /dev/null
+++ b/drivers/media/platform/imx/imx-ipu-scaler.c
@@ -0,0 +1,860 @@
+/*
+ * i.MX IPUv3 scaler driver
+ *
+ * Copyright (C) 2011 Sascha Hauer, Pengutronix
+ *
+ * based on the mem2mem test driver
+ *
+ * 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 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "imx-ipu.h"
+
+#define MIN_W 32
+#define MIN_H 32
+#define MAX_W 4096
+#define MAX_H 4096
+#define DIM_ALIGN_MASK 0x08 /* 8-alignment for dimensions */
+
+/* Flags that indicate a format can be used for capture/output */
+#define MEM2MEM_CAPTURE(1 << 0)
+#define MEM2MEM_OUTPUT (1 << 1)
+
+#define MEM2MEM_NAME   "imx-ipuv3-scale"
+
+/* Per queue */
+#define MEM2MEM_DEF_NUM_BUFS   VIDEO_MAX_FRAME
+/* In bytes, per queue */
+#define MEM2MEM_VID_MEM_LIMIT  (64 * 1024 * 1024)
+
+#define fh_to_ctx(__fh)container_of(__fh, struct ipu_scale_ctx, fh)
+
+enum {
+   V4L2_M2M_SRC = 0,
+   V4L2_M2M_DST = 1,
+};
+
+struct ipu_scale_dev {
+   struct v4l2_device  v4l2_dev;
+   struct video_device vfd;
+   struct device   *dev;
+   struct ipu_soc  *ipu;
+
+   atomic_tnum_inst;
+   spinlock_t  irqlock;
+
+   struct v4l2_m2m_dev *m2m_dev;
+   struct mutexdev_mutex;
+};
+
+/* Per-queue, driver-specific private data */
+struct ipu_scale_q_data {
+   struct v4l2_pix_format  cur_fmt;
+   struct v4l2_rectrect;
+};
+
+struct ipu_scale_ctx {
+   struct ipu_scale_dev*ipu_scaler;
+
+   struct v4l2_fh  fh;
+   struct vb2_alloc_ctx*alloc_ctx;
+   struct ipu_scale_q_data q_data[2];
+   struct work_struct  work;
+   struct completion   completion;
+   struct work_struct  skip_run;
+   int error;
+   int aborting;
+   enum ipu_image_scale_ctrl ctrl;
+   struct image_convert_ctx *icc;
+   int num_tiles;
+};
+
+static struct ipu_scale_q_data *get_q_data(struct ipu_scale_ctx *ctx,
+  enum v4l2_buf_type type)
+{
+   switch (

[PATCH v3 1/5] gpu: ipu-v3: Add missing IDMAC channel names

2015-07-16 Thread Philipp Zabel
This patch adds the remaining missing IDMAC channel names: all VDIC
channels for deinterlacing and combining, the separate alpha channels
for the MEM->IC and MEM->DC ASYNC channels, and the DC read, command,
and output mask channels.

Signed-off-by: Philipp Zabel 
---
 include/video/imx-ipu-v3.h | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h
index 85dedca..0cf0a51 100644
--- a/include/video/imx-ipu-v3.h
+++ b/include/video/imx-ipu-v3.h
@@ -96,20 +96,34 @@ enum ipu_channel_irq {
 #define IPUV3_CHANNEL_CSI2  2
 #define IPUV3_CHANNEL_CSI3  3
 #define IPUV3_CHANNEL_VDI_MEM_IC_VF 5
+#define IPUV3_CHANNEL_MEM_VDI_PREV  8
+#define IPUV3_CHANNEL_MEM_VDI_CUR   9
+#define IPUV3_CHANNEL_MEM_VDI_NEXT 10
 #define IPUV3_CHANNEL_MEM_IC_PP11
 #define IPUV3_CHANNEL_MEM_IC_PRP_VF12
+#define IPUV3_CHANNEL_VDI_MEM_RECENT   13
 #define IPUV3_CHANNEL_G_MEM_IC_PRP_VF  14
 #define IPUV3_CHANNEL_G_MEM_IC_PP  15
+#define IPUV3_CHANNEL_G_MEM_IC_PRP_VF_ALPHA17
+#define IPUV3_CHANNEL_G_MEM_IC_PP_ALPHA18
+#define IPUV3_CHANNEL_MEM_VDI_PLANE1_COMB_ALPHA19
 #define IPUV3_CHANNEL_IC_PRP_ENC_MEM   20
 #define IPUV3_CHANNEL_IC_PRP_VF_MEM21
 #define IPUV3_CHANNEL_IC_PP_MEM22
 #define IPUV3_CHANNEL_MEM_BG_SYNC  23
 #define IPUV3_CHANNEL_MEM_BG_ASYNC 24
+#define IPUV3_CHANNEL_MEM_VDI_PLANE1_COMB  25
+#define IPUV3_CHANNEL_MEM_VDI_PLANE3_COMB  26
 #define IPUV3_CHANNEL_MEM_FG_SYNC  27
 #define IPUV3_CHANNEL_MEM_DC_SYNC  28
 #define IPUV3_CHANNEL_MEM_FG_ASYNC 29
 #define IPUV3_CHANNEL_MEM_FG_SYNC_ALPHA31
+#define IPUV3_CHANNEL_MEM_FG_ASYNC_ALPHA   33
+#define IPUV3_CHANNEL_DC_MEM_READ  40
 #define IPUV3_CHANNEL_MEM_DC_ASYNC 41
+#define IPUV3_CHANNEL_MEM_DC_COMMAND   42
+#define IPUV3_CHANNEL_MEM_DC_COMMAND2  43
+#define IPUV3_CHANNEL_MEM_DC_OUTPUT_MASK   44
 #define IPUV3_CHANNEL_MEM_ROT_ENC  45
 #define IPUV3_CHANNEL_MEM_ROT_VF   46
 #define IPUV3_CHANNEL_MEM_ROT_PP   47
@@ -117,6 +131,7 @@ enum ipu_channel_irq {
 #define IPUV3_CHANNEL_ROT_VF_MEM   49
 #define IPUV3_CHANNEL_ROT_PP_MEM   50
 #define IPUV3_CHANNEL_MEM_BG_SYNC_ALPHA51
+#define IPUV3_CHANNEL_MEM_BG_ASYNC_ALPHA   52
 
 int ipu_map_irq(struct ipu_soc *ipu, int irq);
 int ipu_idmac_channel_irq(struct ipu_soc *ipu, struct ipuv3_channel *channel,
-- 
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 v3 0/5] i.MX5/6 mem2mem scaler

2015-07-16 Thread Philipp Zabel
Hi,

this series uses the IPU IC post-processing task to implement
a mem2mem device for scaling and colorspace conversion. This
version addresses a few review commends, and includes some
further cleanup.

Changes since v2:
 - Limit downscaling to 4:1
 - Disabled USERPTR memory
 - Set icc pointer to NULL on error
 - Dropped currently unused IDMAC channels
 - Fixed scaler module description
 - Embedded struct video_device

If it is acceptable, I'd like to merge this through drm-next via imx-drm.
Mauro reportedly would be ok with that, and currently the potential for
conflicts is limited to drivers/media/{Kconfig,Makefile}. If not, I'll
postpone the two [media] patches for a release.

regards
Philipp

Philipp Zabel (3):
  gpu: ipu-v3: Add missing IDMAC channel names
  gpu: ipu-v3: Add mem2mem image conversion support to IC
  gpu: ipu-v3: Register scaler platform device

Sascha Hauer (2):
  [media] imx-ipu: Add ipu media common code
  [media] imx-ipu: Add i.MX IPUv3 scaler driver

 drivers/gpu/ipu-v3/ipu-common.c |   2 +
 drivers/gpu/ipu-v3/ipu-ic.c | 754 +++-
 drivers/media/platform/Kconfig  |   2 +
 drivers/media/platform/Makefile |   1 +
 drivers/media/platform/imx/Kconfig  |  11 +
 drivers/media/platform/imx/Makefile |   2 +
 drivers/media/platform/imx/imx-ipu-scaler.c | 859 
 drivers/media/platform/imx/imx-ipu.c| 313 ++
 drivers/media/platform/imx/imx-ipu.h|  36 ++
 include/video/imx-ipu-v3.h  |  49 +-
 10 files changed, 2012 insertions(+), 17 deletions(-)
 create mode 100644 drivers/media/platform/imx/Kconfig
 create mode 100644 drivers/media/platform/imx/Makefile
 create mode 100644 drivers/media/platform/imx/imx-ipu-scaler.c
 create mode 100644 drivers/media/platform/imx/imx-ipu.c
 create mode 100644 drivers/media/platform/imx/imx-ipu.h

-- 
2.1.4

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


[PATCH v3 3/5] gpu: ipu-v3: Register scaler platform device

2015-07-16 Thread Philipp Zabel
This patch registers the scaler device using the IC post-processing task,
to be handled by a mem2mem scaler driver.

Signed-off-by: Philipp Zabel 
---
 drivers/gpu/ipu-v3/ipu-common.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 6d2f39d..9846cec 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -1026,6 +1026,8 @@ static const struct ipu_platform_reg client_reg[] = {
},
.reg_offset = IPU_CM_CSI1_REG_OFS,
.name = "imx-ipuv3-camera",
+   }, {
+   .name = "imx-ipuv3-scaler",
},
 };
 
-- 
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/3] [media] coda: make NV12 format default

2015-07-16 Thread Philipp Zabel
The chroma interleaved NV12 format has higher memory bandwidth efficiency
because the chroma planes can be read/written with longer burst lengths.
Use NV12 as default format if available and consistently sort it first.

This patch also shortens the NV12 format name to fit into the fixed
length string.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-common.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index d62b828..04310cd 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -90,17 +90,17 @@ void coda_write_base(struct coda_ctx *ctx, struct 
coda_q_data *q_data,
u32 base_cb, base_cr;
 
switch (q_data->fourcc) {
-   case V4L2_PIX_FMT_YVU420:
-   /* Switch Cb and Cr for YVU420 format */
-   base_cr = base_y + q_data->bytesperline * q_data->height;
-   base_cb = base_cr + q_data->bytesperline * q_data->height / 4;
-   break;
-   case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_NV12:
+   case V4L2_PIX_FMT_YUV420:
default:
base_cb = base_y + q_data->bytesperline * q_data->height;
base_cr = base_cb + q_data->bytesperline * q_data->height / 4;
break;
+   case V4L2_PIX_FMT_YVU420:
+   /* Switch Cb and Cr for YVU420 format */
+   base_cr = base_y + q_data->bytesperline * q_data->height;
+   base_cb = base_cr + q_data->bytesperline * q_data->height / 4;
+   break;
case V4L2_PIX_FMT_YUV422P:
base_cb = base_y + q_data->bytesperline * q_data->height;
base_cr = base_cb + q_data->bytesperline * q_data->height / 2;
@@ -156,9 +156,9 @@ static const struct coda_video_device coda_bit_encoder = {
.type = CODA_INST_ENCODER,
.ops = &coda_bit_encode_ops,
.src_formats = {
+   V4L2_PIX_FMT_NV12,
V4L2_PIX_FMT_YUV420,
V4L2_PIX_FMT_YVU420,
-   V4L2_PIX_FMT_NV12,
},
.dst_formats = {
V4L2_PIX_FMT_H264,
@@ -171,9 +171,9 @@ static const struct coda_video_device coda_bit_jpeg_encoder 
= {
.type = CODA_INST_ENCODER,
.ops = &coda_bit_encode_ops,
.src_formats = {
+   V4L2_PIX_FMT_NV12,
V4L2_PIX_FMT_YUV420,
V4L2_PIX_FMT_YVU420,
-   V4L2_PIX_FMT_NV12,
V4L2_PIX_FMT_YUV422P,
},
.dst_formats = {
@@ -190,9 +190,9 @@ static const struct coda_video_device coda_bit_decoder = {
V4L2_PIX_FMT_MPEG4,
},
.dst_formats = {
+   V4L2_PIX_FMT_NV12,
V4L2_PIX_FMT_YUV420,
V4L2_PIX_FMT_YVU420,
-   V4L2_PIX_FMT_NV12,
},
 };
 
@@ -204,9 +204,9 @@ static const struct coda_video_device coda_bit_jpeg_decoder 
= {
V4L2_PIX_FMT_JPEG,
},
.dst_formats = {
+   V4L2_PIX_FMT_NV12,
V4L2_PIX_FMT_YUV420,
V4L2_PIX_FMT_YVU420,
-   V4L2_PIX_FMT_NV12,
V4L2_PIX_FMT_YUV422P,
},
 };
@@ -234,9 +234,9 @@ static const struct coda_video_device 
*coda9_video_devices[] = {
 static u32 coda_format_normalize_yuv(u32 fourcc)
 {
switch (fourcc) {
+   case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
-   case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_YUV422P:
return V4L2_PIX_FMT_YUV420;
default:
@@ -448,9 +448,9 @@ static int coda_try_fmt(struct coda_ctx *ctx, const struct 
coda_codec *codec,
  S_ALIGN);
 
switch (f->fmt.pix.pixelformat) {
+   case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
-   case V4L2_PIX_FMT_NV12:
/*
 * Frame stride must be at least multiple of 8,
 * but multiple of 16 for h.264 or JPEG 4:2:x
@@ -1099,8 +1099,8 @@ static void set_default_params(struct coda_ctx *ctx)
ctx->params.framerate = 30;
 
/* Default formats for output and input queues */
-   ctx->q_data[V4L2_M2M_SRC].fourcc = ctx->codec->src_fourcc;
-   ctx->q_data[V4L2_M2M_DST].fourcc = ctx->codec->dst_fourcc;
+   ctx->q_data[V4L2_M2M_SRC].fourcc = ctx->cvd->src_formats[0];
+   ctx->q_data[V4L2_M2M_DST].fourcc = ctx->cvd->dst_formats[0];
ctx->q_data[V4L2_M2M_SRC].width = max_w;
ctx->q_data[V4L2_M2M_SRC].height = max_h;
ctx->q_data[V4L2_M2M_DST].width = max_w;
-- 
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/3] [media] coda: add macroblock tiling support

2015-07-16 Thread Philipp Zabel
From: Philipp Zabel 

Storing internal frames in macroblock tiled order improves memory
access patterns by allowing increased burst sizes when transferring
the uncompressed macroblocks to or from main memory.
The translation logic only supports a single chroma base address,
so this is only supported for the chroma interleaved NV12 format.

Since the rotator used to copy the decoder output into the v4l2
capture buffers does not seem to support the tiled format correctly,
only enable it in the encoder for now.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/Makefile  |   2 +-
 drivers/media/platform/coda/coda-bit.c|  48 +++---
 drivers/media/platform/coda/coda-common.c |  74 +--
 drivers/media/platform/coda/coda-gdi.c| 150 ++
 drivers/media/platform/coda/coda.h|  11 +--
 drivers/media/platform/coda/coda_regs.h   |   6 ++
 6 files changed, 221 insertions(+), 70 deletions(-)
 create mode 100644 drivers/media/platform/coda/coda-gdi.c

diff --git a/drivers/media/platform/coda/Makefile 
b/drivers/media/platform/coda/Makefile
index 834e504..9342ac5 100644
--- a/drivers/media/platform/coda/Makefile
+++ b/drivers/media/platform/coda/Makefile
@@ -1,5 +1,5 @@
 ccflags-y += -I$(src)
 
-coda-objs := coda-common.o coda-bit.o coda-h264.o coda-jpeg.o
+coda-objs := coda-common.o coda-bit.o coda-gdi.o coda-h264.o coda-jpeg.o
 
 obj-$(CONFIG_VIDEO_CODA) += coda.o
diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index 46c7054..3d434a4 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -340,7 +340,6 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,
 {
struct coda_dev *dev = ctx->dev;
int width, height;
-   dma_addr_t paddr;
int ysize;
int ret;
int i;
@@ -360,7 +359,10 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,
size_t size;
char *name;
 
-   size = ysize + ysize / 2;
+   if (ctx->tiled_map_type == GDI_TILED_FRAME_MB_RASTER_MAP)
+   size = round_up(ysize, 4096) + ysize / 2;
+   else
+   size = ysize + ysize / 2;
if (ctx->codec->src_fourcc == V4L2_PIX_FMT_H264 &&
dev->devtype->product != CODA_DX6)
size += ysize / 4;
@@ -376,11 +378,23 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,
 
/* Register frame buffers in the parameter buffer */
for (i = 0; i < ctx->num_internal_frames; i++) {
-   paddr = ctx->internal_frames[i].paddr;
+   u32 y, cb, cr;
+
/* Start addresses of Y, Cb, Cr planes */
-   coda_parabuf_write(ctx, i * 3 + 0, paddr);
-   coda_parabuf_write(ctx, i * 3 + 1, paddr + ysize);
-   coda_parabuf_write(ctx, i * 3 + 2, paddr + ysize + ysize / 4);
+   y = ctx->internal_frames[i].paddr;
+   cb = y + ysize;
+   cr = y + ysize + ysize/4;
+   if (ctx->tiled_map_type == GDI_TILED_FRAME_MB_RASTER_MAP) {
+   cb = round_up(cb, 4096);
+   cr = 0;
+   /* Packed 20-bit MSB of base addresses */
+   /* YCCC, CCyc,  */
+   y = (y & 0xf000) | cb >> 20;
+   cb = (cb & 0x000ff000) << 12;
+   }
+   coda_parabuf_write(ctx, i * 3 + 0, y);
+   coda_parabuf_write(ctx, i * 3 + 1, cb);
+   coda_parabuf_write(ctx, i * 3 + 2, cr);
 
/* mvcol buffer for h.264 */
if (ctx->codec->src_fourcc == V4L2_PIX_FMT_H264 &&
@@ -725,9 +739,15 @@ static void coda9_set_frame_cache(struct coda_ctx *ctx, 
u32 fourcc)
 {
u32 cache_size, cache_config;
 
-   /* Luma 2x0 page, 2x6 cache, chroma 2x0 page, 2x4 cache size */
-   cache_size = 0x20262024;
-   cache_config = 2 << CODA9_CACHE_PAGEMERGE_OFFSET;
+   if (ctx->tiled_map_type == GDI_LINEAR_FRAME_MAP) {
+   /* Luma 2x0 page, 2x6 cache, chroma 2x0 page, 2x4 cache size */
+   cache_size = 0x20262024;
+   cache_config = 2 << CODA9_CACHE_PAGEMERGE_OFFSET;
+   } else {
+   /* Luma 0x2 page, 4x4 cache, chroma 0x2 page, 4x3 cache size */
+   cache_size = 0x02440243;
+   cache_config = 1 << CODA9_CACHE_PAGEMERGE_OFFSET;
+   }
coda_write(ctx->dev, cache_size, CODA9_CMD_SET_FRAME_CACHE_SIZE);
if (fourcc == V4L2_PIX_FMT_NV12) {
cache_config |= 32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET |
@@ -818,9 +838,12 @@ static int coda_start_encoding(struct coda_ctx *ctx)
break;
}
 
-   ctx->frame_mem_ctrl &= ~CODA_FRAME_CHROMA_INTERLEAVE;
+   ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 << 

[PATCH 1/3] [media] coda: move cache setup into coda9_set_frame_cache, also use it in start_encoding

2015-07-16 Thread Philipp Zabel
The frame cache should be set up correctly to encode NV12 source frames.
This was not done before, so move the cache setup out of start_decoding
into its own function and call it from both start_encoding and
start_decoding.

Signed-off-by: Philipp Zabel 
---
 drivers/media/platform/coda/coda-bit.c | 45 +++---
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/coda/coda-bit.c 
b/drivers/media/platform/coda/coda-bit.c
index b14affc..46c7054 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -721,6 +721,26 @@ err_clk_per:
return ret;
 }
 
+static void coda9_set_frame_cache(struct coda_ctx *ctx, u32 fourcc)
+{
+   u32 cache_size, cache_config;
+
+   /* Luma 2x0 page, 2x6 cache, chroma 2x0 page, 2x4 cache size */
+   cache_size = 0x20262024;
+   cache_config = 2 << CODA9_CACHE_PAGEMERGE_OFFSET;
+   coda_write(ctx->dev, cache_size, CODA9_CMD_SET_FRAME_CACHE_SIZE);
+   if (fourcc == V4L2_PIX_FMT_NV12) {
+   cache_config |= 32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET |
+   16 << CODA9_CACHE_CR_BUFFER_SIZE_OFFSET |
+   0 << CODA9_CACHE_CB_BUFFER_SIZE_OFFSET;
+   } else {
+   cache_config |= 32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET |
+   8 << CODA9_CACHE_CR_BUFFER_SIZE_OFFSET |
+   8 << CODA9_CACHE_CB_BUFFER_SIZE_OFFSET;
+   }
+   coda_write(ctx->dev, cache_config, CODA9_CMD_SET_FRAME_CACHE_CONFIG);
+}
+
 /*
  * Encoder context operations
  */
@@ -1049,6 +1069,8 @@ static int coda_start_encoding(struct coda_ctx *ctx)
coda_write(dev, ctx->iram_info.buf_btp_use,
CODA9_CMD_SET_FRAME_AXI_BTP_ADDR);
 
+   coda9_set_frame_cache(ctx, q_data_src->fourcc);
+
/* FIXME */
coda_write(dev, ctx->internal_frames[2].paddr,
   CODA9_CMD_SET_FRAME_SUBSAMP_A);
@@ -1606,30 +1628,13 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
CODA7_CMD_SET_FRAME_AXI_DBKC_ADDR);
coda_write(dev, ctx->iram_info.buf_ovl_use,
CODA7_CMD_SET_FRAME_AXI_OVL_ADDR);
-   if (dev->devtype->product == CODA_960)
+   if (dev->devtype->product == CODA_960) {
coda_write(dev, ctx->iram_info.buf_btp_use,
CODA9_CMD_SET_FRAME_AXI_BTP_ADDR);
-   }
-
-   if (dev->devtype->product == CODA_960) {
-   int cbb_size, crb_size;
-
-   coda_write(dev, -1, CODA9_CMD_SET_FRAME_DELAY);
-   /* Luma 2x0 page, 2x6 cache, chroma 2x0 page, 2x4 cache size */
-   coda_write(dev, 0x20262024, CODA9_CMD_SET_FRAME_CACHE_SIZE);
 
-   if (dst_fourcc == V4L2_PIX_FMT_NV12) {
-   cbb_size = 0;
-   crb_size = 16;
-   } else {
-   cbb_size = 8;
-   crb_size = 8;
+   coda_write(dev, -1, CODA9_CMD_SET_FRAME_DELAY);
+   coda9_set_frame_cache(ctx, dst_fourcc);
}
-   coda_write(dev, 2 << CODA9_CACHE_PAGEMERGE_OFFSET |
-   32 << CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET |
-   cbb_size << CODA9_CACHE_CB_BUFFER_SIZE_OFFSET |
-   crb_size << CODA9_CACHE_CR_BUFFER_SIZE_OFFSET,
-   CODA9_CMD_SET_FRAME_CACHE_CONFIG);
}
 
if (src_fourcc == V4L2_PIX_FMT_H264) {
-- 
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 0/2] omap3isp: Remove legacy platform data support

2015-07-16 Thread Sakari Ailus
Laurent Pinchart wrote:
> Hello,
> 
> Now that all users of the OMAP3 ISP have switched to DT, this patch series
> removes support for legacy platform data support in the omap3isp driver. It
> also drops the OMAP3 ISP device instantiation board code that is now unused.
> 
> Patch 2/2 depends on 1/2. From a conflict resolution point of view it would be
> easier to merge the whole series through the linux-media tree. Tony, would
> that be fine with you ? If so could you please ack patch 1/2 ?
> 
> Laurent Pinchart (2):
>   ARM: OMAP2+: Remove legacy OMAP3 ISP instantiation
>   v4l: omap3isp: Drop platform data support
> 
>  arch/arm/mach-omap2/devices.c   |  53 --
>  arch/arm/mach-omap2/devices.h   |  19 
>  drivers/media/platform/Kconfig  |   2 +-
>  drivers/media/platform/omap3isp/isp.c   | 133 ---
>  drivers/media/platform/omap3isp/isp.h   |   7 +-
>  drivers/media/platform/omap3isp/ispcsiphy.h |   2 +-
>  drivers/media/platform/omap3isp/ispvideo.c  |   9 +-
>  drivers/media/platform/omap3isp/omap3isp.h  | 132 +++
>  include/media/omap3isp.h| 158 
> 
>  9 files changed, 158 insertions(+), 357 deletions(-)
>  delete mode 100644 arch/arm/mach-omap2/devices.h
>  create mode 100644 drivers/media/platform/omap3isp/omap3isp.h
>  delete mode 100644 include/media/omap3isp.h

For the set:

Acked-by: Sakari Ailus 

-- 
Sakari Ailus
sakari.ai...@iki.fi
--
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] coda: Use S_PARM to set nominal framerate for h.264 encoder

2015-07-16 Thread Philipp Zabel
The encoder needs to know the nominal framerate for the constant bitrate
control mechanism to work. Currently the only way to set the framerate is
by using VIDIOC_S_PARM on the output queue.

Signed-off-by: Philipp Zabel 
---
Changes since v1:
 - Fixed typo in coda_g_parm
---
 drivers/media/platform/coda/coda-common.c | 102 ++
 drivers/media/platform/coda/coda_regs.h   |   4 ++
 2 files changed, 106 insertions(+)

diff --git a/drivers/media/platform/coda/coda-common.c 
b/drivers/media/platform/coda/coda-common.c
index 367b6ba..5290313 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -770,6 +771,104 @@ static int coda_decoder_cmd(struct file *file, void *fh,
return 0;
 }
 
+static int coda_g_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
+{
+   struct coda_ctx *ctx = fh_to_ctx(fh);
+   struct v4l2_fract *tpf;
+
+   if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
+   tpf = &a->parm.output.timeperframe;
+   tpf->denominator = ctx->params.framerate & CODA_FRATE_RES_MASK;
+   tpf->numerator = 1 + (ctx->params.framerate >>
+ CODA_FRATE_DIV_OFFSET);
+
+   return 0;
+}
+
+/*
+ * Approximate timeperframe v4l2_fract with values that can be written
+ * into the 16-bit CODA_FRATE_DIV and CODA_FRATE_RES fields.
+ */
+static void coda_approximate_timeperframe(struct v4l2_fract *timeperframe)
+{
+   struct v4l2_fract s = *timeperframe;
+   struct v4l2_fract f0;
+   struct v4l2_fract f1 = { 1, 0 };
+   struct v4l2_fract f2 = { 0, 1 };
+   unsigned int i, div, s_denominator;
+
+   /* Lower bound is 1/65535 */
+   if (s.numerator == 0 || s.denominator / s.numerator > 65535) {
+   timeperframe->numerator = 1;
+   timeperframe->denominator = 65535;
+   return;
+   }
+
+   /* Upper bound is 65536/1, map everything above to infinity */
+   if (s.denominator == 0 || s.numerator / s.denominator > 65536) {
+   timeperframe->numerator = 1;
+   timeperframe->denominator = 0;
+   return;
+   }
+
+   /* Reduce fraction to lowest terms */
+   div = gcd(s.numerator, s.denominator);
+   if (div > 1) {
+   s.numerator /= div;
+   s.denominator /= div;
+   }
+
+   if (s.numerator <= 65536 && s.denominator < 65536) {
+   *timeperframe = s;
+   return;
+   }
+
+   /* Find successive convergents from continued fraction expansion */
+   while (f2.numerator <= 65536 && f2.denominator < 65536) {
+   f0 = f1;
+   f1 = f2;
+
+   /* Stop when f2 exactly equals timeperframe */
+   if (s.numerator == 0)
+   break;
+
+   i = s.denominator / s.numerator;
+
+   f2.numerator = f0.numerator + i * f1.numerator;
+   f2.denominator = f0.denominator + i * f2.denominator;
+
+   s_denominator = s.numerator;
+   s.numerator = s.denominator % s.numerator;
+   s.denominator = s_denominator;
+   }
+
+   *timeperframe = f1;
+}
+
+static uint32_t coda_timeperframe_to_frate(struct v4l2_fract *timeperframe)
+{
+   return ((timeperframe->numerator - 1) << CODA_FRATE_DIV_OFFSET) |
+   timeperframe->denominator;
+}
+
+static int coda_s_parm(struct file *file, void *fh, struct v4l2_streamparm *a)
+{
+   struct coda_ctx *ctx = fh_to_ctx(fh);
+   struct v4l2_fract *tpf;
+
+   if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   return -EINVAL;
+
+   tpf = &a->parm.output.timeperframe;
+   coda_approximate_timeperframe(tpf);
+   ctx->params.framerate = coda_timeperframe_to_frate(tpf);
+
+   return 0;
+}
+
 static int coda_subscribe_event(struct v4l2_fh *fh,
const struct v4l2_event_subscription *sub)
 {
@@ -810,6 +909,9 @@ static const struct v4l2_ioctl_ops coda_ioctl_ops = {
.vidioc_try_decoder_cmd = coda_try_decoder_cmd,
.vidioc_decoder_cmd = coda_decoder_cmd,
 
+   .vidioc_g_parm  = coda_g_parm,
+   .vidioc_s_parm  = coda_s_parm,
+
.vidioc_subscribe_event = coda_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
diff --git a/drivers/media/platform/coda/coda_regs.h 
b/drivers/media/platform/coda/coda_regs.h
index 7d02624..00e4f51 100644
--- a/drivers/media/platform/coda/coda_regs.h
+++ b/drivers/media/platform/coda/coda_regs.h
@@ -263,6 +263,10 @@
 #defineCODADX6_PICHEIGHT_MASK  0x3ff
 #defineCODA7_PICHEIGHT_MASK0x
 #define CODA_CMD_ENC_SEQ_SRC_F_RATE

Re: [PATCH 1/2] ARM: OMAP2+: Remove legacy OMAP3 ISP instantiation

2015-07-16 Thread Sakari Ailus
Laurent Pinchart wrote:
> Hi Sakari,
> 
> On Thursday 16 July 2015 18:45:22 Sakari Ailus wrote:
>> Laurent Pinchart wrote:
>>> The OMAP3 ISP is now fully supported in DT, remove its instantiation
>>> from C code.
>>>
>>> Signed-off-by: Laurent Pinchart 
>>> ---
>>>
>>>  arch/arm/mach-omap2/devices.c | 53 --
>>>  arch/arm/mach-omap2/devices.h | 19 
>>>  2 files changed, 72 deletions(-)
>>>  delete mode 100644 arch/arm/mach-omap2/devices.h
>>
>> If you remove the definitions, arch/arm/mach-omap2/board-cm-t35.c will
>> no longer compile. Could you remove the camera support there as well?
>>
>> My understanding is the board might be supported in DT but I'm not sure
>> about camera.
>>
>> Cc Mike and Igor.
> 
> commit 11cd7b8c2773d01e4b40e38568ae62c471a2ea10
> Author: Tony Lindgren 
> Date:   Mon May 4 10:48:07 2015 -0700
> 
> ARM: OMAP2+: Remove legacy booting support for cm-t35
> 
> 
> Merged in v4.2-rc1 :-)

Oh, I missed that one. Good!

-- 
Sakari Ailus
sakari.ai...@iki.fi
--
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 1/2] ARM: OMAP2+: Remove legacy OMAP3 ISP instantiation

2015-07-16 Thread Laurent Pinchart
Hi Sakari,

On Thursday 16 July 2015 18:45:22 Sakari Ailus wrote:
> Laurent Pinchart wrote:
> > The OMAP3 ISP is now fully supported in DT, remove its instantiation
> > from C code.
> > 
> > Signed-off-by: Laurent Pinchart 
> > ---
> > 
> >  arch/arm/mach-omap2/devices.c | 53 --
> >  arch/arm/mach-omap2/devices.h | 19 
> >  2 files changed, 72 deletions(-)
> >  delete mode 100644 arch/arm/mach-omap2/devices.h
> 
> If you remove the definitions, arch/arm/mach-omap2/board-cm-t35.c will
> no longer compile. Could you remove the camera support there as well?
> 
> My understanding is the board might be supported in DT but I'm not sure
> about camera.
> 
> Cc Mike and Igor.

commit 11cd7b8c2773d01e4b40e38568ae62c471a2ea10
Author: Tony Lindgren 
Date:   Mon May 4 10:48:07 2015 -0700

ARM: OMAP2+: Remove legacy booting support for cm-t35


Merged in v4.2-rc1 :-)

-- 
Regards,

Laurent Pinchart

--
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 1/2] ARM: OMAP2+: Remove legacy OMAP3 ISP instantiation

2015-07-16 Thread Sakari Ailus
Hi Laurent,

Laurent Pinchart wrote:
> The OMAP3 ISP is now fully supported in DT, remove its instantiation
> from C code.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  arch/arm/mach-omap2/devices.c | 53 
> ---
>  arch/arm/mach-omap2/devices.h | 19 
>  2 files changed, 72 deletions(-)
>  delete mode 100644 arch/arm/mach-omap2/devices.h

If you remove the definitions, arch/arm/mach-omap2/board-cm-t35.c will
no longer compile. Could you remove the camera support there as well?

My understanding is the board might be supported in DT but I'm not sure
about camera.

Cc Mike and Igor.

-- 
Regards,

Sakari Ailus
sakari.ai...@iki.fi
--
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 1/1] omap3isp: Fix async notifier registration order

2015-07-16 Thread Timur Tabi

Laurent Pinchart wrote:

IS_ENABLED(CONFIG_OF) can be evaluated at compile time, so it will allow the
compiler to remove the code block completely when OF support is disabled.
pdev->dev.of_node is a runtime-only check which would allow the same
optimization.


Ok, thanks.  I was thinking that there was more to it than just 
optimization, but I guess not.


--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
--
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: [PATCHv7 14/15] cec: s5p-cec: Add s5p-cec driver

2015-07-16 Thread Hans Verkuil
Marek, Kamil,



On 06/29/15 12:14, Hans Verkuil wrote:
> From: Kamil Debski 
> 
> Add CEC interface driver present in the Samsung Exynos range of
> SoCs.
> 
> The following files were based on work by SangPil Moon:
> - exynos_hdmi_cec.h
> - exynos_hdmi_cecctl.c
> 
> Signed-off-by: Kamil Debski 
> Signed-off-by: Hans Verkuil 
> ---



> diff --git a/drivers/media/platform/s5p-cec/s5p_cec.c 
> b/drivers/media/platform/s5p-cec/s5p_cec.c
> new file mode 100644
> index 000..0f16d00
> --- /dev/null
> +++ b/drivers/media/platform/s5p-cec/s5p_cec.c
> @@ -0,0 +1,283 @@
> +/* drivers/media/platform/s5p-cec/s5p_cec.c
> + *
> + * Samsung S5P CEC driver
> + *
> + * Copyright (c) 2014 Samsung Electronics Co., Ltd.
> + *
> + * 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 driver is based on the "cec interface driver for exynos soc" by
> + * SangPil Moon.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "exynos_hdmi_cec.h"
> +#include "regs-cec.h"
> +#include "s5p_cec.h"
> +
> +#define CEC_NAME "s5p-cec"
> +
> +static int debug;
> +module_param(debug, int, 0644);
> +MODULE_PARM_DESC(debug, "debug level (0-2)");
> +
> +static int s5p_cec_enable(struct cec_adapter *adap, bool enable)
> +{
> + struct s5p_cec_dev *cec = container_of(adap, struct s5p_cec_dev, adap);
> + int ret;
> +
> + if (enable) {
> + ret = pm_runtime_get_sync(cec->dev);
> +
> + adap->phys_addr = 0x100b;

This is a bogus physical address. The actual physical address has to be derived
from the EDID that is read by the HDMI transmitter.

I think in the case of this driver it will have to be userspace that assigns
the physical address after reading the EDID from drm/kms?

How did you test this, Kamil?

Regards,

Hans

> + s5p_cec_reset(cec);
> +
> + s5p_cec_set_divider(cec);
> + s5p_cec_threshold(cec);
> +
> + s5p_cec_unmask_tx_interrupts(cec);
> + s5p_cec_unmask_rx_interrupts(cec);
> + s5p_cec_enable_rx(cec);
> + } else {
> + s5p_cec_mask_tx_interrupts(cec);
> + s5p_cec_mask_rx_interrupts(cec);
> + pm_runtime_disable(cec->dev);
> + }
> +
> + return 0;
> +}
> +
> +static int s5p_cec_log_addr(struct cec_adapter *adap, u8 addr)
> +{
> + struct s5p_cec_dev *cec = container_of(adap, struct s5p_cec_dev, adap);
> +
> + s5p_cec_set_addr(cec, addr);
> + return 0;
> +}
> +
> +static int s5p_cec_transmit(struct cec_adapter *adap, struct cec_msg *msg)
> +{
> + struct s5p_cec_dev *cec = container_of(adap, struct s5p_cec_dev, adap);
> +
> + s5p_cec_copy_packet(cec, msg->msg, msg->len);
> + return 0;
> +}
> +
> +static void s5p_cec_transmit_timed_out(struct cec_adapter *adap)
> +{
> +
> +}
> +
> +static irqreturn_t s5p_cec_irq_handler(int irq, void *priv)
> +{
> + struct s5p_cec_dev *cec = priv;
> + u32 status = 0;
> +
> + status = s5p_cec_get_status(cec);
> +
> + dev_dbg(cec->dev, "irq received\n");
> +
> + if (status & CEC_STATUS_TX_DONE) {
> + if (status & CEC_STATUS_TX_ERROR) {
> + dev_dbg(cec->dev, "CEC_STATUS_TX_ERROR set\n");
> + cec->tx = STATE_ERROR;
> + } else {
> + dev_dbg(cec->dev, "CEC_STATUS_TX_DONE\n");
> + cec->tx = STATE_DONE;
> + }
> + s5p_clr_pending_tx(cec);
> + }
> +
> + if (status & CEC_STATUS_RX_DONE) {
> + if (status & CEC_STATUS_RX_ERROR) {
> + dev_dbg(cec->dev, "CEC_STATUS_RX_ERROR set\n");
> + s5p_cec_rx_reset(cec);
> + s5p_cec_enable_rx(cec);
> + } else {
> + dev_dbg(cec->dev, "CEC_STATUS_RX_DONE set\n");
> + if (cec->rx != STATE_IDLE)
> + dev_dbg(cec->dev, "Buffer overrun (worker did 
> not process previous message)\n");
> + cec->rx = STATE_BUSY;
> + cec->msg.len = status >> 24;
> + cec->msg.status = CEC_RX_STATUS_READY;
> + s5p_cec_get_rx_buf(cec, cec->msg.len,
> + cec->msg.msg);
> + cec->rx = STATE_DONE;
> + s5p_cec_enable_rx(cec);
> + }
> + /* Clear interrupt pending bit */
> + s5p_clr_pending_rx(cec);
> + }
> + return IRQ_WAKE_THREAD;
> +}
> +
> +static irqreturn_t s5p_cec_irq_handler_thread(int irq, void *priv)
> +{
> + struct s5p_cec_dev *cec = priv;
> +
> + dev_dbg(cec->dev, "irq pro

Re: [PATCH 1/2] ARM: OMAP2+: Remove legacy OMAP3 ISP instantiation

2015-07-16 Thread Tony Lindgren
* Laurent Pinchart  [150716 05:57]:
> The OMAP3 ISP is now fully supported in DT, remove its instantiation
> from C code.

Please feel to queue this along with the second patch in this series,
this should not cause any merge conflicts:

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


[PATCH 1/2] ARM: OMAP2+: Remove legacy OMAP3 ISP instantiation

2015-07-16 Thread Laurent Pinchart
The OMAP3 ISP is now fully supported in DT, remove its instantiation
from C code.

Signed-off-by: Laurent Pinchart 
---
 arch/arm/mach-omap2/devices.c | 53 ---
 arch/arm/mach-omap2/devices.h | 19 
 2 files changed, 72 deletions(-)
 delete mode 100644 arch/arm/mach-omap2/devices.h

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index a69bd67e9028..9374da313e8e 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -33,7 +33,6 @@
 #include "common.h"
 #include "mux.h"
 #include "control.h"
-#include "devices.h"
 #include "display.h"
 
 #define L3_MODULES_MAX_LEN 12
@@ -67,58 +66,6 @@ static int __init omap3_l3_init(void)
 }
 omap_postcore_initcall(omap3_l3_init);
 
-#if defined(CONFIG_IOMMU_API)
-
-#include 
-
-static struct resource omap3isp_resources[] = {
-   {
-   .start  = OMAP3430_ISP_BASE,
-   .end= OMAP3430_ISP_BASE + 0x12fc,
-   .flags  = IORESOURCE_MEM,
-   },
-   {
-   .start  = OMAP3430_ISP_BASE2,
-   .end= OMAP3430_ISP_BASE2 + 0x0600,
-   .flags  = IORESOURCE_MEM,
-   },
-   {
-   .start  = 24 + OMAP_INTC_START,
-   .flags  = IORESOURCE_IRQ,
-   }
-};
-
-static struct platform_device omap3isp_device = {
-   .name   = "omap3isp",
-   .id = -1,
-   .num_resources  = ARRAY_SIZE(omap3isp_resources),
-   .resource   = omap3isp_resources,
-};
-
-static struct omap_iommu_arch_data omap3_isp_iommu = {
-   .name = "mmu_isp",
-};
-
-int omap3_init_camera(struct isp_platform_data *pdata)
-{
-   if (of_have_populated_dt())
-   omap3_isp_iommu.name = "480bd400.mmu";
-
-   omap3isp_device.dev.platform_data = pdata;
-   omap3isp_device.dev.archdata.iommu = &omap3_isp_iommu;
-
-   return platform_device_register(&omap3isp_device);
-}
-
-#else /* !CONFIG_IOMMU_API */
-
-int omap3_init_camera(struct isp_platform_data *pdata)
-{
-   return 0;
-}
-
-#endif
-
 #if defined(CONFIG_OMAP2PLUS_MBOX) || defined(CONFIG_OMAP2PLUS_MBOX_MODULE)
 static inline void __init omap_init_mbox(void)
 {
diff --git a/arch/arm/mach-omap2/devices.h b/arch/arm/mach-omap2/devices.h
deleted file mode 100644
index f61eb6e5d136..
--- a/arch/arm/mach-omap2/devices.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * arch/arm/mach-omap2/devices.h
- *
- * OMAP2 platform device setup/initialization
- *
- * 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.
- */
-
-#ifndef __ARCH_ARM_MACH_OMAP_DEVICES_H
-#define __ARCH_ARM_MACH_OMAP_DEVICES_H
-
-struct isp_platform_data;
-
-int omap3_init_camera(struct isp_platform_data *pdata);
-
-#endif
-- 
2.3.6

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


[PATCH 0/2] omap3isp: Remove legacy platform data support

2015-07-16 Thread Laurent Pinchart
Hello,

Now that all users of the OMAP3 ISP have switched to DT, this patch series
removes support for legacy platform data support in the omap3isp driver. It
also drops the OMAP3 ISP device instantiation board code that is now unused.

Patch 2/2 depends on 1/2. From a conflict resolution point of view it would be
easier to merge the whole series through the linux-media tree. Tony, would
that be fine with you ? If so could you please ack patch 1/2 ?

Laurent Pinchart (2):
  ARM: OMAP2+: Remove legacy OMAP3 ISP instantiation
  v4l: omap3isp: Drop platform data support

 arch/arm/mach-omap2/devices.c   |  53 --
 arch/arm/mach-omap2/devices.h   |  19 
 drivers/media/platform/Kconfig  |   2 +-
 drivers/media/platform/omap3isp/isp.c   | 133 ---
 drivers/media/platform/omap3isp/isp.h   |   7 +-
 drivers/media/platform/omap3isp/ispcsiphy.h |   2 +-
 drivers/media/platform/omap3isp/ispvideo.c  |   9 +-
 drivers/media/platform/omap3isp/omap3isp.h  | 132 +++
 include/media/omap3isp.h| 158 
 9 files changed, 158 insertions(+), 357 deletions(-)
 delete mode 100644 arch/arm/mach-omap2/devices.h
 create mode 100644 drivers/media/platform/omap3isp/omap3isp.h
 delete mode 100644 include/media/omap3isp.h

-- 
Regards,

Laurent Pinchart

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


[PATCH 2/2] v4l: omap3isp: Drop platform data support

2015-07-16 Thread Laurent Pinchart
Platforms using the OMAP3 ISP have all switched to DT, drop platform
data support.

Signed-off-by: Laurent Pinchart 
---
 drivers/media/platform/Kconfig  |   2 +-
 drivers/media/platform/omap3isp/isp.c   | 133 ---
 drivers/media/platform/omap3isp/isp.h   |   7 +-
 drivers/media/platform/omap3isp/ispcsiphy.h |   2 +-
 drivers/media/platform/omap3isp/ispvideo.c  |   9 +-
 drivers/media/platform/omap3isp/omap3isp.h  | 132 +++
 include/media/omap3isp.h| 158 
 7 files changed, 158 insertions(+), 285 deletions(-)
 create mode 100644 drivers/media/platform/omap3isp/omap3isp.h
 delete mode 100644 include/media/omap3isp.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f6bed197130c..ea07c6f793cb 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -86,7 +86,7 @@ config VIDEO_M32R_AR_M64278
 config VIDEO_OMAP3
tristate "OMAP 3 Camera support"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && ARCH_OMAP3
-   depends on HAS_DMA
+   depends on HAS_DMA && OF
depends on OMAP_IOMMU
select ARM_DMA_USE_IOMMU
select VIDEOBUF2_DMA_CONTIG
diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 12be830d704f..56e683b19a73 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -101,7 +101,6 @@ static const struct isp_res_mapping isp_res_maps[] = {
0x, /* csi2a, len 0x0170 */
0x0170, /* csiphy2, len 0x000c */
},
-   .syscon_offset = 0xdc,
.phy_type = ISP_PHY_TYPE_3430,
},
{
@@ -124,7 +123,6 @@ static const struct isp_res_mapping isp_res_maps[] = {
0x0570, /* csiphy1, len 0x000c */
0x05c0, /* csi2c, len 0x0040 (2nd area) */
},
-   .syscon_offset = 0x2f0,
.phy_type = ISP_PHY_TYPE_3630,
},
 };
@@ -1796,47 +1794,6 @@ static void isp_unregister_entities(struct isp_device 
*isp)
media_device_unregister(&isp->media_dev);
 }
 
-/*
- * isp_register_subdev - Register a sub-device
- * @isp: OMAP3 ISP device
- * @isp_subdev: platform data related to a sub-device
- *
- * Register an I2C sub-device which has not been registered by other
- * means (such as the Device Tree).
- *
- * Return a pointer to the sub-device if it has been successfully
- * registered, or NULL otherwise.
- */
-static struct v4l2_subdev *
-isp_register_subdev(struct isp_device *isp,
-   struct isp_platform_subdev *isp_subdev)
-{
-   struct i2c_adapter *adapter;
-   struct v4l2_subdev *sd;
-
-   if (isp_subdev->board_info == NULL)
-   return NULL;
-
-   adapter = i2c_get_adapter(isp_subdev->i2c_adapter_id);
-   if (adapter == NULL) {
-   dev_err(isp->dev,
-   "%s: Unable to get I2C adapter %d for device %s\n",
-   __func__, isp_subdev->i2c_adapter_id,
-   isp_subdev->board_info->type);
-   return NULL;
-   }
-
-   sd = v4l2_i2c_new_subdev_board(&isp->v4l2_dev, adapter,
-  isp_subdev->board_info, NULL);
-   if (sd == NULL) {
-   dev_err(isp->dev, "%s: Unable to register subdev %s\n",
-   __func__, isp_subdev->board_info->type);
-   return NULL;
-   }
-
-   return sd;
-}
-
 static int isp_link_entity(
struct isp_device *isp, struct media_entity *entity,
enum isp_interface_type interface)
@@ -1910,8 +1867,6 @@ static int isp_link_entity(
 
 static int isp_register_entities(struct isp_device *isp)
 {
-   struct isp_platform_data *pdata = isp->pdata;
-   struct isp_platform_subdev *isp_subdev;
int ret;
 
isp->media_dev.dev = isp->dev;
@@ -1968,37 +1923,6 @@ static int isp_register_entities(struct isp_device *isp)
if (ret < 0)
goto done;
 
-   /*
-* Device Tree --- the external sub-devices will be registered
-* later. The same goes for the sub-device node registration.
-*/
-   if (isp->dev->of_node)
-   return 0;
-
-   /* Register external entities */
-   for (isp_subdev = pdata ? pdata->subdevs : NULL;
-isp_subdev && isp_subdev->board_info; isp_subdev++) {
-   struct v4l2_subdev *sd;
-
-   sd = isp_register_subdev(isp, isp_subdev);
-
-   /*
-* No bus information --- this is either a flash or a
-* lens subdev.
-*/
-   if (!sd || !isp_subdev->bus)
-   continue;
-
-   sd->host_priv = isp_subdev->bus;
-
-   ret = isp_link_entity(isp, &sd->entity,
- 

Re: www.kernellabs.com Contact: Hauppauge hvr1275 TV Tuner card linux problem

2015-07-16 Thread Steven Toth
> Dear : Steven Toth
> Thanks for your professional answer
> Thanks a lot
> Best Regards

You are welcome!

>> It looks like Hauppauge have released an updated HVR-1275 card, as
>> indicated by the updated PCI-SubDevice ID 2A38. The hardware has
>> changed and the driver needs to be modified to support these changes.
>>
>> Modprobing with option=19 isn't going to help.
>
> I've reached out to Hauppauge for comment on the new H/W. Stay tuned.

A sample HVR-1275 arrived yesterday, thank you Hauppauge.

I'll add driver support for this in the coming week, DTV only, its on
my todo list.

-- 
Steven Toth - Kernel Labs
http://www.kernellabs.com
--
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 v4 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls

2015-07-16 Thread Ricardo Ribalda Delgado
Callback needed by ioctl VIDIOC_G_DEF_EXT_CTRLS as this driver does not
use the controller framework.

Signed-off-by: Ricardo Ribalda Delgado 
---
Changelog

v4: Comments by Laurent Pinchart 
Remove unneeded  uvc_ctrl_begin()


 drivers/media/usb/uvc/uvc_v4l2.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 2764f43607c1..7ec7d45b24ed 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -1001,6 +1001,31 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void 
*fh,
return uvc_ctrl_rollback(handle);
 }
 
+static int uvc_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
+struct v4l2_ext_controls *ctrls)
+{
+   struct uvc_fh *handle = fh;
+   struct uvc_video_chain *chain = handle->chain;
+   struct v4l2_ext_control *ctrl = ctrls->controls;
+   unsigned int i;
+   int ret;
+   struct v4l2_queryctrl qc;
+
+   for (i = 0; i < ctrls->count; ++ctrl, ++i) {
+   qc.id = ctrl->id;
+   ret = uvc_query_v4l2_ctrl(chain, &qc);
+   if (ret < 0) {
+   ctrls->error_idx = i;
+   return ret;
+   }
+   ctrl->value = qc.default_value;
+   }
+
+   ctrls->error_idx = 0;
+
+   return 0;
+}
+
 static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
 struct v4l2_ext_controls *ctrls,
 bool commit)
@@ -1500,6 +1525,7 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = {
.vidioc_g_ctrl = uvc_ioctl_g_ctrl,
.vidioc_s_ctrl = uvc_ioctl_s_ctrl,
.vidioc_g_ext_ctrls = uvc_ioctl_g_ext_ctrls,
+   .vidioc_g_def_ext_ctrls = uvc_ioctl_g_def_ext_ctrls,
.vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls,
.vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls,
.vidioc_querymenu = uvc_ioctl_querymenu,
-- 
2.1.4

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


Re: [RFC v3 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls

2015-07-16 Thread Ricardo Ribalda Delgado
Hello Laurent

On Thu, Jul 16, 2015 at 10:27 AM, Laurent Pinchart
 wrote:

> I'd argue that even just two drivers would be enough :-) Especially given that
> the proposed implementation for uvcvideo is wrong.

This is why we have the review process :P. I do my best, but you are
the expert on your driver.

A core implementation cannot be completely correct, as it will not
support array controls.

I will resend this patch ASAP.


Thanks for your comments!


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


Re: [RFC v3 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls

2015-07-16 Thread Hans Verkuil
On 07/16/15 10:27, Laurent Pinchart wrote:
> On Thursday 16 July 2015 10:23:03 Hans Verkuil wrote:
>> On 07/16/15 10:11, Laurent Pinchart wrote:
>>> On Thursday 16 July 2015 09:38:11 Hans Verkuil wrote:
 On 07/15/15 23:05, Laurent Pinchart wrote:
> On Friday 12 June 2015 18:46:23 Ricardo Ribalda Delgado wrote:
>> Callback needed by ioctl VIDIOC_G_DEF_EXT_CTRLS as this driver does not
>> use the controller framework.
>>
>> Signed-off-by: Ricardo Ribalda Delgado 
>> ---
>>
>>  drivers/media/usb/uvc/uvc_v4l2.c | 30 ++
>>  1 file changed, 30 insertions(+)
>>
>> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
>> b/drivers/media/usb/uvc/uvc_v4l2.c index 2764f43607c1..e2698a77138a
>> 100644
>> --- a/drivers/media/usb/uvc/uvc_v4l2.c
>> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
>> @@ -1001,6 +1001,35 @@ static int uvc_ioctl_g_ext_ctrls(struct file
>> *file, void *fh,
>>  return uvc_ctrl_rollback(handle);
>>  }
>>
>> +static int uvc_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
>> + struct v4l2_ext_controls *ctrls)
>> +{
>> +struct uvc_fh *handle = fh;
>> +struct uvc_video_chain *chain = handle->chain;
>> +struct v4l2_ext_control *ctrl = ctrls->controls;
>> +unsigned int i;
>> +int ret;
>> +struct v4l2_queryctrl qc;
>> +
>> +ret = uvc_ctrl_begin(chain);
>
> There's no need to call uvc_ctrl_begin() here (and if there was, you'd
> have to call uvc_ctrl_rollback() or uvc_ctrl_commit() before returning).
>
>> +if (ret < 0)
>> +return ret;
>> +
>> +for (i = 0; i < ctrls->count; ++ctrl, ++i) {
>> +qc.id = ctrl->id;
>> +ret = uvc_query_v4l2_ctrl(chain, &qc);
>> +if (ret < 0) {
>> +ctrls->error_idx = i;
>> +return ret;
>> +}
>> +ctrl->value = qc.default_value;
>> +}
>> +
>> +ctrls->error_idx = 0;
>> +
>> +return 0;
>> +}
>
> Instead of open-coding this in multiple drivers, how about adding a
> helper function to the core ? Something like (totally untested)

 It's only open-coded in drivers that do not use the control framework.
 For drivers that use the control framework it is completely transparent.
>>>
>>> Sure, but still, the same function is implemented several times while a
>>> single implementation could do. I'd prefer having it in the core until
>>> all (or all but one) drivers are converted to the control framework.
>>
>> There are only three drivers that need to implement this manually: uvc,
>> saa7164 and pvrusb2. That's not enough to warrant moving this into the
>> core.
> 
> I'd argue that even just two drivers would be enough :-) Especially given 
> that 
> the proposed implementation for uvcvideo is wrong.

I don't want to add code to the core to cater to exceptions.

>> One of these days I should sit down and convert saa7164 to the control
>> framework. That shouldn't be too difficult.
> 
> How about pvrusb2, is there a good reason not to use the control framework 
> there ?

Brrr. pvrusb2 exports controls (and a bunch of other things) to /sys allowing
scripts to get/set controls using cat and echo. I have no idea how to switch 
pvrusb2
to the control framework while still keeping this non-standard API.

I guess one of these days I will need to look at it, but I've been postponing it
for years now :-)

There are still a few other drivers that do not use the control framework:

saa7164, zoran, fsl-viu, omap_vout (although I hope that one can be removed),
usbvision and bcm2048 (that's a staging driver, so I can probably ignore that 
one).

pvrusb2 is actually fairly important: v4l2-subdev still has legacy ops for 
handling
controls and as long as pvrusb2 is not converted I cannot remove those ops.

Regards,

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


Re: [RFC v3 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls

2015-07-16 Thread Laurent Pinchart
On Thursday 16 July 2015 10:23:03 Hans Verkuil wrote:
> On 07/16/15 10:11, Laurent Pinchart wrote:
> > On Thursday 16 July 2015 09:38:11 Hans Verkuil wrote:
> >> On 07/15/15 23:05, Laurent Pinchart wrote:
> >>> On Friday 12 June 2015 18:46:23 Ricardo Ribalda Delgado wrote:
>  Callback needed by ioctl VIDIOC_G_DEF_EXT_CTRLS as this driver does not
>  use the controller framework.
>  
>  Signed-off-by: Ricardo Ribalda Delgado 
>  ---
>  
>   drivers/media/usb/uvc/uvc_v4l2.c | 30 ++
>   1 file changed, 30 insertions(+)
>  
>  diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
>  b/drivers/media/usb/uvc/uvc_v4l2.c index 2764f43607c1..e2698a77138a
>  100644
>  --- a/drivers/media/usb/uvc/uvc_v4l2.c
>  +++ b/drivers/media/usb/uvc/uvc_v4l2.c
>  @@ -1001,6 +1001,35 @@ static int uvc_ioctl_g_ext_ctrls(struct file
>  *file, void *fh,
>   return uvc_ctrl_rollback(handle);
>   }
>  
>  +static int uvc_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
>  + struct v4l2_ext_controls *ctrls)
>  +{
>  +struct uvc_fh *handle = fh;
>  +struct uvc_video_chain *chain = handle->chain;
>  +struct v4l2_ext_control *ctrl = ctrls->controls;
>  +unsigned int i;
>  +int ret;
>  +struct v4l2_queryctrl qc;
>  +
>  +ret = uvc_ctrl_begin(chain);
> >>> 
> >>> There's no need to call uvc_ctrl_begin() here (and if there was, you'd
> >>> have to call uvc_ctrl_rollback() or uvc_ctrl_commit() before returning).
> >>> 
>  +if (ret < 0)
>  +return ret;
>  +
>  +for (i = 0; i < ctrls->count; ++ctrl, ++i) {
>  +qc.id = ctrl->id;
>  +ret = uvc_query_v4l2_ctrl(chain, &qc);
>  +if (ret < 0) {
>  +ctrls->error_idx = i;
>  +return ret;
>  +}
>  +ctrl->value = qc.default_value;
>  +}
>  +
>  +ctrls->error_idx = 0;
>  +
>  +return 0;
>  +}
> >>> 
> >>> Instead of open-coding this in multiple drivers, how about adding a
> >>> helper function to the core ? Something like (totally untested)
> >> 
> >> It's only open-coded in drivers that do not use the control framework.
> >> For drivers that use the control framework it is completely transparent.
> > 
> > Sure, but still, the same function is implemented several times while a
> > single implementation could do. I'd prefer having it in the core until
> > all (or all but one) drivers are converted to the control framework.
> 
> There are only three drivers that need to implement this manually: uvc,
> saa7164 and pvrusb2. That's not enough to warrant moving this into the
> core.

I'd argue that even just two drivers would be enough :-) Especially given that 
the proposed implementation for uvcvideo is wrong.

> One of these days I should sit down and convert saa7164 to the control
> framework. That shouldn't be too difficult.

How about pvrusb2, is there a good reason not to use the control framework 
there ?

-- 
Regards,

Laurent Pinchart

--
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 v3 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls

2015-07-16 Thread Hans Verkuil
On 07/16/15 10:11, Laurent Pinchart wrote:
> Hi Hans,
> 
> On Thursday 16 July 2015 09:38:11 Hans Verkuil wrote:
>> On 07/15/15 23:05, Laurent Pinchart wrote:
>>> On Friday 12 June 2015 18:46:23 Ricardo Ribalda Delgado wrote:
 Callback needed by ioctl VIDIOC_G_DEF_EXT_CTRLS as this driver does not
 use the controller framework.

 Signed-off-by: Ricardo Ribalda Delgado 
 ---

  drivers/media/usb/uvc/uvc_v4l2.c | 30 ++
  1 file changed, 30 insertions(+)

 diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
 b/drivers/media/usb/uvc/uvc_v4l2.c index 2764f43607c1..e2698a77138a
 100644
 --- a/drivers/media/usb/uvc/uvc_v4l2.c
 +++ b/drivers/media/usb/uvc/uvc_v4l2.c
 @@ -1001,6 +1001,35 @@ static int uvc_ioctl_g_ext_ctrls(struct file
 *file, void *fh,
return uvc_ctrl_rollback(handle);
  }

 +static int uvc_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
 +   struct v4l2_ext_controls *ctrls)
 +{
 +  struct uvc_fh *handle = fh;
 +  struct uvc_video_chain *chain = handle->chain;
 +  struct v4l2_ext_control *ctrl = ctrls->controls;
 +  unsigned int i;
 +  int ret;
 +  struct v4l2_queryctrl qc;
 +
 +  ret = uvc_ctrl_begin(chain);
>>>
>>> There's no need to call uvc_ctrl_begin() here (and if there was, you'd
>>> have to call uvc_ctrl_rollback() or uvc_ctrl_commit() before returning).
>>>
 +  if (ret < 0)
 +  return ret;
 +
 +  for (i = 0; i < ctrls->count; ++ctrl, ++i) {
 +  qc.id = ctrl->id;
 +  ret = uvc_query_v4l2_ctrl(chain, &qc);
 +  if (ret < 0) {
 +  ctrls->error_idx = i;
 +  return ret;
 +  }
 +  ctrl->value = qc.default_value;
 +  }
 +
 +  ctrls->error_idx = 0;
 +
 +  return 0;
 +}
>>>
>>> Instead of open-coding this in multiple drivers, how about adding a helper
>>> function to the core ? Something like (totally untested)
>>
>> It's only open-coded in drivers that do not use the control framework. For
>> drivers that use the control framework it is completely transparent.
> 
> Sure, but still, the same function is implemented several times while a 
> single 
> implementation could do. I'd prefer having it in the core until all (or all 
> but one) drivers are converted to the control framework.

There are only three drivers that need to implement this manually: uvc, saa7164
and pvrusb2. That's not enough to warrant moving this into the core.

One of these days I should sit down and convert saa7164 to the control 
framework.
That shouldn't be too difficult.

Regards,

Hans

> 
>>> int v4l2_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
>>>struct v4l2_ext_controls *ctrls)
>>> {
>>> struct video_device *vdev = video_devdata(file);
>>> unsigned int i;
>>> int ret;
>>> 
>>> for (i = 0; i < ctrls->count; ++i) {
>>> struct v4l2_queryctrl qc;
>>> 
>>> qc.id = ctrl->id;
>>> ret = vdev->ioctl_ops->vidioc_queryctrl(file, fh, &qc);
>>> if (ret < 0) {
>>> ctrls->error_idx = i;
>>> return ret;
>>> }
>>> ctrls->controls[i].value = qc.default_value;
>>> }
>>> ctrls->error_idx = 0;
>>> 
>>> return 0;
>>> }
>>>
>>> The function could be called by v4l_g_def_ext_ctrls() when ops->
>>> vidioc_g_def_ext_ctrls is NULL.
> 
--
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


[GIT PULL FOR v4.3] VSP1 fixes

2015-07-16 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit 8783b9c50400c6279d7c3b716637b98e83d3c933:

  [media] SMI PCIe IR driver for DVBSky cards (2015-07-06 08:26:16 -0300)

are available in the git repository at:

  git://linuxtv.org/pinchartl/media.git vsp1/next

for you to fetch changes up to 9bb44c299a19725e3ce0a7f15521a4fea898c0dc:

  v4l: vsp1: Don't sleep in atomic context (2015-07-16 11:21:25 +0300)


Laurent Pinchart (2):
  v4l: vsp1: Fix plane stride and size checks
  v4l: vsp1: Don't sleep in atomic context

 drivers/media/platform/vsp1/vsp1_entity.c | 18 +-
 drivers/media/platform/vsp1/vsp1_entity.h |  4 ++--
 drivers/media/platform/vsp1/vsp1_video.c  |  2 +-
 3 files changed, 12 insertions(+), 12 deletions(-)

-- 
Regards,

Laurent Pinchart

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


[GIT PULL FOR v4.3] Xilinx video driver fix

2015-07-16 Thread Laurent Pinchart
Hi Mauro,

The following changes since commit 8783b9c50400c6279d7c3b716637b98e83d3c933:

  [media] SMI PCIe IR driver for DVBSky cards (2015-07-06 08:26:16 -0300)

are available in the git repository at:

  git://linuxtv.org/pinchartl/media.git xilinx/next

for you to fetch changes up to 0b35afd34edbad0ca874264110513311daa8f822:

  v4l: xilinx: missing error code (2015-07-16 10:36:47 +0300)


Dan Carpenter (1):
  v4l: xilinx: missing error code

 drivers/media/platform/xilinx/xilinx-dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
Regards,

Laurent Pinchart

--
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 v3 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls

2015-07-16 Thread Laurent Pinchart
Hi Hans,

On Thursday 16 July 2015 09:38:11 Hans Verkuil wrote:
> On 07/15/15 23:05, Laurent Pinchart wrote:
> > On Friday 12 June 2015 18:46:23 Ricardo Ribalda Delgado wrote:
> >> Callback needed by ioctl VIDIOC_G_DEF_EXT_CTRLS as this driver does not
> >> use the controller framework.
> >> 
> >> Signed-off-by: Ricardo Ribalda Delgado 
> >> ---
> >> 
> >>  drivers/media/usb/uvc/uvc_v4l2.c | 30 ++
> >>  1 file changed, 30 insertions(+)
> >> 
> >> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
> >> b/drivers/media/usb/uvc/uvc_v4l2.c index 2764f43607c1..e2698a77138a
> >> 100644
> >> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> >> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> >> @@ -1001,6 +1001,35 @@ static int uvc_ioctl_g_ext_ctrls(struct file
> >> *file, void *fh,
> >>return uvc_ctrl_rollback(handle);
> >>  }
> >> 
> >> +static int uvc_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
> >> +   struct v4l2_ext_controls *ctrls)
> >> +{
> >> +  struct uvc_fh *handle = fh;
> >> +  struct uvc_video_chain *chain = handle->chain;
> >> +  struct v4l2_ext_control *ctrl = ctrls->controls;
> >> +  unsigned int i;
> >> +  int ret;
> >> +  struct v4l2_queryctrl qc;
> >> +
> >> +  ret = uvc_ctrl_begin(chain);
> > 
> > There's no need to call uvc_ctrl_begin() here (and if there was, you'd
> > have to call uvc_ctrl_rollback() or uvc_ctrl_commit() before returning).
> > 
> >> +  if (ret < 0)
> >> +  return ret;
> >> +
> >> +  for (i = 0; i < ctrls->count; ++ctrl, ++i) {
> >> +  qc.id = ctrl->id;
> >> +  ret = uvc_query_v4l2_ctrl(chain, &qc);
> >> +  if (ret < 0) {
> >> +  ctrls->error_idx = i;
> >> +  return ret;
> >> +  }
> >> +  ctrl->value = qc.default_value;
> >> +  }
> >> +
> >> +  ctrls->error_idx = 0;
> >> +
> >> +  return 0;
> >> +}
> > 
> > Instead of open-coding this in multiple drivers, how about adding a helper
> > function to the core ? Something like (totally untested)
> 
> It's only open-coded in drivers that do not use the control framework. For
> drivers that use the control framework it is completely transparent.

Sure, but still, the same function is implemented several times while a single 
implementation could do. I'd prefer having it in the core until all (or all 
but one) drivers are converted to the control framework.

> > int v4l2_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
> >struct v4l2_ext_controls *ctrls)
> > {
> > struct video_device *vdev = video_devdata(file);
> > unsigned int i;
> > int ret;
> > 
> > for (i = 0; i < ctrls->count; ++i) {
> > struct v4l2_queryctrl qc;
> > 
> > qc.id = ctrl->id;
> > ret = vdev->ioctl_ops->vidioc_queryctrl(file, fh, &qc);
> > if (ret < 0) {
> > ctrls->error_idx = i;
> > return ret;
> > }
> > ctrls->controls[i].value = qc.default_value;
> > }
> > ctrls->error_idx = 0;
> > 
> > return 0;
> > }
> > 
> > The function could be called by v4l_g_def_ext_ctrls() when ops->
> > vidioc_g_def_ext_ctrls is NULL.

-- 
Regards,

Laurent Pinchart

--
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 v3 04/19] media/usb/uvc: Implement vivioc_g_def_ext_ctrls

2015-07-16 Thread Hans Verkuil
On 07/15/15 23:05, Laurent Pinchart wrote:
> Hi Ricardo,
> 
> Thank you for the patch.
> 
> On Friday 12 June 2015 18:46:23 Ricardo Ribalda Delgado wrote:
>> Callback needed by ioctl VIDIOC_G_DEF_EXT_CTRLS as this driver does not
>> use the controller framework.
>>
>> Signed-off-by: Ricardo Ribalda Delgado 
>> ---
>>  drivers/media/usb/uvc/uvc_v4l2.c | 30 ++
>>  1 file changed, 30 insertions(+)
>>
>> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c
>> b/drivers/media/usb/uvc/uvc_v4l2.c index 2764f43607c1..e2698a77138a 100644
>> --- a/drivers/media/usb/uvc/uvc_v4l2.c
>> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
>> @@ -1001,6 +1001,35 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file,
>> void *fh, return uvc_ctrl_rollback(handle);
>>  }
>>
>> +static int uvc_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
>> + struct v4l2_ext_controls *ctrls)
>> +{
>> +struct uvc_fh *handle = fh;
>> +struct uvc_video_chain *chain = handle->chain;
>> +struct v4l2_ext_control *ctrl = ctrls->controls;
>> +unsigned int i;
>> +int ret;
>> +struct v4l2_queryctrl qc;
>> +
>> +ret = uvc_ctrl_begin(chain);
> 
> There's no need to call uvc_ctrl_begin() here (and if there was, you'd have 
> to 
> call uvc_ctrl_rollback() or uvc_ctrl_commit() before returning).
> 
>> +if (ret < 0)
>> +return ret;
>> +
>> +for (i = 0; i < ctrls->count; ++ctrl, ++i) {
>> +qc.id = ctrl->id;
>> +ret = uvc_query_v4l2_ctrl(chain, &qc);
>> +if (ret < 0) {
>> +ctrls->error_idx = i;
>> +return ret;
>> +}
>> +ctrl->value = qc.default_value;
>> +}
>> +
>> +ctrls->error_idx = 0;
>> +
>> +return 0;
>> +}
> 
> Instead of open-coding this in multiple drivers, how about adding a helper 
> function to the core ? Something like (totally untested)

It's only open-coded in drivers that do not use the control framework. For
drivers that use the control framework it is completely transparent.

Regards,

Hans

> 
> int v4l2_ioctl_g_def_ext_ctrls(struct file *file, void *fh,
>struct v4l2_ext_controls *ctrls)
> {
>   struct video_device *vdev = video_devdata(file);
>   unsigned int i;
>   int ret;
> 
>   for (i = 0; i < ctrls->count; ++i) {
>   struct v4l2_queryctrl qc;
> 
>   qc.id = ctrl->id;
>   ret = vdev->ioctl_ops->vidioc_queryctrl(file, fh, &qc);
>   if (ret < 0) {
>   ctrls->error_idx = i;
>   return ret;
>   }
> 
>   ctrls->controls[i].value = qc.default_value;
>   }
> 
>   ctrls->error_idx = 0;
> 
>   return 0;
> }
> 
> The function could be called by v4l_g_def_ext_ctrls() when ops-
>> vidioc_g_def_ext_ctrls is NULL.
> 
>>  static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,
>>   struct v4l2_ext_controls *ctrls,
>>   bool commit)
>> @@ -1500,6 +1529,7 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = {
>>  .vidioc_g_ctrl = uvc_ioctl_g_ctrl,
>>  .vidioc_s_ctrl = uvc_ioctl_s_ctrl,
>>  .vidioc_g_ext_ctrls = uvc_ioctl_g_ext_ctrls,
>> +.vidioc_g_def_ext_ctrls = uvc_ioctl_g_def_ext_ctrls,
>>  .vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls,
>>  .vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls,
>>  .vidioc_querymenu = uvc_ioctl_querymenu,
> 
--
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 1/1] omap3isp: Fix async notifier registration order

2015-07-16 Thread Laurent Pinchart
Hi Timur,

On Wednesday 15 July 2015 16:04:01 Timur Tabi wrote:
> On Tue, May 19, 2015 at 6:08 PM, Sakari Ailus  wrote:
> > @@ -2557,18 +2553,27 @@ static int isp_probe(struct platform_device *pdev)
> > if (ret < 0)
> > goto error_iommu;
> > 
> > -   isp->notifier.bound = isp_subdev_notifier_bound;
> > -   isp->notifier.complete = isp_subdev_notifier_complete;
> > -
> > ret = isp_register_entities(isp);
> > if (ret < 0)
> > goto error_modules;
> > 
> > +   if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
> 
> So I have a question (for Laurent, I guess) that's unrelated to this patch.
> 
> Why is the "IS_ENABLED(CONFIG_OF)" important?  If CONFIG_OF is
> disabled, isn't pdev->dev.of_node always NULL anyway?

IS_ENABLED(CONFIG_OF) can be evaluated at compile time, so it will allow the 
compiler to remove the code block completely when OF support is disabled. 
pdev->dev.of_node is a runtime-only check which would allow the same 
optimization.

-- 
Regards,

Laurent Pinchart

--
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 2/9] v4l2: add RF gain control

2015-07-16 Thread Antti Palosaari

On 06/08/2015 12:03 PM, Hans Verkuil wrote:

On 06/06/2015 02:03 PM, Antti Palosaari wrote:

Add new RF tuner gain control named RF gain. That is aimed for
external LNA (amplifier) chip just right after antenna connector.


I don't follow. Do you mean:

This feeds into the external LNA...

But if that's the case, then the LNA chip isn't right after the antenna 
connector,
since there is a RF amplified in between.


On that case, there is amplifier between antenna and tuner chip. And I 
named it as a RF gain. It is quite same thing than LNA gain, but I would 
call LNA gain as a "RF gain" inside the tuner chip - integrated into 
tuner chip. These terms are not 100% established as LNA gain and RF gain 
are considered as a same thing very often.


The fact is that almost every silicon tuner nowadays has integrated 
RF/LNA amplifier, but there is devices having still separate amplifier 
between tuner and antenna. For DVB side there is multiple such devices, 
for example PCTV 290e and PCTV 292. HackRF SDR has separate RF amplifier 
and multiple other amplifiers.


So all in all, I needed second "LNA/RF" gain control and as LNA gain was 
already defined, I defined another as a RF gain.



 RF in   ++ +-+ +---+ ++  IF out
---> | RF | --> | LNA | --> | Mixer | --> | IF | >
 ++ +-+ +---+ ++

Those boxes (RF/LNA/Mixer/IF) are gain controls and signal travels in 
order shown from gain to gain. In real life there is usually even more 
gains withing gain stage, eg. Mixer gain stage could contain 3 different 
amplifiers.



RF in = antenna input
IF out = connected to ADC (demod)


Hope the RF gain / LNA gain documentation is now a bit better.


regards
Antti

--
http://palosaari.fi/
--
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 8/9] hackrf: add support for transmitter

2015-07-16 Thread Antti Palosaari

Moikka!

On 06/08/2015 12:26 PM, Hans Verkuil wrote:

Hi Antti,

I've got one comment:

On 06/06/2015 02:03 PM, Antti Palosaari wrote:

HackRF SDR device has both receiver and transmitter. There is limitation
that receiver and transmitter cannot be used at the same time
(half-duplex operation). That patch implements transmitter support to
existing receiver only driver.

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
  drivers/media/usb/hackrf/hackrf.c | 855 --
  1 file changed, 640 insertions(+), 215 deletions(-)

diff --git a/drivers/media/usb/hackrf/hackrf.c 
b/drivers/media/usb/hackrf/hackrf.c
index 5bd291b..6ad6937 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
+/*
+ * TODO: That blocks whole transmitter device open when receiver is opened and
+ * the other way around, even only streaming is not allowed. Better solution
+ * needed...


Exactly. Why not use a similar approach as for video:

Return EBUSY when the applications tries to call:

S_FREQUENCY, S_MODULATOR, S_TUNER or REQBUFS/CREATE_BUFS and the other
vb2 queue is marked 'busy'. The check for REQBUFS/CREATE_BUFS can be done
in hackrf_queue_setup.

You should always be able to open a device node in V4L2.


It is now changed. All the other operations are allowed, but not 
streaming. Driver caches configuration values for both RX and TX mode 
and those are programmed when streaming is started.


regards
Antti

--
http://palosaari.fi/
--
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


[PATCHv2 6/9] hackrf: add control for RF amplifier

2015-07-16 Thread Antti Palosaari
There is Avago MGA-81563 amplifier just right after antenna connector.
It could be turned on/off and its gain is around 12dB.

Signed-off-by: Antti Palosaari 
---
 drivers/media/usb/hackrf/hackrf.c | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/hackrf/hackrf.c 
b/drivers/media/usb/hackrf/hackrf.c
index fd1fa41..136de9a 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -31,6 +31,7 @@ enum {
CMD_BOARD_ID_READ  = 0x0e,
CMD_VERSION_STRING_READ= 0x0f,
CMD_SET_FREQ   = 0x10,
+   CMD_AMP_ENABLE = 0x11,
CMD_SET_LNA_GAIN   = 0x13,
CMD_SET_VGA_GAIN   = 0x14,
 };
@@ -133,6 +134,7 @@ struct hackrf_dev {
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl *bandwidth_auto;
struct v4l2_ctrl *bandwidth;
+   struct v4l2_ctrl *rf_gain;
struct v4l2_ctrl *lna_gain;
struct v4l2_ctrl *if_gain;
 
@@ -164,6 +166,7 @@ static int hackrf_ctrl_msg(struct hackrf_dev *dev, u8 
request, u16 value,
switch (request) {
case CMD_SET_TRANSCEIVER_MODE:
case CMD_SET_FREQ:
+   case CMD_AMP_ENABLE:
case CMD_SAMPLE_RATE_SET:
case CMD_BASEBAND_FILTER_BANDWIDTH_SET:
pipe = usb_sndctrlpipe(dev->udev, 0);
@@ -949,6 +952,22 @@ static int hackrf_set_bandwidth(struct hackrf_dev *dev)
return ret;
 }
 
+static int hackrf_set_rf_gain(struct hackrf_dev *dev)
+{
+   int ret;
+   u8 u8tmp;
+
+   dev_dbg(dev->dev, "rf val=%d->%d\n",
+   dev->rf_gain->cur.val, dev->rf_gain->val);
+
+   u8tmp = (dev->rf_gain->val) ? 1 : 0;
+   ret = hackrf_ctrl_msg(dev, CMD_AMP_ENABLE, u8tmp, 0, NULL, 0);
+   if (ret)
+   dev_dbg(dev->dev, "failed=%d\n", ret);
+
+   return ret;
+}
+
 static int hackrf_set_lna_gain(struct hackrf_dev *dev)
 {
int ret;
@@ -992,6 +1011,9 @@ static int hackrf_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_RF_TUNER_BANDWIDTH:
ret = hackrf_set_bandwidth(dev);
break;
+   case  V4L2_CID_RF_TUNER_RF_GAIN:
+   ret = hackrf_set_rf_gain(dev);
+   break;
case  V4L2_CID_RF_TUNER_LNA_GAIN:
ret = hackrf_set_lna_gain(dev);
break;
@@ -1077,13 +1099,15 @@ static int hackrf_probe(struct usb_interface *intf,
}
 
/* Register controls */
-   v4l2_ctrl_handler_init(&dev->hdl, 4);
+   v4l2_ctrl_handler_init(&dev->hdl, 5);
dev->bandwidth_auto = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1);
dev->bandwidth = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
V4L2_CID_RF_TUNER_BANDWIDTH,
175, 2800, 5, 175);
v4l2_ctrl_auto_cluster(2, &dev->bandwidth_auto, 0, false);
+   dev->rf_gain = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
+   V4L2_CID_RF_TUNER_RF_GAIN, 0, 12, 12, 0);
dev->lna_gain = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
V4L2_CID_RF_TUNER_LNA_GAIN, 0, 40, 8, 0);
dev->if_gain = v4l2_ctrl_new_std(&dev->hdl, &hackrf_ctrl_ops,
-- 
http://palosaari.fi/

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


[PATCHv2 8/9] hackrf: add support for transmitter

2015-07-16 Thread Antti Palosaari
HackRF SDR device has both receiver and transmitter. There is limitation
that receiver and transmitter cannot be used at the same time
(half-duplex operation). That patch implements transmitter support to
existing receiver only driver.

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 drivers/media/usb/hackrf/hackrf.c | 787 +++---
 1 file changed, 572 insertions(+), 215 deletions(-)

diff --git a/drivers/media/usb/hackrf/hackrf.c 
b/drivers/media/usb/hackrf/hackrf.c
index 5bd291b..97de9cb6 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -34,6 +34,7 @@ enum {
CMD_AMP_ENABLE = 0x11,
CMD_SET_LNA_GAIN   = 0x13,
CMD_SET_VGA_GAIN   = 0x14,
+   CMD_SET_TXVGA_GAIN = 0x15,
 };
 
 /*
@@ -44,7 +45,7 @@ enum {
 #define MAX_BULK_BUFS(6)
 #define BULK_BUFFER_SIZE (128 * 512)
 
-static const struct v4l2_frequency_band bands_adc[] = {
+static const struct v4l2_frequency_band bands_adc_dac[] = {
{
.tuner = 0,
.type = V4L2_TUNER_ADC,
@@ -55,7 +56,7 @@ static const struct v4l2_frequency_band bands_adc[] = {
},
 };
 
-static const struct v4l2_frequency_band bands_rf[] = {
+static const struct v4l2_frequency_band bands_rx_tx[] = {
{
.tuner = 1,
.type = V4L2_TUNER_RF,
@@ -91,28 +92,39 @@ struct hackrf_frame_buf {
 };
 
 struct hackrf_dev {
-#define POWER_ON 1
-#define USB_STATE_URB_BUF2 /* XXX: set manually */
-#define SAMPLE_RATE_SET 10
-#define RX_BANDWIDTH11
-#define RX_RF_FREQUENCY 12
-#define RX_RF_GAIN  13
-#define RX_LNA_GAIN 14
-#define RX_IF_GAIN  15
+#define USB_STATE_URB_BUF1 /* XXX: set manually */
+#define QUEUE_SETUP  3
+#define RX_ON4
+#define TX_ON5
+#define RX_ADC_FREQUENCY11
+#define TX_DAC_FREQUENCY12
+#define RX_BANDWIDTH13
+#define TX_BANDWIDTH14
+#define RX_RF_FREQUENCY 15
+#define TX_RF_FREQUENCY 16
+#define RX_RF_GAIN  17
+#define TX_RF_GAIN  18
+#define RX_IF_GAIN  19
+#define RX_LNA_GAIN 20
+#define TX_LNA_GAIN 21
unsigned long flags;
 
struct usb_interface *intf;
struct device *dev;
struct usb_device *udev;
-   struct video_device vdev;
-   struct v4l2_device v4l2_dev;
+   struct video_device rx_vdev;
+   struct video_device tx_vdev;
+   struct v4l2_device rx_v4l2_dev;
+   struct v4l2_device tx_v4l2_dev;
 
/* videobuf2 queue and queued buffers list */
-   struct vb2_queue vb_queue;
+   struct vb2_queue rx_vb2_queue;
+   struct vb2_queue tx_vb2_queue;
struct list_head queued_bufs;
spinlock_t queued_bufs_lock; /* Protects queued_bufs */
unsigned sequence;   /* Buffer sequence counter */
unsigned int vb_full;/* vb is full and packets dropped */
+   unsigned int vb_empty;   /* vb is empty and packets dropped */
 
/* Note if taking both locks v4l2_lock must always be locked first! */
struct mutex v4l2_lock;  /* Protects everything else */
@@ -132,17 +144,24 @@ struct hackrf_dev {
 
/* Current configuration */
unsigned int f_adc;
-   unsigned int f_rf;
+   unsigned int f_dac;
+   unsigned int f_rx;
+   unsigned int f_tx;
u32 pixelformat;
u32 buffersize;
 
/* Controls */
-   struct v4l2_ctrl_handler hdl;
-   struct v4l2_ctrl *bandwidth_auto;
-   struct v4l2_ctrl *bandwidth;
-   struct v4l2_ctrl *rf_gain;
-   struct v4l2_ctrl *lna_gain;
-   struct v4l2_ctrl *if_gain;
+   struct v4l2_ctrl_handler rx_ctrl_handler;
+   struct v4l2_ctrl *rx_bandwidth_auto;
+   struct v4l2_ctrl *rx_bandwidth;
+   struct v4l2_ctrl *rx_rf_gain;
+   struct v4l2_ctrl *rx_lna_gain;
+   struct v4l2_ctrl *rx_if_gain;
+   struct v4l2_ctrl_handler tx_ctrl_handler;
+   struct v4l2_ctrl *tx_bandwidth_auto;
+   struct v4l2_ctrl *tx_bandwidth;
+   struct v4l2_ctrl *tx_rf_gain;
+   struct v4l2_ctrl *tx_lna_gain;
 
/* Sample rate calc */
unsigned long jiffies_next;
@@ -182,6 +201,7 @@ static int hackrf_ctrl_msg(struct hackrf_dev *dev, u8 
request, u16 value,
case CMD_VERSION_STRING_READ:
case CMD_SET_LNA_GAIN:
case CMD_SET_VGA_GAIN:
+   case CMD_SET_TXVGA_GAIN:
pipe = usb_rcvctrlpipe(dev->udev, 0);
requesttype = (USB_TYPE_VENDOR | USB_DIR_IN);
break;
@@ -220,16 +240,

[PATCHv2 4/9] v4l2: add support for SDR transmitter

2015-07-16 Thread Antti Palosaari
New IOCTL ops:
vidioc_enum_fmt_sdr_out
vidioc_g_fmt_sdr_out
vidioc_s_fmt_sdr_out
vidioc_try_fmt_sdr_out

New vb2 buffertype:
V4L2_BUF_TYPE_SDR_OUTPUT

New v4l2 capability:
V4L2_CAP_SDR_OUTPUT

Signed-off-by: Antti Palosaari 
Acked-by: Hans Verkuil 
---
 drivers/media/v4l2-core/v4l2-dev.c  | 14 --
 drivers/media/v4l2-core/v4l2-ioctl.c| 25 +
 drivers/media/v4l2-core/videobuf-core.c |  4 +++-
 include/media/v4l2-ioctl.h  |  8 
 include/trace/events/v4l2.h |  1 +
 include/uapi/linux/videodev2.h  |  5 -
 6 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 71a1b93..6b1eaed 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -637,8 +637,8 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
   ops->vidioc_try_fmt_sliced_vbi_out)))
set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, 
vidioc_g_sliced_vbi_cap);
-   } else if (is_sdr) {
-   /* SDR specific ioctls */
+   } else if (is_sdr && is_rx) {
+   /* SDR receiver specific ioctls */
if (ops->vidioc_enum_fmt_sdr_cap)
set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
if (ops->vidioc_g_fmt_sdr_cap)
@@ -647,6 +647,16 @@ static void determine_valid_ioctls(struct video_device 
*vdev)
set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
if (ops->vidioc_try_fmt_sdr_cap)
set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
+   } else if (is_sdr && is_tx) {
+   /* SDR transmitter specific ioctls */
+   if (ops->vidioc_enum_fmt_sdr_out)
+   set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
+   if (ops->vidioc_g_fmt_sdr_out)
+   set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
+   if (ops->vidioc_s_fmt_sdr_out)
+   set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
+   if (ops->vidioc_try_fmt_sdr_out)
+   set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
}
 
if (is_vid || is_vbi || is_sdr) {
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index ef42474..21e9598 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -154,6 +154,7 @@ const char *v4l2_type_names[] = {
[V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE] = "vid-cap-mplane",
[V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE] = "vid-out-mplane",
[V4L2_BUF_TYPE_SDR_CAPTURE]= "sdr-cap",
+   [V4L2_BUF_TYPE_SDR_OUTPUT] = "sdr-out",
 };
 EXPORT_SYMBOL(v4l2_type_names);
 
@@ -327,6 +328,7 @@ static void v4l_print_format(const void *arg, bool 
write_only)
sliced->service_lines[1][i]);
break;
case V4L2_BUF_TYPE_SDR_CAPTURE:
+   case V4L2_BUF_TYPE_SDR_OUTPUT:
sdr = &p->fmt.sdr;
pr_cont(", pixelformat=%c%c%c%c\n",
(sdr->pixelformat >>  0) & 0xff,
@@ -975,6 +977,10 @@ static int check_fmt(struct file *file, enum v4l2_buf_type 
type)
if (is_sdr && is_rx && ops->vidioc_g_fmt_sdr_cap)
return 0;
break;
+   case V4L2_BUF_TYPE_SDR_OUTPUT:
+   if (is_sdr && is_tx && ops->vidioc_g_fmt_sdr_out)
+   return 0;
+   break;
default:
break;
}
@@ -1324,6 +1330,11 @@ static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops,
break;
ret = ops->vidioc_enum_fmt_sdr_cap(file, fh, arg);
break;
+   case V4L2_BUF_TYPE_SDR_OUTPUT:
+   if (unlikely(!is_tx || !is_sdr || 
!ops->vidioc_enum_fmt_sdr_out))
+   break;
+   ret = ops->vidioc_enum_fmt_sdr_out(file, fh, arg);
+   break;
}
if (ret == 0)
v4l_fill_fmtdesc(p);
@@ -1418,6 +1429,10 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
if (unlikely(!is_rx || !is_sdr || !ops->vidioc_g_fmt_sdr_cap))
break;
return ops->vidioc_g_fmt_sdr_cap(file, fh, arg);
+   case V4L2_BUF_TYPE_SDR_OUTPUT:
+   if (unlikely(!is_tx || !is_sdr || !ops->vidioc_g_fmt_sdr_out))
+   break;
+   return ops->vidioc_g_fmt_sdr_out(file, fh, arg);
}
return -EINVAL;
 }
@@ -1497,6 +1512,11 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
break;
CLEAR_AFTER_FIELD(p, fmt.sdr);
return ops->vidioc_s_fmt_sdr_cap(file, fh, arg);
+   case V4L2_BUF_

[PATCHv2 3/9] DocBook: document tuner RF gain control

2015-07-16 Thread Antti Palosaari
Add brief description for tuner RF gain control.

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 Documentation/DocBook/media/v4l/compat.xml   |  4 
 Documentation/DocBook/media/v4l/controls.xml | 14 ++
 Documentation/DocBook/media/v4l/v4l2.xml |  1 +
 3 files changed, 19 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index f56faf5..eb091c7 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2600,6 +2600,10 @@ and &v4l2-mbus-framefmt;.
 V4L2_TUNER_ADC is deprecated now.
  

+   
+ Added V4L2_CID_RF_TUNER_RF_GAIN
+RF Tuner control.
+   
   
 
 
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 6e1667b..7cae933 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -5418,6 +5418,18 @@ set. Unit is in Hz. The range and step are 
driver-specific.
   Enables/disables IF automatic gain 
control (AGC)
 
 
+  V4L2_CID_RF_TUNER_RF_GAIN 
+  integer
+
+
+  The RF amplifier is the very first
+amplifier on the receiver signal path, just right after the antenna input.
+The difference between the LNA gain and the RF gain in this document is that
+the LNA gain is integrated in the tuner chip while the RF gain is a separate
+chip. There may be both RF and LNA gain controls in the same device.
+The range and step are driver-specific.
+
+
   V4L2_CID_RF_TUNER_LNA_GAIN 
   integer
 
@@ -5425,6 +5437,8 @@ set. Unit is in Hz. The range and step are 
driver-specific.
   LNA (low noise amplifier) gain is first
 gain stage on the RF tuner signal path. It is located very close to tuner
 antenna input. Used when V4L2_CID_RF_TUNER_LNA_GAIN_AUTO 
is not set.
+See V4L2_CID_RF_TUNER_RF_GAIN to understand how RF gain
+and LNA gain differs from the each others.
 The range and step are driver-specific.
 
 
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml 
b/Documentation/DocBook/media/v4l/v4l2.xml
index c9eedc1..ab9fca4 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -156,6 +156,7 @@ applications. -->
2015-05-26
ap
Renamed V4L2_TUNER_ADC to V4L2_TUNER_SDR.
+Added V4L2_CID_RF_TUNER_RF_GAIN control.

   
 
-- 
http://palosaari.fi/

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


[PATCHv2 9/9] hackrf: do not set human readable name for formats

2015-07-16 Thread Antti Palosaari
Format names are set by core nowadays. Remove name from driver.

Signed-off-by: Antti Palosaari 
Acked-by: Hans Verkuil 
---
 drivers/media/usb/hackrf/hackrf.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/media/usb/hackrf/hackrf.c 
b/drivers/media/usb/hackrf/hackrf.c
index 97de9cb6..b7e910e 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -69,7 +69,6 @@ static const struct v4l2_frequency_band bands_rx_tx[] = {
 
 /* stream formats */
 struct hackrf_format {
-   char*name;
u32 pixelformat;
u32 buffersize;
 };
@@ -77,7 +76,6 @@ struct hackrf_format {
 /* format descriptions for capture and preview */
 static struct hackrf_format formats[] = {
{
-   .name   = "Complex S8",
.pixelformat= V4L2_SDR_FMT_CS8,
.buffersize = BULK_BUFFER_SIZE,
},
@@ -985,7 +983,6 @@ static int hackrf_enum_fmt_sdr_cap(struct file *file, void 
*priv,
if (f->index >= NUM_FORMATS)
return -EINVAL;
 
-   strlcpy(f->description, formats[f->index].name, sizeof(f->description));
f->pixelformat = formats[f->index].pixelformat;
 
return 0;
-- 
http://palosaari.fi/

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


[PATCHv2 7/9] hackrf: switch to single function which configures everything

2015-07-16 Thread Antti Palosaari
Implement single funtion, hackrf_set_params(), which handles all
needed settings. Controls and other IOCTLs are just wrappers to that
function. That way we can get easily better control what we could do
on different device states - sleeping, receiving, transmitting.

Signed-off-by: Antti Palosaari 
---
 drivers/media/usb/hackrf/hackrf.c | 323 +-
 1 file changed, 175 insertions(+), 148 deletions(-)

diff --git a/drivers/media/usb/hackrf/hackrf.c 
b/drivers/media/usb/hackrf/hackrf.c
index 136de9a..5bd291b 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -91,11 +91,17 @@ struct hackrf_frame_buf {
 };
 
 struct hackrf_dev {
-#define POWER_ON   (1 << 1)
-#define URB_BUF(1 << 2)
-#define USB_STATE_URB_BUF  (1 << 3)
+#define POWER_ON 1
+#define USB_STATE_URB_BUF2 /* XXX: set manually */
+#define SAMPLE_RATE_SET 10
+#define RX_BANDWIDTH11
+#define RX_RF_FREQUENCY 12
+#define RX_RF_GAIN  13
+#define RX_LNA_GAIN 14
+#define RX_IF_GAIN  15
unsigned long flags;
 
+   struct usb_interface *intf;
struct device *dev;
struct usb_device *udev;
struct video_device vdev;
@@ -208,6 +214,140 @@ err:
return ret;
 }
 
+static int hackrf_set_params(struct hackrf_dev *dev)
+{
+   struct usb_interface *intf = dev->intf;
+   int ret, i;
+   u8 buf[8], u8tmp;
+   unsigned int uitmp, uitmp1, uitmp2;
+
+   if (!test_bit(POWER_ON, &dev->flags)) {
+   dev_dbg(&intf->dev, "device is sleeping\n");
+   return 0;
+   }
+
+   if (test_and_clear_bit(SAMPLE_RATE_SET, &dev->flags)) {
+   dev_dbg(&intf->dev, "ADC frequency=%u Hz\n", dev->f_adc);
+   uitmp1 = dev->f_adc;
+   uitmp2 = 1;
+   buf[0] = (uitmp1 >>  0) & 0xff;
+   buf[1] = (uitmp1 >>  8) & 0xff;
+   buf[2] = (uitmp1 >> 16) & 0xff;
+   buf[3] = (uitmp1 >> 24) & 0xff;
+   buf[4] = (uitmp2 >>  0) & 0xff;
+   buf[5] = (uitmp2 >>  8) & 0xff;
+   buf[6] = (uitmp2 >> 16) & 0xff;
+   buf[7] = (uitmp2 >> 24) & 0xff;
+   ret = hackrf_ctrl_msg(dev, CMD_SAMPLE_RATE_SET, 0, 0, buf, 8);
+   if (ret)
+   goto err;
+   }
+
+   if (test_and_clear_bit(RX_BANDWIDTH, &dev->flags)) {
+   static const struct {
+   u32 freq;
+   } bandwidth_lut[] = {
+   { 175}, /*  1.75 MHz */
+   { 250}, /*  2.5  MHz */
+   { 350}, /*  3.5  MHz */
+   { 500}, /*  5MHz */
+   { 550}, /*  5.5  MHz */
+   { 600}, /*  6MHz */
+   { 700}, /*  7MHz */
+   { 800}, /*  8MHz */
+   { 900}, /*  9MHz */
+   {1000}, /* 10MHz */
+   {1200}, /* 12MHz */
+   {1400}, /* 14MHz */
+   {1500}, /* 15MHz */
+   {2000}, /* 20MHz */
+   {2400}, /* 24MHz */
+   {2800}, /* 28MHz */
+   };
+
+   if (dev->bandwidth_auto->val == true)
+   uitmp = dev->f_adc;
+   else
+   uitmp = dev->bandwidth->val;
+
+   for (i = 0; i < ARRAY_SIZE(bandwidth_lut); i++) {
+   if (uitmp <= bandwidth_lut[i].freq) {
+   uitmp = bandwidth_lut[i].freq;
+   break;
+   }
+   }
+
+   dev->bandwidth->val = uitmp;
+   dev->bandwidth->cur.val = uitmp;
+
+   dev_dbg(&intf->dev, "bandwidth selected=%u\n", uitmp);
+
+   uitmp1 = 0;
+   uitmp1 |= ((uitmp >> 0) & 0xff) << 0;
+   uitmp1 |= ((uitmp >> 8) & 0xff) << 8;
+   uitmp2 = 0;
+   uitmp2 |= ((uitmp >> 16) & 0xff) << 0;
+   uitmp2 |= ((uitmp >> 24) & 0xff) << 8;
+
+   ret = hackrf_ctrl_msg(dev, CMD_BASEBAND_FILTER_BANDWIDTH_SET,
+ uitmp1, uitmp2, NULL, 0);
+   if (ret)
+   goto err;
+   }
+
+   if (test_and_clear_bit(RX_RF_FREQUENCY, &dev->flags)) {
+   dev_dbg(&intf->dev, "RF frequency=%u Hz\n", dev->f_rf);
+   uitmp1 = dev->f_rf / 100;
+   uitmp2 = dev->f_rf % 100;
+   buf[0] = (uitmp1 >>  0) & 0xff;
+   buf[1] = (uitmp1 >>  8) & 0xff;
+   buf[2] = (uitmp1 >> 16) & 0xff;
+   

[PATCHv2 0/9] SDR transmitter API

2015-07-16 Thread Antti Palosaari
v2:
* Allow device open even another device node is active. This means you
could use transmitter device even receiver is active and other way
around, just streaming is blocked to single node.

* Removed V4L2_CID_RF_TUNER_RF_GAIN_AUTO control as it was not used.

* Changed RF gain documentation.

regards
Antti

Antti Palosaari (9):
  v4l2: rename V4L2_TUNER_ADC to V4L2_TUNER_SDR
  v4l2: add RF gain control
  DocBook: document tuner RF gain control
  v4l2: add support for SDR transmitter
  DocBook: document SDR transmitter
  hackrf: add control for RF amplifier
  hackrf: switch to single function which configures everything
  hackrf: add support for transmitter
  hackrf: do not set human readable name for formats

 Documentation/DocBook/media/v4l/compat.xml |  20 +
 Documentation/DocBook/media/v4l/controls.xml   |  14 +
 Documentation/DocBook/media/v4l/dev-sdr.xml|  32 +-
 Documentation/DocBook/media/v4l/io.xml |  10 +-
 Documentation/DocBook/media/v4l/pixfmt.xml |   2 +-
 Documentation/DocBook/media/v4l/v4l2.xml   |   9 +
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml   |   2 +-
 .../DocBook/media/v4l/vidioc-querycap.xml  |   6 +
 drivers/media/usb/hackrf/hackrf.c  | 955 +++--
 drivers/media/v4l2-core/v4l2-ctrls.c   |   2 +
 drivers/media/v4l2-core/v4l2-dev.c |  14 +-
 drivers/media/v4l2-core/v4l2-ioctl.c   |  31 +-
 drivers/media/v4l2-core/videobuf-core.c|   4 +-
 include/media/v4l2-ioctl.h |   8 +
 include/trace/events/v4l2.h|   1 +
 include/uapi/linux/v4l2-controls.h |   1 +
 include/uapi/linux/videodev2.h |  10 +-
 17 files changed, 824 insertions(+), 297 deletions(-)

-- 
http://palosaari.fi/

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


[PATCHv2 5/9] DocBook: document SDR transmitter

2015-07-16 Thread Antti Palosaari
Add documentation for V4L SDR transmitter (output) devices.

Signed-off-by: Antti Palosaari 
Acked-by: Hans Verkuil 
---
 Documentation/DocBook/media/v4l/compat.xml |  4 +++
 Documentation/DocBook/media/v4l/dev-sdr.xml| 30 +++---
 Documentation/DocBook/media/v4l/io.xml | 10 ++--
 Documentation/DocBook/media/v4l/pixfmt.xml |  2 +-
 Documentation/DocBook/media/v4l/v4l2.xml   |  1 +
 Documentation/DocBook/media/v4l/vidioc-g-fmt.xml   |  2 +-
 .../DocBook/media/v4l/vidioc-querycap.xml  |  6 +
 7 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index eb091c7..f534fc5 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2604,6 +2604,10 @@ and &v4l2-mbus-framefmt;.
  Added V4L2_CID_RF_TUNER_RF_GAIN
 RF Tuner control.

+   
+ Added transmitter support for Software Defined Radio (SDR)
+Interface.
+   
   
 
 
diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml 
b/Documentation/DocBook/media/v4l/dev-sdr.xml
index 3344921..a659771 100644
--- a/Documentation/DocBook/media/v4l/dev-sdr.xml
+++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
@@ -28,6 +28,16 @@ Devices supporting the SDR receiver interface set the
 capabilities field of &v4l2-capability;
 returned by the &VIDIOC-QUERYCAP; ioctl. That flag means the device has an
 Analog to Digital Converter (ADC), which is a mandatory element for the SDR 
receiver.
+
+
+Devices supporting the SDR transmitter interface set the
+V4L2_CAP_SDR_OUTPUT and
+V4L2_CAP_MODULATOR flag in the
+capabilities field of &v4l2-capability;
+returned by the &VIDIOC-QUERYCAP; ioctl. That flag means the device has an
+Digital to Analog Converter (DAC), which is a mandatory element for the SDR 
transmitter.
+
+
 At least one of the read/write, streaming or asynchronous I/O methods must
 be supported.
 
@@ -39,14 +49,15 @@ be supported.
 
 SDR devices can support controls, and must
 support the tuner ioctls. Tuner ioctls are used
-for setting the ADC sampling rate (sampling frequency) and the possible RF 
tuner
-frequency.
+for setting the ADC/DAC sampling rate (sampling frequency) and the possible
+radio frequency (RF).
 
 
 
-The V4L2_TUNER_SDR tuner type is used for SDR tuners, and
-the V4L2_TUNER_RF tuner type is used for RF tuners. The
-tuner index of the RF tuner (if any) must always follow the SDR tuner index.
+The V4L2_TUNER_SDR tuner type is used for setting SDR
+device ADC/DAC frequency, and the V4L2_TUNER_RF
+tuner type is used for setting radio frequency.
+The tuner index of the RF tuner (if any) must always follow the SDR tuner 
index.
 Normally the SDR tuner is #0 and the RF tuner is #1.
 
 
@@ -59,9 +70,9 @@ The &VIDIOC-S-HW-FREQ-SEEK; ioctl is not supported.
 Data Format Negotiation
 
 
-The SDR capture device uses the format ioctls to
-select the capture format. Both the sampling resolution and the data streaming
-format are bound to that selectable format. In addition to the basic
+The SDR device uses the format ioctls to
+select the capture and output format. Both the sampling resolution and the data
+streaming format are bound to that selectable format. In addition to the basic
 format ioctls, the &VIDIOC-ENUM-FMT; ioctl
 must be supported as well.
 
@@ -69,7 +80,8 @@ must be supported as well.
 
 To use the format ioctls applications set the
 type field of a &v4l2-format; to
-V4L2_BUF_TYPE_SDR_CAPTURE and use the &v4l2-sdr-format;
+V4L2_BUF_TYPE_SDR_CAPTURE or
+V4L2_BUF_TYPE_SDR_OUTPUT and use the &v4l2-sdr-format;
 sdr member of the fmt
 union as needed per the desired operation.
 Currently there is two fields, pixelformat and
diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 7bbc2a4..da65403 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -1006,8 +1006,14 @@ must set this to 0.
  
V4L2_BUF_TYPE_SDR_CAPTURE
11
-   Buffer for Software Defined Radio (SDR), see .
+   Buffer for Software Defined Radio (SDR) capture stream, see
+   .
+ 
+ 
+   V4L2_BUF_TYPE_SDR_OUTPUT
+   12
+   Buffer for Software Defined Radio (SDR) output stream, see
+   .
  

   
diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml 
b/Documentation/DocBook/media/v4l/pixfmt.xml
index 965ea91..02aac95 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -1623,7 +1623,7 @@ extended control 
V4L2_CID_MPEG_STREAM_TYPE, see
   
 SDR Formats
 
-These formats are used for SDR Capture
+These formats are used for SDR
 interface only.
 
 &sub-sdr-cu08;
diff --git a/Documentation/DocBook/media

[PATCHv2 1/9] v4l2: rename V4L2_TUNER_ADC to V4L2_TUNER_SDR

2015-07-16 Thread Antti Palosaari
SDR receiver has ADC (Analog-to-Digital Converter) and SDR transmitter
has DAC (Digital-to-Analog Converter) . Originally I though it could
be good idea to have own type for receiver and transmitter, but now I
feel one common type for SDR is enough. So lets rename it.

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 Documentation/DocBook/media/v4l/compat.xml  | 12 
 Documentation/DocBook/media/v4l/dev-sdr.xml |  6 +++---
 Documentation/DocBook/media/v4l/v4l2.xml|  7 +++
 drivers/media/v4l2-core/v4l2-ioctl.c|  6 +++---
 include/uapi/linux/videodev2.h  |  5 -
 5 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index a0aef85..f56faf5 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2591,6 +2591,18 @@ and &v4l2-mbus-framefmt;.
   
 
 
+
+  V4L2 in Linux 4.2
+  
+   
+ Renamed V4L2_TUNER_ADC to
+V4L2_TUNER_SDR. The use of
+V4L2_TUNER_ADC is deprecated now.
+ 
+   
+  
+
+
 
   Relation of V4L2 to other Linux multimedia APIs
 
diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml 
b/Documentation/DocBook/media/v4l/dev-sdr.xml
index f890356..3344921 100644
--- a/Documentation/DocBook/media/v4l/dev-sdr.xml
+++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
@@ -44,10 +44,10 @@ frequency.
 
 
 
-The V4L2_TUNER_ADC tuner type is used for ADC tuners, and
+The V4L2_TUNER_SDR tuner type is used for SDR tuners, and
 the V4L2_TUNER_RF tuner type is used for RF tuners. The
-tuner index of the RF tuner (if any) must always follow the ADC tuner index.
-Normally the ADC tuner is #0 and the RF tuner is #1.
+tuner index of the RF tuner (if any) must always follow the SDR tuner index.
+Normally the SDR tuner is #0 and the RF tuner is #1.
 
 
 
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml 
b/Documentation/DocBook/media/v4l/v4l2.xml
index e98caa1..c9eedc1 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -151,6 +151,13 @@ Rubli, Andy Walls, Muralidharan Karicheri, Mauro Carvalho 
Chehab,
 structs, ioctls) must be noted in more detail in the history chapter
 (compat.xml), along with the possible impact on existing drivers and
 applications. -->
+  
+   4.2
+   2015-05-26
+   ap
+   Renamed V4L2_TUNER_ADC to V4L2_TUNER_SDR.
+   
+  
 
   
3.21
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 85de455..ef42474 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1637,7 +1637,7 @@ static int v4l_g_frequency(const struct v4l2_ioctl_ops 
*ops,
struct v4l2_frequency *p = arg;
 
if (vfd->vfl_type == VFL_TYPE_SDR)
-   p->type = V4L2_TUNER_ADC;
+   p->type = V4L2_TUNER_SDR;
else
p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
@@ -1652,7 +1652,7 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops 
*ops,
enum v4l2_tuner_type type;
 
if (vfd->vfl_type == VFL_TYPE_SDR) {
-   if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF)
+   if (p->type != V4L2_TUNER_SDR && p->type != V4L2_TUNER_RF)
return -EINVAL;
} else {
type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
@@ -2277,7 +2277,7 @@ static int v4l_enum_freq_bands(const struct 
v4l2_ioctl_ops *ops,
int err;
 
if (vfd->vfl_type == VFL_TYPE_SDR) {
-   if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF)
+   if (p->type != V4L2_TUNER_SDR && p->type != V4L2_TUNER_RF)
return -EINVAL;
type = p->type;
} else {
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 3228fbe..467816cb 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -165,10 +165,13 @@ enum v4l2_tuner_type {
V4L2_TUNER_RADIO = 1,
V4L2_TUNER_ANALOG_TV = 2,
V4L2_TUNER_DIGITAL_TV= 3,
-   V4L2_TUNER_ADC   = 4,
+   V4L2_TUNER_SDR   = 4,
V4L2_TUNER_RF= 5,
 };
 
+/* Deprecated, do not use */
+#define V4L2_TUNER_ADC  V4L2_TUNER_SDR
+
 enum v4l2_memory {
V4L2_MEMORY_MMAP = 1,
V4L2_MEMORY_USERPTR  = 2,
-- 
http://palosaari.fi/

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


[PATCHv2 2/9] v4l2: add RF gain control

2015-07-16 Thread Antti Palosaari
Add new RF tuner gain control named RF Gain. That is aimed for first
amplifier chip right after antenna connector.
There is existing LNA Gain control, which is quite same, but it is
aimed for cases amplifier is integrated to tuner chip. Some designs
have both, as almost all recent tuner silicons has integrated LNA/RF
amplifier in any case.

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 drivers/media/v4l2-core/v4l2-ctrls.c | 2 ++
 include/uapi/linux/v4l2-controls.h   | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index b6b7dcc..d18462c 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -888,6 +888,7 @@ const char *v4l2_ctrl_get_name(u32 id)
case V4L2_CID_TUNE_DEEMPHASIS:  return "De-Emphasis";
case V4L2_CID_RDS_RECEPTION:return "RDS Reception";
case V4L2_CID_RF_TUNER_CLASS:   return "RF Tuner Controls";
+   case V4L2_CID_RF_TUNER_RF_GAIN: return "RF Gain";
case V4L2_CID_RF_TUNER_LNA_GAIN_AUTO:   return "LNA Gain, Auto";
case V4L2_CID_RF_TUNER_LNA_GAIN:return "LNA Gain";
case V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO: return "Mixer Gain, Auto";
@@ -1161,6 +1162,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_PILOT_TONE_FREQUENCY:
case V4L2_CID_TUNE_POWER_LEVEL:
case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
+   case V4L2_CID_RF_TUNER_RF_GAIN:
case V4L2_CID_RF_TUNER_LNA_GAIN:
case V4L2_CID_RF_TUNER_MIXER_GAIN:
case V4L2_CID_RF_TUNER_IF_GAIN:
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index 9f6e108..efb47cd 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -932,6 +932,7 @@ enum v4l2_deemphasis {
 
 #define V4L2_CID_RF_TUNER_BANDWIDTH_AUTO   (V4L2_CID_RF_TUNER_CLASS_BASE + 
11)
 #define V4L2_CID_RF_TUNER_BANDWIDTH(V4L2_CID_RF_TUNER_CLASS_BASE + 
12)
+#define V4L2_CID_RF_TUNER_RF_GAIN  (V4L2_CID_RF_TUNER_CLASS_BASE + 
32)
 #define V4L2_CID_RF_TUNER_LNA_GAIN_AUTO
(V4L2_CID_RF_TUNER_CLASS_BASE + 41)
 #define V4L2_CID_RF_TUNER_LNA_GAIN (V4L2_CID_RF_TUNER_CLASS_BASE + 
42)
 #define V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO  (V4L2_CID_RF_TUNER_CLASS_BASE + 
51)
-- 
http://palosaari.fi/

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