cron job: media_tree daily build: WARNINGS

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

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: OK
linux-2.6.33.7-i686: OK
linux-2.6.34.7-i686: OK
linux-2.6.35.9-i686: OK
linux-2.6.36.4-i686: OK
linux-2.6.37.6-i686: OK
linux-2.6.38.8-i686: OK
linux-2.6.39.4-i686: OK
linux-3.0.60-i686: OK
linux-3.1.10-i686: OK
linux-3.2.37-i686: OK
linux-3.3.8-i686: OK
linux-3.4.27-i686: OK
linux-3.5.7-i686: OK
linux-3.6.11-i686: OK
linux-3.7.4-i686: OK
linux-3.8-i686: OK
linux-3.9.2-i686: OK
linux-3.10.1-i686: OK
linux-3.11.1-i686: OK
linux-3.12.23-i686: OK
linux-3.13.11-i686: OK
linux-3.14.9-i686: OK
linux-3.15.2-i686: OK
linux-3.16.7-i686: OK
linux-3.17.8-i686: OK
linux-3.18.7-i686: OK
linux-3.19-i686: OK
linux-4.0-i686: OK
linux-4.1-rc1-i686: OK
linux-2.6.32.27-x86_64: OK
linux-2.6.33.7-x86_64: OK
linux-2.6.34.7-x86_64: OK
linux-2.6.35.9-x86_64: OK
linux-2.6.36.4-x86_64: OK
linux-2.6.37.6-x86_64: OK
linux-2.6.38.8-x86_64: OK
linux-2.6.39.4-x86_64: OK
linux-3.0.60-x86_64: OK
linux-3.1.10-x86_64: OK
linux-3.2.37-x86_64: OK
linux-3.3.8-x86_64: OK
linux-3.4.27-x86_64: OK
linux-3.5.7-x86_64: OK
linux-3.6.11-x86_64: OK
linux-3.7.4-x86_64: OK
linux-3.8-x86_64: OK
linux-3.9.2-x86_64: OK
linux-3.10.1-x86_64: OK
linux-3.11.1-x86_64: OK
linux-3.12.23-x86_64: OK
linux-3.13.11-x86_64: OK
linux-3.14.9-x86_64: OK
linux-3.15.2-x86_64: OK
linux-3.16.7-x86_64: OK
linux-3.17.8-x86_64: OK
linux-3.18.7-x86_64: OK
linux-3.19-x86_64: OK
linux-4.0-x86_64: WARNINGS
linux-4.1-rc1-x86_64: WARNINGS
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

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

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Sunday.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


[PATCH v2 2/2] stk1160: Add frame scaling support

2015-06-06 Thread Ezequiel Garcia
This commit implements frame decimation for stk1160, which allows
to support format changes instead of a static frame size.

The stk1160 supports independent row and column decimation, in two
different modes:
 * set a number of rows/columns units to skip for each unit sent.
 * set a number of rows/columns units to send for each unit skipped.

This effectively allows to achieve different frame scaling ratios.

The unit number can be set to either two row/columns sent/skipped,
or four row/columns sent/skipped. Since the video format (UYVY)
has 4-bytes, using a unit number of two row/columns, results
in frame color 'shifting'.

Signed-off-by: Michael Stegemann 
Signed-off-by: Dale Hamel 
Signed-off-by: Ezequiel Garcia 
---
Changes from v1:

  * Clamp width and height in stk1160_try_fmt, this guarantees
sane values are given to the driver.

 drivers/media/usb/stk1160/stk1160-reg.h |  34 ++
 drivers/media/usb/stk1160/stk1160-v4l.c | 187 +++-
 2 files changed, 193 insertions(+), 28 deletions(-)

diff --git a/drivers/media/usb/stk1160/stk1160-reg.h 
b/drivers/media/usb/stk1160/stk1160-reg.h
index 3e49da6..81ff3a1 100644
--- a/drivers/media/usb/stk1160/stk1160-reg.h
+++ b/drivers/media/usb/stk1160/stk1160-reg.h
@@ -33,6 +33,40 @@
  */
 #define STK1160_DCTRL  0x100
 
+/*
+ * Decimation Control Register:
+ * Byte 104: Horizontal Decimation Line Unit Count
+ * Byte 105: Vertical Decimation Line Unit Count
+ * Byte 106: Decimation Control
+ * Bit 0 - Horizontal Decimation Control
+ *   0 Horizontal decimation is disabled.
+ *   1 Horizontal decimation is enabled.
+ * Bit 1 - Decimates Half or More Column
+ *   0 Decimates less than half from original column,
+ * send count unit (0x105) before each unit skipped.
+ *   1 Decimates half or more from original column,
+ * skip count unit (0x105) before each unit sent.
+ * Bit 2 - Vertical Decimation Control
+ *   0 Vertical decimation is disabled.
+ *   1 Vertical decimation is enabled.
+ * Bit 3 - Vertical Greater or Equal to Half
+ *   0 Decimates less than half from original row,
+ * send count unit (0x105) before each unit skipped.
+ *   1 Decimates half or more from original row,
+ * skip count unit (0x105) before each unit sent.
+ * Bit 4 - Decimation Unit
+ *  0 Decimation will work with 2 rows or columns per unit.
+ *  1 Decimation will work with 4 rows or columns per unit.
+ */
+#define STK1160_DMCTRL_H_UNITS 0x104
+#define STK1160_DMCTRL_V_UNITS 0x105
+#define STK1160_DMCTRL 0x106
+#define  STK1160_H_DEC_EN  BIT(0)
+#define  STK1160_H_DEC_MODEBIT(1)
+#define  STK1160_V_DEC_EN  BIT(2)
+#define  STK1160_V_DEC_MODEBIT(3)
+#define  STK1160_DEC_UNIT_SIZE BIT(4)
+
 /* Capture Frame Start Position */
 #define STK116_CFSPO   0x110
 #define STK116_CFSPO_STX_L 0x110
diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c 
b/drivers/media/usb/stk1160/stk1160-v4l.c
index 498bdc7..167a5a0 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -42,6 +42,17 @@ static bool keep_buffers;
 module_param(keep_buffers, bool, 0644);
 MODULE_PARM_DESC(keep_buffers, "don't release buffers upon stop streaming");
 
+enum stk1160_decimate_mode {
+   STK1160_DECIMATE_MORE_THAN_HALF,
+   STK1160_DECIMATE_LESS_THAN_HALF,
+};
+
+struct stk1160_decimate_ctrl {
+   bool col_en, row_en;
+   enum stk1160_decimate_mode col_mode, row_mode;
+   unsigned int col_n, row_n;
+};
+
 /* supported video standards */
 static struct stk1160_fmt format[] = {
{
@@ -106,6 +117,37 @@ static void stk1160_set_std(struct stk1160 *dev)
 
 }
 
+static void stk1160_set_fmt(struct stk1160 *dev,
+   struct stk1160_decimate_ctrl *ctrl)
+{
+   u32 val = 0;
+
+   if (ctrl) {
+   /*
+* Since the format is UYVY, the device must skip or send
+* a number of rows/columns multiple of four. This way, the
+* colour format is preserved. The STK1160_DEC_UNIT_SIZE bit
+* does exactly this.
+*/
+   val |= STK1160_DEC_UNIT_SIZE;
+   val |= ctrl->col_en ? STK1160_H_DEC_EN : 0;
+   val |= ctrl->row_en ? STK1160_V_DEC_EN : 0;
+   val |= ctrl->col_mode == STK1160_DECIMATE_MORE_THAN_HALF ? 
STK1160_H_DEC_MODE : 0;
+   val |= ctrl->row_mode == STK1160_DECIMATE_MORE_THAN_HALF ? 
STK1160_V_DEC_MODE : 0;
+
+   /* Horizontal count units */
+   stk1160_write_reg(dev, STK1160_DMCTRL_H_UNITS, ctrl->col_n);
+   /* Vertical count units */
+   stk1160_write_reg(dev, STK1160_DMCTRL_V_UNITS, ctrl->row_n);
+
+   stk1160_dbg("decimate 0x%x, column units %d, row units %d\n",
+   val, ctrl->col_n, ctrl->row_n);
+   }
+
+   /* Decimation

[PATCH v2 1/2] stk1160: Reduce driver verbosity

2015-06-06 Thread Ezequiel Garcia
These messages are not really informational, and just makes the driver's
output too verbose. This commit changes some messages to a debug level,
removes a really useless "driver loaded" message and finally undefines
the DEBUG macro.

Signed-off-by: Ezequiel Garcia 
---
 drivers/media/usb/stk1160/stk1160-core.c |  5 +
 drivers/media/usb/stk1160/stk1160-v4l.c  | 16 
 drivers/media/usb/stk1160/stk1160.h  |  1 -
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/media/usb/stk1160/stk1160-core.c 
b/drivers/media/usb/stk1160/stk1160-core.c
index 03504dc..1b6836f 100644
--- a/drivers/media/usb/stk1160/stk1160-core.c
+++ b/drivers/media/usb/stk1160/stk1160-core.c
@@ -162,7 +162,7 @@ static void stk1160_release(struct v4l2_device *v4l2_dev)
 {
struct stk1160 *dev = container_of(v4l2_dev, struct stk1160, v4l2_dev);
 
-   stk1160_info("releasing all resources\n");
+   stk1160_dbg("releasing all resources\n");
 
stk1160_i2c_unregister(dev);
 
@@ -363,9 +363,6 @@ static int stk1160_probe(struct usb_interface *interface,
dev->sd_saa7115 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"saa7115_auto", 0, saa7113_addrs);
 
-   stk1160_info("driver ver %s successfully loaded\n",
-   STK1160_VERSION);
-
/* i2c reset saa711x */
v4l2_device_call_all(&dev->v4l2_dev, 0, core, reset, 0);
v4l2_device_call_all(&dev->v4l2_dev, 0, video, s_stream, 0);
diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c 
b/drivers/media/usb/stk1160/stk1160-v4l.c
index 749ad56..498bdc7 100644
--- a/drivers/media/usb/stk1160/stk1160-v4l.c
+++ b/drivers/media/usb/stk1160/stk1160-v4l.c
@@ -136,7 +136,7 @@ static bool stk1160_set_alternate(struct stk1160 *dev)
dev->alt = i;
}
 
-   stk1160_info("setting alternate %d\n", dev->alt);
+   stk1160_dbg("setting alternate %d\n", dev->alt);
 
if (dev->alt != prev_alt) {
stk1160_dbg("minimum isoc packet size: %u (alt=%d)\n",
@@ -224,7 +224,7 @@ static void stk1160_stop_hw(struct stk1160 *dev)
 
/* set alternate 0 */
dev->alt = 0;
-   stk1160_info("setting alternate %d\n", dev->alt);
+   stk1160_dbg("setting alternate %d\n", dev->alt);
usb_set_interface(dev->udev, 0, 0);
 
/* Stop stk1160 */
@@ -537,8 +537,8 @@ static int queue_setup(struct vb2_queue *vq, const struct 
v4l2_format *v4l_fmt,
 
sizes[0] = size;
 
-   stk1160_info("%s: buffer count %d, each %ld bytes\n",
-   __func__, *nbuffers, size);
+   stk1160_dbg("%s: buffer count %d, each %ld bytes\n",
+   __func__, *nbuffers, size);
 
return 0;
 }
@@ -622,8 +622,8 @@ void stk1160_clear_queue(struct stk1160 *dev)
struct stk1160_buffer, list);
list_del(&buf->list);
vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
-   stk1160_info("buffer [%p/%d] aborted\n",
-   buf, buf->vb.v4l2_buf.index);
+   stk1160_dbg("buffer [%p/%d] aborted\n",
+   buf, buf->vb.v4l2_buf.index);
}
 
/* It's important to release the current buffer */
@@ -632,8 +632,8 @@ void stk1160_clear_queue(struct stk1160 *dev)
dev->isoc_ctl.buf = NULL;
 
vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR);
-   stk1160_info("buffer [%p/%d] aborted\n",
-   buf, buf->vb.v4l2_buf.index);
+   stk1160_dbg("buffer [%p/%d] aborted\n",
+   buf, buf->vb.v4l2_buf.index);
}
spin_unlock_irqrestore(&dev->buf_lock, flags);
 }
diff --git a/drivers/media/usb/stk1160/stk1160.h 
b/drivers/media/usb/stk1160/stk1160.h
index abdea48..77f5d46 100644
--- a/drivers/media/usb/stk1160/stk1160.h
+++ b/drivers/media/usb/stk1160/stk1160.h
@@ -58,7 +58,6 @@
  * new drivers should use.
  *
  */
-#define DEBUG
 #ifdef DEBUG
 #define stk1160_dbg(fmt, args...) \
printk(KERN_DEBUG "stk1160: " fmt,  ## args)
-- 
2.3.3

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


[PATCH v2 0/2] stk1160: Frame scaling and "de-verbosification"

2015-06-06 Thread Ezequiel Garcia
I've removed the driver verbosity and fixed the frame scale implementation.
In addition to the usual mplayer/vlc/qv4l2, it's tested with v4l2-compliance
on 4.1-rc4.

v4l2-compliance passes:
Total: 111, Succeeded: 111, Failed: 0, Warnings: 5

v4l2-compliance -s shows some failures, but AFAICS it's not the
driver's fault as the failing ioclt are handled by generic
implementations (vb2_ioctl_reqbufs):

test MMAP: FAIL
VIDIOC_QUERYCAP returned 0 (Success)
VIDIOC_QUERY_EXT_CTRL returned 0 (Success)
VIDIOC_TRY_EXT_CTRLS returned 0 (Success)
VIDIOC_QUERYCTRL returned 0 (Success)
VIDIOC_G_SELECTION returned -1 (Inappropriate ioctl for device)
VIDIOC_REQBUFS returned -1 (Device or resource busy)
fail: v4l2-test-buffers.cpp(976): ret != EINVAL
test USERPTR: FAIL
VIDIOC_QUERYCAP returned 0 (Success)
VIDIOC_QUERY_EXT_CTRL returned 0 (Success)
VIDIOC_TRY_EXT_CTRLS returned 0 (Success)
VIDIOC_QUERYCTRL returned 0 (Success)
VIDIOC_G_SELECTION returned -1 (Inappropriate ioctl for device)
VIDIOC_REQBUFS returned -1 (Invalid argument)
test DMABUF: OK (Not Supported)
VIDIOC_QUERYCAP returned 0 (Success)
VIDIOC_QUERY_EXT_CTRL returned 0 (Success)
VIDIOC_TRY_EXT_CTRLS returned 0 (Success)
VIDIOC_QUERYCTRL returned 0 (Success)
VIDIOC_G_SELECTION returned -1 (Inappropriate ioctl for device)

Total: 115, Succeeded: 113, Failed: 2, Warnings: 5

Thanks,

Ezequiel Garcia (2):
  stk1160: Reduce driver verbosity
  stk1160: Add frame scaling support

 drivers/media/usb/stk1160/stk1160-core.c |   5 +-
 drivers/media/usb/stk1160/stk1160-reg.h  |  34 ++
 drivers/media/usb/stk1160/stk1160-v4l.c  | 203 +--
 drivers/media/usb/stk1160/stk1160.h  |   1 -
 4 files changed, 202 insertions(+), 41 deletions(-)

-- 
2.3.3

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


Re: [PATCH] stk1160: Add frame scaling support

2015-06-06 Thread Ezequiel Garcia
Hi Hans,

On 06/05/2015 08:11 AM, Hans Verkuil wrote:
> Hi Ezequiel,
> 
> As mentioned in irc: run v4l2-compliance -s and v4l2-compliance -f.
> I quickly tried it and v4l2-compliance fails:
> 
> Test input 0:
> 
> Control ioctls:
> test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
> test VIDIOC_QUERYCTRL: OK
> test VIDIOC_G/S_CTRL: OK
> test VIDIOC_G/S/TRY_EXT_CTRLS: OK
> test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
> test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
> Standard Controls: 7 Private Controls: 0
> 
> Format ioctls:
> test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
> test VIDIOC_G/S_PARM: OK
> test VIDIOC_G_FBUF: OK (Not Supported)
> test VIDIOC_G_FMT: OK
> fail: v4l2-test-formats.cpp(422): !pix.width || !pix.height
> fail: v4l2-test-formats.cpp(726): Video Capture is valid, but 
> TRY_FMT failed to return a format
> test VIDIOC_TRY_FMT: FAIL
> fail: v4l2-test-formats.cpp(422): !pix.width || !pix.height
> fail: v4l2-test-formats.cpp(942): Video Capture is valid, but 
> no S_FMT was implemented
> test VIDIOC_S_FMT: FAIL
> test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
> test Cropping: OK (Not Supported)
> test Composing: OK (Not Supported)
> 
> and it ends with a segfault and this in the kernel log:
> 
> [  180.135178] stk1160: width 720, height 480
> [  180.135187] stk1160: width 0, height 0
> [  180.135240] stk1160: width 0, height 0
> [  180.135317] stk1160: decimate 0x1f, column units -721, row units -481
> [  180.135450] stk1160: width 1, height 1
> [  180.135524] stk1160: decimate 0x1f, column units 719, row units 479
> [  180.135572] stk1160: width 720, height 480
> [  180.135701] stk1160: decimate 0x10, column units 0, row units 0
> [  180.135750] divide error:  [#1] PREEMPT SMP 
> [  180.135773] Modules linked in: stk1160 ivtv_alsa tuner_simple tuner_types 
> tda9887 tda8290 tuner msp3400 saa7127 ivtv saa7115 videobuf2_vmalloc tveeprom 
> videobuf2_memops videobuf2_core cx2341x v4l2_common videodev media 
> x86_pkg_temp_thermal processor button [last unloaded: stk1160]
> [  180.135851] CPU: 2 PID: 7391 Comm: v4l2-compliance Not tainted 
> 4.1.0-rc3-koryphon #837
> [  180.135862] Hardware name: ASUSTeK COMPUTER INC. Z10PA-U8 Series/Z10PA-U8 
> Series, BIOS 0303 11/20/2014
> [  180.135873] task: 8810364b1830 ti: 88100c794000 task.ti: 
> 88100c794000
> [  180.135882] RIP: 0010:[]  [] 
> stk1160_try_fmt.isra.5+0x1ba/0x1e0 [stk1160]
> [  180.135902] RSP: 0018:88100c797bd8  EFLAGS: 00010202
> [  180.135910] RAX: 02d0 RBX:  RCX: 
> 88100c797c14
> [  180.135918] RDX:  RSI: 8810364107c0 RDI: 
> 01e0
> [  180.135927] RBP: 88100c797bf8 R08: 881036537500 R09: 
> 01e0
> [  180.135939] R10:  R11: 0005 R12: 
> 
> [  180.135948] R13:  R14: 0001 R15: 
> 
> [  180.135958] FS:  7f7acbad8740() GS:88107fc8() 
> knlGS:
> [  180.135968] CS:  0010 DS:  ES:  CR0: 80050033
> [  180.135975] CR2: 7faa881e4148 CR3: 00102974d000 CR4: 
> 001406e0
> [  180.135984] Stack:
> [  180.136003]  88103641  881036537500 
> 881036536c00
> [  180.136018]  88100c797c48 a003ee4b 88100c797c58 
> 81a0dbc2
> [  180.136033]  00010001  88100c797c48 
> 881036537500
> [  180.136048] Call Trace:
> [  180.136057]  [] vidioc_s_fmt_vid_cap+0x4b/0xf0 [stk1160]
> [  180.136073]  [] v4l_s_fmt+0x123/0x490 [videodev]
> [  180.136086]  [] __video_do_ioctl+0x274/0x310 [videodev]
> [  180.136099]  [] ? video_usercopy+0x2fa/0x4c0 [videodev]
> [  180.136111]  [] video_usercopy+0x336/0x4c0 [videodev]
> [  180.136122]  [] ? v4l_querycap+0x60/0x60 [videodev]
> [  180.136135]  [] ? __this_cpu_preempt_check+0x13/0x20
> [  180.136146]  [] ? __srcu_read_lock+0x5f/0xa0
> [  180.136157]  [] video_ioctl2+0x10/0x20 [videodev]
> [  180.136168]  [] v4l2_ioctl+0xd0/0xf0 [videodev]
> [  180.136179]  [] do_vfs_ioctl+0x2e0/0x4e0
> [  180.136187]  [] ? vfs_write+0x14c/0x1b0
> [  180.136196]  [] SyS_ioctl+0x81/0xa0
> [  180.136208]  [] system_call_fastpath+0x12/0x71
> [  180.136216] Code: 31 d2 41 89 c1 41 89 40 0c e9 d0 fe ff ff 0f 1f 00 44 89 
> d0 41 be 01 00 00 00 45 31 ed c1 e8 1f 44 01 d0 d1 f8 05 d0 02 00 00 99 <41> 
> f7 fa 31 d2 41 89 c2 44 8d 60 ff b8 d0 02 00 00 41 f7 f2 41 
> [  180.136354] RIP  [] stk1160_try_fmt.isra.5+0x1ba/0x1e0 
> [stk1160]
> [  180.136366]  RSP 
> [  180.139977] ---[ end trace a699ade0cf2b43de ]---
> 
> So this needs a bit more work... Remember: v4l2-compliance is your frie

Re: [PATCH 01/10] sh-vou: hook up the clock correctly

2015-06-06 Thread Geert Uytterhoeven
Hi Hans,

On Fri, Jun 5, 2015 at 12:59 PM, Hans Verkuil  wrote:
> From: Hans Verkuil 
>
> Bitrot has set in for this driver and the sh-vou.0 clock was never enabled,
> so this driver didn't do anything. In addition, the clock was incorrectly
> defined in clock-sh7724.c. Fix this.

I think the clock should be enabled automatically using Runtime PM.
drivers/sh/pm_runtime.c should configure the "NULL" (i.e. the first) clock
for power management, after which pm_runtime_get_sync() will enable it.

> While we're at it: use proper resource managed calls.

Shouldn't that be a separate patch? Especially if the real fix becomes a
one-liner (see below).

> Signed-off-by: Hans Verkuil 
> Cc: Magnus Damm 
> ---
>  arch/sh/kernel/cpu/sh4a/clock-sh7724.c |  2 +-
>  drivers/media/platform/sh_vou.c| 54 
> --
>  2 files changed, 20 insertions(+), 36 deletions(-)
>
> diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c 
> b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> index c187b95..f1df899 100644
> --- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
> @@ -343,7 +343,7 @@ static struct clk_lookup lookups[] = {
> CLKDEV_CON_ID("2ddmac0", &mstp_clks[HWBLK_2DDMAC]),
> CLKDEV_DEV_ID("sh_fsi.0", &mstp_clks[HWBLK_SPU]),
> CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]),
> -   CLKDEV_DEV_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]),
> +   CLKDEV_CON_ID("sh-vou.0", &mstp_clks[HWBLK_VOU]),

I don't know which SH board you have, but both
arch/sh/boards/mach-ecovec24/setup.c and
arch/sh/boards/mach-se/7724/setup.c create the platform device as:

static struct platform_device vou_device = {
.name   = "sh-vou",
.id = -1,
};

so unless I'm mistaken, the platform device's name will be "sh-vou",
not "sh-vou.0".

Does it work if you just correct the name in the CLKDEV_DEV_ID() line?

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
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/4] media: pxa_camera conversion to dmaengine

2015-06-06 Thread Robert Jarzmik
Robert Jarzmik  writes:

> Robert Jarzmik  writes:
>
>> Hi Guennadi,
>>
>> I've been cooking this since 2012. At that time, I thought the dmaengine API 
>> was
>> not rich enough to support the pxa_camera subtleties (or complexity).
>>
>> I was wrong. I submitted a driver to Vinod for a dma pxa driver which would
>> support everything needed to make pxa_camera work normally.
>>
>> As a consequence, I wrote this serie. Should the pxa-dma driver be accepted,
>> then this serie will be my next move towards pxa conversion to dmaengine. 
>> And to
>> parallelize the review work, I'll submit it right away to receive a review 
>> and
>> fix pxa_camera so that it is ready by the time pxa-dma is also reviewed.
> Hi Guennadi,
>
> Any update on this serie ? The pxa-dma driver is upstreamed now.

Guennadi, are you around ?

Cheers.

-- 
Robert
--
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: Si2168 B40 frimware.

2015-06-06 Thread Unembossed Name

From: "Antti Palosaari"
To: "Unembossed Name" ; 

Sent: Sunday, June 07, 2015 3:14 AM
Subject: Re: Si2168 B40 frimware.


Could you please check it again? And in case of success see which
version it is?

file name:dvb-demod-si2168-b40-rom4_0_2-patch-build-probably4_0_19.fw.tar.gz
http://beholder.ru/bb/download/file.php?id=857
Best regards.


That one works, DVB-T/T2 scan tested.

si2168 6-0064: found a 'Silicon Labs Si2168-B40'
si2168 6-0064: downloading firmware from file 'dvb-demod-si2168-b40-01.fw'
si2168 6-0064: firmware version: 4.0.19
si2157 7-0060: found a 'Silicon Labs Si2157-A30'
si2157 7-0060: firmware version: 3.0.5


Hi Antti,

Great! Thank you.
Instructions, on how to extract 4.0.19 for Si2168 B40 demod:
First, you have to download zipped file from 
http://beholder.ru/files/drv_v5510.zip
Unpack beholder.bin from it, and then use that command to extract firmware 
patch:
dd if=beholder.bin  bs=1 skip=69520 count=13651 
of=dvb-demod-si2168-b40-rom4_0_2-patch-build4_0_19.fw

Best regards.
--
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/5] [media] mantis: add remote control support

2015-06-06 Thread Jan Klötzke
Hi Mauro,

I am re-submitting my patch for remote control support of mantis based DVB
cards for the 3rd time. The last submission can be found here [1]. It has been
rebased and tested on v4.0. It has been working fine on my HTPC for almost
three years now. Compared to the previous submission I've split the patch into
the individual rc key tables and the actual mantis rc support.

I am really hoping that the patch will be applied this time. These cards are
still in use and people have to patch their kernel to get them fully working.
I recently got some feedback that it is working for other too.

This patch has been tested on a TechniSat CableStar HD2. Other rc-maps were
taken from Christoph Pinkl's patch [2] and the s2-liplianin repository. The
major difference to Christoph's patch is a reworked interrupt handling of the
UART because the RX interrupt is apparently level triggered and requires
masking until the FIFO is read by the UART worker.

Tested-by: Thomas Müller 

[1] https://patchwork.linuxtv.org/patch/26321/
[2] http://patchwork.linuxtv.org/patch/7217/

---
 drivers/media/pci/mantis/hopper_cards.c|  13 ++-
 drivers/media/pci/mantis/mantis_cards.c|  60 +---
 drivers/media/pci/mantis/mantis_common.h   |  33 ++-
 drivers/media/pci/mantis/mantis_dma.c  |   5 +-
 drivers/media/pci/mantis/mantis_i2c.c  |   8 +-
 drivers/media/pci/mantis/mantis_input.c| 106 -
 drivers/media/pci/mantis/mantis_input.h|  28 ++
 drivers/media/pci/mantis/mantis_pcmcia.c   |   4 +-
 drivers/media/pci/mantis/mantis_uart.c |  62 ++--
 drivers/media/rc/keymaps/Makefile  |   4 +
 drivers/media/rc/keymaps/rc-technisat-ts35.c   |  76 +++
 .../media/rc/keymaps/rc-terratec-cinergy-c-pci.c   |  88 +
 .../media/rc/keymaps/rc-terratec-cinergy-s2-hd.c   |  86 +
 drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c   |  98 +++
 include/media/rc-map.h |   4 +
 15 files changed, 526 insertions(+), 149 deletions(-)

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


[PATCH 3/5] [media] rc/keymaps: add keytable for Terratec Cinergy S2 HD

2015-06-06 Thread Jan Klötzke
This RC map was taken from Christoph Pinkl's patch
(http://patchwork.linuxtv.org/patch/7217/). It is used solely by the respective
mantis based card because the encoding is not known.

Signed-off-by: Jan Klötzke 
---
 drivers/media/rc/keymaps/Makefile  |  1 +
 .../media/rc/keymaps/rc-terratec-cinergy-s2-hd.c   | 86 ++
 include/media/rc-map.h |  1 +
 3 files changed, 88 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index 775f663..f0c02c8 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-technisat-ts35.o \
rc-technisat-usb2.o \
rc-terratec-cinergy-c-pci.o \
+   rc-terratec-cinergy-s2-hd.o \
rc-terratec-cinergy-xs.o \
rc-terratec-slim.o \
rc-terratec-slim-2.o \
diff --git a/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c 
b/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c
new file mode 100644
index 000..1e096bb
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c
@@ -0,0 +1,86 @@
+/* keytable for Terratec Cinergy S2 HD Remote Controller
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+
+static struct rc_map_table terratec_cinergy_s2_hd[] = {
+   { 0x03, KEY_NEXT},   /* >| */
+   { 0x07, KEY_RECORD},
+   { 0x0b, KEY_PREVIOUS},   /* |< */
+   { 0x10, KEY_FASTFORWARD},/* >> */
+   { 0x11, KEY_REWIND}, /* << */
+   { 0x12, KEY_ESC},/* Back */
+   { 0x13, KEY_PLAY},
+   { 0x14, KEY_IMAGES},
+   { 0x15, KEY_AUDIO},
+   { 0x16, KEY_MEDIA},  /* Video-Menu */
+   { 0x17, KEY_STOP},
+   { 0x18, KEY_DVD},
+   { 0x19, KEY_TV},
+   { 0x1a, KEY_DELETE},
+   { 0x1b, KEY_TEXT},
+   { 0x1c, KEY_SUBTITLE},
+   { 0x1d, KEY_MENU},   /* DVD-Menu */
+   { 0x1e, KEY_HOME},
+   { 0x1f, KEY_PAUSE},
+   { 0x20, KEY_CHANNELDOWN},
+   { 0x21, KEY_VOLUMEDOWN},
+   { 0x22, KEY_MUTE},
+   { 0x23, KEY_VOLUMEUP},
+   { 0x24, KEY_CHANNELUP},
+   { 0x25, KEY_BLUE},
+   { 0x26, KEY_YELLOW},
+   { 0x27, KEY_GREEN},
+   { 0x28, KEY_RED},
+   { 0x29, KEY_INFO},
+   { 0x2b, KEY_DOWN},
+   { 0x2c, KEY_RIGHT},
+   { 0x2d, KEY_OK},
+   { 0x2e, KEY_LEFT},
+   { 0x2f, KEY_UP},
+   { 0x30, KEY_EPG},
+   { 0x32, KEY_VIDEO},  /* A<=>B */
+   { 0x33, KEY_0},
+   { 0x34, KEY_VCR},/* AV */
+   { 0x35, KEY_9},
+   { 0x36, KEY_8},
+   { 0x37, KEY_7},
+   { 0x38, KEY_6},
+   { 0x39, KEY_5},
+   { 0x3a, KEY_4},
+   { 0x3b, KEY_3},
+   { 0x3c, KEY_2},
+   { 0x3d, KEY_1},
+   { 0x3e, KEY_POWER},
+
+};
+
+static struct rc_map_list terratec_cinergy_s2_hd_map = {
+   .map = {
+   .scan= terratec_cinergy_s2_hd,
+   .size= ARRAY_SIZE(terratec_cinergy_s2_hd),
+   .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
+   .name= RC_MAP_TERRATEC_CINERGY_S2_HD,
+   }
+};
+
+static int __init init_rc_map_terratec_cinergy_s2_hd(void)
+{
+   return rc_map_register(&terratec_cinergy_s2_hd_map);
+}
+
+static void __exit exit_rc_map_terratec_cinergy_s2_hd(void)
+{
+   rc_map_unregister(&terratec_cinergy_s2_hd_map);
+}
+
+module_init(init_rc_map_terratec_cinergy_s2_hd);
+module_exit(exit_rc_map_terratec_cinergy_s2_hd);
+
+MODULE_LICENSE("GPL");
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 9873a17..50ed644 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -197,6 +197,7 @@ void rc_map_init(void);
 #define RC_MAP_TECHNISAT_TS35"rc-technisat-ts35"
 #define RC_MAP_TECHNISAT_USB2"rc-technisat-usb2"
 #define RC_MAP_TERRATEC_CINERGY_C_PCI"rc-terratec-cinergy-c-pci"
+#define RC_MAP_TERRATEC_CINERGY_S2_HD"rc-terratec-cinergy-s2-hd"
 #define RC_MAP_TERRATEC_CINERGY_XS   "rc-terratec-cinergy-xs"
 #define RC_MAP_TERRATEC_SLIM "rc-terratec-slim"
 #define RC_MAP_TERRATEC_SLIM_2   "rc-terratec-slim-2"
-- 
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 5/5] [media] mantis: add remote control support

2015-06-06 Thread Jan Klötzke
The embedded UART is apparently used to receive decoded IR (RC5?) codes.
Forward these scan codes to the RC framework and (where known) add
corresponding mapping tables to translate them into regular keys.

This patch has been tested on a TechniSat CableStar HD2. The mappings of other
rc-maps were taken from Christoph Pinkl's patch
(http://patchwork.linuxtv.org/patch/7217/) and the s2-liplianin repository. The
major difference to Christoph's patch is a reworked interrupt handling of the
UART because the RX interrupt is apparently level triggered and requires
masking until the FIFO is read by the UART worker.

Signed-off-by: Jan Klötzke 
---
 drivers/media/pci/mantis/hopper_cards.c  |  13 +++-
 drivers/media/pci/mantis/mantis_cards.c  |  60 +
 drivers/media/pci/mantis/mantis_common.h |  33 --
 drivers/media/pci/mantis/mantis_dma.c|   5 +-
 drivers/media/pci/mantis/mantis_i2c.c|   8 +--
 drivers/media/pci/mantis/mantis_input.c  | 106 +--
 drivers/media/pci/mantis/mantis_input.h  |  28 
 drivers/media/pci/mantis/mantis_pcmcia.c |   4 +-
 drivers/media/pci/mantis/mantis_uart.c   |  62 +-
 9 files changed, 170 insertions(+), 149 deletions(-)
 create mode 100644 drivers/media/pci/mantis/mantis_input.h

diff --git a/drivers/media/pci/mantis/hopper_cards.c 
b/drivers/media/pci/mantis/hopper_cards.c
index 104914a..97b7a32 100644
--- a/drivers/media/pci/mantis/hopper_cards.c
+++ b/drivers/media/pci/mantis/hopper_cards.c
@@ -106,6 +106,9 @@ static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
}
if (stat & MANTIS_INT_IRQ1) {
dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
+   spin_lock(&mantis->intmask_lock);
+   mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ1, 
MANTIS_INT_MASK);
+   spin_unlock(&mantis->intmask_lock);
schedule_work(&mantis->uart_work);
}
if (stat & MANTIS_INT_OCERR) {
@@ -154,6 +157,7 @@ static irqreturn_t hopper_irq_handler(int irq, void *dev_id)
 static int hopper_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *pci_id)
 {
+   struct mantis_pci_drvdata *drvdata;
struct mantis_pci *mantis;
struct mantis_hwconfig *config;
int err = 0;
@@ -165,12 +169,16 @@ static int hopper_pci_probe(struct pci_dev *pdev,
goto fail0;
}
 
+   drvdata = (struct mantis_pci_drvdata *) 
pci_id->driver_data;
mantis->num = devs;
mantis->verbose = verbose;
mantis->pdev= pdev;
-   config  = (struct mantis_hwconfig *) 
pci_id->driver_data;
+   config  = drvdata->hwconfig;
config->irq_handler = &hopper_irq_handler;
mantis->hwconfig= config;
+   mantis->rc_map_name = drvdata->rc_map_name;
+
+   spin_lock_init(&mantis->intmask_lock);
 
err = mantis_pci_init(mantis);
if (err) {
@@ -247,7 +255,8 @@ static void hopper_pci_remove(struct pci_dev *pdev)
 }
 
 static struct pci_device_id hopper_pci_table[] = {
-   MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config),
+   MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3028_DVB_T, &vp3028_config,
+   NULL),
{ }
 };
 
diff --git a/drivers/media/pci/mantis/mantis_cards.c 
b/drivers/media/pci/mantis/mantis_cards.c
index 801fc55..9294efe 100644
--- a/drivers/media/pci/mantis/mantis_cards.c
+++ b/drivers/media/pci/mantis/mantis_cards.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "dmxdev.h"
 #include "dvbdev.h"
@@ -49,6 +50,7 @@
 #include "mantis_pci.h"
 #include "mantis_i2c.h"
 #include "mantis_reg.h"
+#include "mantis_input.h"
 
 static unsigned int verbose;
 module_param(verbose, int, 0644);
@@ -114,6 +116,9 @@ static irqreturn_t mantis_irq_handler(int irq, void *dev_id)
}
if (stat & MANTIS_INT_IRQ1) {
dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
+   spin_lock(&mantis->intmask_lock);
+   mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ1, 
MANTIS_INT_MASK);
+   spin_unlock(&mantis->intmask_lock);
schedule_work(&mantis->uart_work);
}
if (stat & MANTIS_INT_OCERR) {
@@ -162,6 +167,7 @@ static irqreturn_t mantis_irq_handler(int irq, void *dev_id)
 static int mantis_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *pci_id)
 {
+   struct mantis_pci_drvdata *drvdata;
struct mantis_pci *mantis;
struct mantis_hwconfig *config;
int err = 0;
@@ -173,12 +179,16 @@ static int mantis_pci_probe(struct pci_dev *pdev,
goto fail0;
}
 
+   drvdata = (struct mantis_pci_drvdata *) 
pci_id->driver_data;
mantis->num = devs;
mantis->verbose = verbose;
   

[PATCH 4/5] [media] rc/keymaps: add keytable for Twinhan DTV CAB CI

2015-06-06 Thread Jan Klötzke
This RC map was taken from Christoph Pinkl's patch
(http://patchwork.linuxtv.org/patch/7217/). It is used solely by the respective
mantis based card because the encoding is not known.

Signed-off-by: Jan Klötzke 
---
 drivers/media/rc/keymaps/Makefile|  1 +
 drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c | 98 
 include/media/rc-map.h   |  1 +
 3 files changed, 100 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index f0c02c8..fbbd3bb 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-total-media-in-hand-02.o \
rc-trekstor.o \
rc-tt-1500.o \
+   rc-twinhan-dtv-cab-ci.o \
rc-twinhan1027.o \
rc-videomate-m1f.o \
rc-videomate-s350.o \
diff --git a/drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c 
b/drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c
new file mode 100644
index 000..202500c
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c
@@ -0,0 +1,98 @@
+/* keytable for Twinhan DTV CAB CI Remote Controller
+ *
+ * Copyright (c) 2010 by Igor M. Liplianin 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+
+static struct rc_map_table twinhan_dtv_cab_ci[] = {
+   { 0x29, KEY_POWER},
+   { 0x28, KEY_FAVORITES},
+   { 0x30, KEY_TEXT},
+   { 0x17, KEY_INFO},  /* Preview */
+   { 0x23, KEY_EPG},
+   { 0x3b, KEY_F22},   /* Record List */
+
+   { 0x3c, KEY_1},
+   { 0x3e, KEY_2},
+   { 0x39, KEY_3},
+   { 0x36, KEY_4},
+   { 0x22, KEY_5},
+   { 0x20, KEY_6},
+   { 0x32, KEY_7},
+   { 0x26, KEY_8},
+   { 0x24, KEY_9},
+   { 0x2a, KEY_0},
+
+   { 0x33, KEY_CANCEL},
+   { 0x2c, KEY_BACK},
+   { 0x15, KEY_CLEAR},
+   { 0x3f, KEY_TAB},
+   { 0x10, KEY_ENTER},
+   { 0x14, KEY_UP},
+   { 0x0d, KEY_RIGHT},
+   { 0x0e, KEY_DOWN},
+   { 0x11, KEY_LEFT},
+
+   { 0x21, KEY_VOLUMEUP},
+   { 0x35, KEY_VOLUMEDOWN},
+   { 0x3d, KEY_CHANNELDOWN},
+   { 0x3a, KEY_CHANNELUP},
+   { 0x2e, KEY_RECORD},
+   { 0x2b, KEY_PLAY},
+   { 0x13, KEY_PAUSE},
+   { 0x25, KEY_STOP},
+
+   { 0x1f, KEY_REWIND},
+   { 0x2d, KEY_FASTFORWARD},
+   { 0x1e, KEY_PREVIOUS},  /* Replay |< */
+   { 0x1d, KEY_NEXT},  /* Skip   >| */
+
+   { 0x0b, KEY_CAMERA},/* Capture */
+   { 0x0f, KEY_LANGUAGE},  /* SAP */
+   { 0x18, KEY_MODE},  /* PIP */
+   { 0x12, KEY_ZOOM},  /* Full screen */
+   { 0x1c, KEY_SUBTITLE},
+   { 0x2f, KEY_MUTE},
+   { 0x16, KEY_F20},   /* L/R */
+   { 0x38, KEY_F21},   /* Hibernate */
+
+   { 0x37, KEY_SWITCHVIDEOMODE},   /* A/V */
+   { 0x31, KEY_AGAIN}, /* Recall */
+   { 0x1a, KEY_KPPLUS},/* Zoom+ */
+   { 0x19, KEY_KPMINUS},   /* Zoom- */
+   { 0x27, KEY_RED},
+   { 0x0C, KEY_GREEN},
+   { 0x01, KEY_YELLOW},
+   { 0x00, KEY_BLUE},
+};
+
+static struct rc_map_list twinhan_dtv_cab_ci_map = {
+   .map = {
+   .scan= twinhan_dtv_cab_ci,
+   .size= ARRAY_SIZE(twinhan_dtv_cab_ci),
+   .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
+   .name= RC_MAP_TWINHAN_DTV_CAB_CI,
+   }
+};
+
+static int __init init_rc_map_twinhan_dtv_cab_ci(void)
+{
+   return rc_map_register(&twinhan_dtv_cab_ci_map);
+}
+
+static void __exit exit_rc_map_twinhan_dtv_cab_ci(void)
+{
+   rc_map_unregister(&twinhan_dtv_cab_ci_map);
+}
+
+module_init(init_rc_map_twinhan_dtv_cab_ci);
+module_exit(exit_rc_map_twinhan_dtv_cab_ci);
+
+MODULE_LICENSE("GPL");
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 50ed644..27763d5 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -207,6 +207,7 @@ void rc_map_init(void);
 #define RC_MAP_TOTAL_MEDIA_IN_HAND_02"rc-total-media-in-hand-02"
 #define RC_MAP_TREKSTOR  "rc-trekstor"
 #define RC_MAP_TT_1500   "rc-tt-1500"
+#define RC_MAP_TWINHAN_DTV_CAB_CI"rc-twinhan-dtv-cab-ci"
 #define RC_MAP_TWINHAN_VP1027_DVBS   "rc-twinhan1027"
 #define RC_MAP_VIDEOMATE_K100"rc-videomate-k100"
 #define RC_MAP_VIDEOMATE_S350"rc-videomate-s350"
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-med

[PATCH 1/5] [media] rc/keymaps: add RC keytable for TechniSat TS35

2015-06-06 Thread Jan Klötzke
The TS35 remote is distributed with TechniSat CableStar HD2 cards (mantis
chipset). The exact protocol type is unknown, making this rc map probably only
usable by mantis cards.

Signed-off-by: Jan Klötzke 
---
 drivers/media/rc/keymaps/Makefile|  1 +
 drivers/media/rc/keymaps/rc-technisat-ts35.c | 76 
 include/media/rc-map.h   |  1 +
 3 files changed, 78 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-technisat-ts35.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index abf6079..07c4b98 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -84,6 +84,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-snapstream-firefly.o \
rc-streamzap.o \
rc-tbs-nec.o \
+   rc-technisat-ts35.o \
rc-technisat-usb2.o \
rc-terratec-cinergy-xs.o \
rc-terratec-slim.o \
diff --git a/drivers/media/rc/keymaps/rc-technisat-ts35.c 
b/drivers/media/rc/keymaps/rc-technisat-ts35.c
new file mode 100644
index 000..3328cbe
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-technisat-ts35.c
@@ -0,0 +1,76 @@
+/* rc-technisat-ts35.c - Keytable for TechniSat TS35 remote
+ *
+ * Copyright (c) 2013 by Jan Klötzke 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ */
+
+#include 
+#include 
+
+static struct rc_map_table technisat_ts35[] = {
+   {0x32, KEY_MUTE},
+   {0x07, KEY_MEDIA},
+   {0x1c, KEY_AB},
+   {0x33, KEY_POWER},
+
+   {0x3e, KEY_1},
+   {0x3d, KEY_2},
+   {0x3c, KEY_3},
+   {0x3b, KEY_4},
+   {0x3a, KEY_5},
+   {0x39, KEY_6},
+   {0x38, KEY_7},
+   {0x37, KEY_8},
+   {0x36, KEY_9},
+   {0x3f, KEY_0},
+   {0x35, KEY_DIGITS},
+   {0x2c, KEY_TV},
+
+   {0x20, KEY_INFO},
+   {0x2d, KEY_MENU},
+   {0x1f, KEY_UP},
+   {0x1e, KEY_DOWN},
+   {0x2e, KEY_LEFT},
+   {0x2f, KEY_RIGHT},
+   {0x28, KEY_OK},
+   {0x10, KEY_EPG},
+   {0x1d, KEY_BACK},
+
+   {0x14, KEY_RED},
+   {0x13, KEY_GREEN},
+   {0x12, KEY_YELLOW},
+   {0x11, KEY_BLUE},
+
+   {0x09, KEY_SELECT},
+   {0x03, KEY_TEXT},
+   {0x16, KEY_STOP},
+   {0x30, KEY_HELP},
+};
+
+static struct rc_map_list technisat_ts35_map = {
+   .map = {
+   .scan= technisat_ts35,
+   .size= ARRAY_SIZE(technisat_ts35),
+   .rc_type = RC_TYPE_UNKNOWN,
+   .name= RC_MAP_TECHNISAT_TS35,
+   }
+};
+
+static int __init init_rc_map(void)
+{
+   return rc_map_register(&technisat_ts35_map);
+}
+
+static void __exit exit_rc_map(void)
+{
+   rc_map_unregister(&technisat_ts35_map);
+}
+
+module_init(init_rc_map)
+module_exit(exit_rc_map)
+
+MODULE_LICENSE("GPL");
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index e7a1514..aa56264 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -194,6 +194,7 @@ void rc_map_init(void);
 #define RC_MAP_SNAPSTREAM_FIREFLY"rc-snapstream-firefly"
 #define RC_MAP_STREAMZAP "rc-streamzap"
 #define RC_MAP_TBS_NEC   "rc-tbs-nec"
+#define RC_MAP_TECHNISAT_TS35"rc-technisat-ts35"
 #define RC_MAP_TECHNISAT_USB2"rc-technisat-usb2"
 #define RC_MAP_TERRATEC_CINERGY_XS   "rc-terratec-cinergy-xs"
 #define RC_MAP_TERRATEC_SLIM "rc-terratec-slim"
-- 
2.1.4

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


[PATCH 2/5] [media] rc/keymaps: add keytable for Terratec Cinergy C PCI

2015-06-06 Thread Jan Klötzke
This RC map was taken from Christoph Pinkl's patch
(http://patchwork.linuxtv.org/patch/7217/). It is used solely by the respective
mantis based card because the encoding is not known.

Signed-off-by: Jan Klötzke 
---
 drivers/media/rc/keymaps/Makefile  |  1 +
 .../media/rc/keymaps/rc-terratec-cinergy-c-pci.c   | 88 ++
 include/media/rc-map.h |  1 +
 3 files changed, 90 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index 07c4b98..775f663 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -86,6 +86,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-tbs-nec.o \
rc-technisat-ts35.o \
rc-technisat-usb2.o \
+   rc-terratec-cinergy-c-pci.o \
rc-terratec-cinergy-xs.o \
rc-terratec-slim.o \
rc-terratec-slim-2.o \
diff --git a/drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c 
b/drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c
new file mode 100644
index 000..7958f45
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c
@@ -0,0 +1,88 @@
+/* keytable for Terratec Cinergy C PCI Remote Controller
+ *
+ * Copyright (c) 2010 by Igor M. Liplianin 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+
+static struct rc_map_table terratec_cinergy_c_pci[] = {
+   { 0x3e, KEY_POWER},
+   { 0x3d, KEY_1},
+   { 0x3c, KEY_2},
+   { 0x3b, KEY_3},
+   { 0x3a, KEY_4},
+   { 0x39, KEY_5},
+   { 0x38, KEY_6},
+   { 0x37, KEY_7},
+   { 0x36, KEY_8},
+   { 0x35, KEY_9},
+   { 0x34, KEY_VIDEO_NEXT}, /* AV */
+   { 0x33, KEY_0},
+   { 0x32, KEY_REFRESH},
+   { 0x30, KEY_EPG},
+   { 0x2f, KEY_UP},
+   { 0x2e, KEY_LEFT},
+   { 0x2d, KEY_OK},
+   { 0x2c, KEY_RIGHT},
+   { 0x2b, KEY_DOWN},
+   { 0x29, KEY_INFO},
+   { 0x28, KEY_RED},
+   { 0x27, KEY_GREEN},
+   { 0x26, KEY_YELLOW},
+   { 0x25, KEY_BLUE},
+   { 0x24, KEY_CHANNELUP},
+   { 0x23, KEY_VOLUMEUP},
+   { 0x22, KEY_MUTE},
+   { 0x21, KEY_VOLUMEDOWN},
+   { 0x20, KEY_CHANNELDOWN},
+   { 0x1f, KEY_PAUSE},
+   { 0x1e, KEY_HOME},
+   { 0x1d, KEY_MENU}, /* DVD Menu */
+   { 0x1c, KEY_SUBTITLE},
+   { 0x1b, KEY_TEXT}, /* Teletext */
+   { 0x1a, KEY_DELETE},
+   { 0x19, KEY_TV},
+   { 0x18, KEY_DVD},
+   { 0x17, KEY_STOP},
+   { 0x16, KEY_VIDEO},
+   { 0x15, KEY_AUDIO}, /* Music */
+   { 0x14, KEY_SCREEN}, /* Pic */
+   { 0x13, KEY_PLAY},
+   { 0x12, KEY_BACK},
+   { 0x11, KEY_REWIND},
+   { 0x10, KEY_FASTFORWARD},
+   { 0x0b, KEY_PREVIOUS},
+   { 0x07, KEY_RECORD},
+   { 0x03, KEY_NEXT},
+
+};
+
+static struct rc_map_list terratec_cinergy_c_pci_map = {
+   .map = {
+   .scan= terratec_cinergy_c_pci,
+   .size= ARRAY_SIZE(terratec_cinergy_c_pci),
+   .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */
+   .name= RC_MAP_TERRATEC_CINERGY_C_PCI,
+   }
+};
+
+static int __init init_rc_map_terratec_cinergy_c_pci(void)
+{
+   return rc_map_register(&terratec_cinergy_c_pci_map);
+}
+
+static void __exit exit_rc_map_terratec_cinergy_c_pci(void)
+{
+   rc_map_unregister(&terratec_cinergy_c_pci_map);
+}
+
+module_init(init_rc_map_terratec_cinergy_c_pci);
+module_exit(exit_rc_map_terratec_cinergy_c_pci);
+
+MODULE_LICENSE("GPL");
diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index aa56264..9873a17 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -196,6 +196,7 @@ void rc_map_init(void);
 #define RC_MAP_TBS_NEC   "rc-tbs-nec"
 #define RC_MAP_TECHNISAT_TS35"rc-technisat-ts35"
 #define RC_MAP_TECHNISAT_USB2"rc-technisat-usb2"
+#define RC_MAP_TERRATEC_CINERGY_C_PCI"rc-terratec-cinergy-c-pci"
 #define RC_MAP_TERRATEC_CINERGY_XS   "rc-terratec-cinergy-xs"
 #define RC_MAP_TERRATEC_SLIM "rc-terratec-slim"
 #define RC_MAP_TERRATEC_SLIM_2   "rc-terratec-slim-2"
-- 
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: Si2168 B40 frimware.

2015-06-06 Thread Antti Palosaari

On 06/06/2015 11:02 PM, Unembossed Name wrote:

Anybody want to test it? Unfortunately, I can not do it myself, because
I do not own hardware with B40 revision.


That does not even download. It looks like 17 byte chunk format, but
it does not divide by 17. Probably there is some bytes missing or too
many at the end of file.

That is how first 16 bytes of those firmwares looks:
4.0.4:  05 00 aa 4d 56 40 00 00  0c 6a 7e aa ef 51 da 89
4.0.11: 08 05 00 8d fc 56 40 00  00 00 00 00 00 00 00 00
4.0.19: 08 05 00 f0 9a 56 40 00  00 00 00 00 00 00 00 00

4.0.4 is 8 byte chunks, 4.0.11 is 17 byte.


Hi Antti,

You're right. I've made a mistake with determining of the end of a
patch. It seems I  blindly used an obsolete information about size it
should be. And because of that, these version of a patch can be even
more recent. Like 4.0.20.

Could you please check it again? And in case of success see which
version it is?

file
name:dvb-demod-si2168-b40-rom4_0_2-patch-build-probably4_0_19.fw.tar.gz
http://beholder.ru/bb/download/file.php?id=857
Best regards.


That one works, DVB-T/T2 scan tested.

si2168 6-0064: found a 'Silicon Labs Si2168-B40'
si2168 6-0064: downloading firmware from file 'dvb-demod-si2168-b40-01.fw'
si2168 6-0064: firmware version: 4.0.19
si2157 7-0060: found a 'Silicon Labs Si2157-A30'
si2157 7-0060: firmware version: 3.0.5

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


[PATCH] [media] airspy: add missing include of linux/mm.h

2015-06-06 Thread Hauke Mehrtens
airspy uses PAGE_ALIGN() which is defined in linux/mm.h, but this file
is not directly included just indirectly thought some other include
file.

Signed-off-by: Hauke Mehrtens 
---
 drivers/media/usb/airspy/airspy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/airspy/airspy.c 
b/drivers/media/usb/airspy/airspy.c
index 4069234..d182dd2 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -15,6 +15,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
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] [media] hackrf: add missing include of linux/mm.h

2015-06-06 Thread Hauke Mehrtens
hackrf uses PAGE_ALIGN() which is defined in linux/mm.h, but this file
is not directly included just indirectly thought some other include
file.

Signed-off-by: Hauke Mehrtens 
---
 drivers/media/usb/hackrf/hackrf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/hackrf/hackrf.c 
b/drivers/media/usb/hackrf/hackrf.c
index fd1fa41..2eade31 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -15,6 +15,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
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: Si2168 B40 frimware.

2015-06-06 Thread Unembossed Name

From: "Antti Palosaari"
To: "Unembossed Name"
Sent: Sunday, June 07, 2015 12:43 AM
Subject: Re: Si2168 B40 frimware.



Anybody want to test it? Unfortunately, I can not do it myself, because
I do not own hardware with B40 revision.


That does not even download. It looks like 17 byte chunk format, but it 
does not divide by 17. Probably there is some bytes missing or too many 
at the end of file.


That is how first 16 bytes of those firmwares looks:
4.0.4:  05 00 aa 4d 56 40 00 00  0c 6a 7e aa ef 51 da 89
4.0.11: 08 05 00 8d fc 56 40 00  00 00 00 00 00 00 00 00
4.0.19: 08 05 00 f0 9a 56 40 00  00 00 00 00 00 00 00 00

4.0.4 is 8 byte chunks, 4.0.11 is 17 byte.


Hi Antti,

You're right. I've made a mistake with determining of the end of a patch. It seems I  blindly used an obsolete information about 
size it should be. And because of that, these version of a patch can be even more recent. Like 4.0.20.


Could you please check it again? And in case of success see which version it is?

file name:dvb-demod-si2168-b40-rom4_0_2-patch-build-probably4_0_19.fw.tar.gz
http://beholder.ru/bb/download/file.php?id=857 


Best regards.
--
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: Si2168 B40 frimware.

2015-06-06 Thread Antti Palosaari

On 06/06/2015 06:28 AM, Unembossed Name wrote:

Hi,

Yesterday I extracted a new firmware for Si2168 B40 rev. from Windows
driver.
It's designed for ROM version 4.0.2 and has a version build 4.0.19
Here is a name of
file:dvb-demod-si2168-b40-rom4_0_2-patch-build4_0_19.fw.tar.gz
And a link for download: http://beholder.ru/bb/download/file.php?id=854
Anybody want to test it? Unfortunately, I can not do it myself, because
I do not own hardware with B40 revision.


That does not even download. It looks like 17 byte chunk format, but it 
does not divide by 17. Probably there is some bytes missing or too many 
at the end of file.


That is how first 16 bytes of those firmwares looks:
4.0.4:  05 00 aa 4d 56 40 00 00  0c 6a 7e aa ef 51 da 89
4.0.11: 08 05 00 8d fc 56 40 00  00 00 00 00 00 00 00 00
4.0.19: 08 05 00 f0 9a 56 40 00  00 00 00 00 00 00 00 00

4.0.4 is 8 byte chunks, 4.0.11 is 17 byte.

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


[PATCH] [media] dvb-core: prevent some corruption the legacy ioctl

2015-06-06 Thread Dan Carpenter
Quite a few of the ->diseqc_send_master_cmd() implementations don't
check cmd->msg_len so it can lead to memory corruption.

Signed-off-by: Dan Carpenter 
---
I don't think it ever makes sense for ->msg_len to be longer than ->msg
but I am a newbie to this code.

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index a894d4c..aa6b48f 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -2403,7 +2403,13 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
 
case FE_DISEQC_SEND_MASTER_CMD:
if (fe->ops.diseqc_send_master_cmd) {
-   err = fe->ops.diseqc_send_master_cmd(fe, (struct 
dvb_diseqc_master_cmd*) parg);
+   struct dvb_diseqc_master_cmd *cmd = parg;
+
+   if (cmd->msg_len > sizeof(cmd->msg)) {
+   err = -EINVAL;
+   break;
+   }
+   err = fe->ops.diseqc_send_master_cmd(fe, cmd);
fepriv->state = FESTATE_DISEQC;
fepriv->status = 0;
}
--
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: si2168/dvbsky - blind-scan for DVB-T2 with PLP fails

2015-06-06 Thread Antti Palosaari

On 06/06/2015 05:07 PM, Hurda wrote:

Thanks, this worked.
The kernel of Ubuntu 15.04 already was compiled with dynamic debug,
which saved
me a lot of time.
The driver is properly setting stream_id to 1 when needed.

I tried again with the vanilla source and "cmd.args[2] = 0;".
With the vanilla source, it doesn't find any T2-transponders.


You mean with vanilla source, but without that "cmd.args[2] = 0;" hack 
it does not find any transponders?




With the modified source, the number of found transponders changes every
time


You mean with source, modified with that "cmd.args[2] = 0;" hack it 
finds transponders, but not always?


If that is difference, then it sounds just like application is 
requesting some PLP, probably 0, and it will not work as your network 
delivers channels using PLP 1.


"cmd.args[2] = 0;" disables PLP filtering - it sets auto mode. Why it 
likely does not find all channels is too short timeout.


Increase timeout value to 3 second, 900 => 3000, in funtion 
si2168_get_tune_settings()



You didn't provide any debugs to see what PLP ID your application is 
requesting. It is the most important thing I would like to know, as I 
suspect it is wrong.


regards
Antti




I'm scanning.
I did four runs: twice it found one mux, once it found two and once it
found
three, but never all four.
I even tried with w_scan-options for longer tuner- and demux-timeouts.

Without changing the position of the antenna or the stick, after
reinstalling
the dvbsky-driver, it found all four T2-muxes on the first try.


On 04.06.2015 21:28, Antti Palosaari wrote:



On 06/04/2015 08:36 PM, Hurda wrote:

How can I enable debug-output to get the log-messages like
http://git.linuxtv.org/cgit.cgi/media_tree.git/tree/drivers/media/dvb-frontends/si2168.c#n164

?


Compile kernel with dynamic debugs. After that you could enable debugs:
modprobe si2168; echo -n 'module si2168 =pft' >
/sys/kernel/debug/dynamic_debug/control

Antti




Am 28.05.2015 07:26, schrieb Antti Palosaari:

On 05/28/2015 01:27 AM, Hurda wrote:

Hello.

I think I came across a bug in either of the drivers si2168 and dvbsky
regarding
blind-scanning DVB-T2-frequencies.

HW: Technotrend CT2-4400v2 (afaik based on or the same as DVBSky T330)
 demod: Si2168-B40
 tuner: Si2158-A20
OS: Ubuntu 15.04 (kernel 3.19)

In Austria, the DVB-T2-service "SimpliTV" is currently airing up to
four
muxes, next to one or two DVB-T-muxes.
In my region, the frequencies are 490MHz, 546MHz, 690MHz, 714MHz for
DVB-T2,
and 498MHz for DVB-T.
These numbers might be of interest when reading the logs.

The peculiar aspect of these T2-muxes is that they're aired on PLP 1
without
there being a PLP 0. I think this is also the root of my problem.


dvbv5-scan is working, but w_scan not?

Could you hack si2168.c file and test?

if (c->delivery_system == SYS_DVBT2) {
/* select PLP */
cmd.args[0] = 0x52;
cmd.args[1] = c->stream_id & 0xff;
//cmd.args[2] = c->stream_id == NO_STREAM_ID_FILTER ? 0 : 1;
cmd.args[2] = 0;
cmd.wlen = 3;
cmd.rlen = 1;
ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
}

Antti




When doing a blind-scan using w_scan 20140727 on Ubuntu 15.04 (kernel
3.19),
w_scan does not find any of these four DVB-T2-muxes.
It just finds the DVB-T-mux.

Logs:
media-tree_dmesg_lsusb.txt http://pastebin.com/0ixFPMSA
media-tree_w_scan.txt http://pastebin.com/yyG3jSwj

The found transponder:
initial_v3_media_build_trunk.conf http://pastebin.com/LmFQavpy
initial_v5.conf http://pastebin.com/Jx6kymVt

I also tried a fresh checkout from git.linuxtv.org as of last weekend
and the
most recent w_scan version (20141122).

As you can see, w_scan tries to tune(?) the DVB-T2-frequencies, but
ultimately doesn't find anything on them.


Then I tried the DVBSky-linux-driver[1]
(media_build-bst-20150322.tar.gz)[2]
from their site, which is using a binary called sit2 for this card.
Using this driver, w_scan found all four DVB-T2-muxes and the
DVB-T-mux.
Additionally, it found the DVB-T2-muxes during the DVB-T-scan.

Logs:
media_build-bst_dmesg_lsusb.txt http://pastebin.com/vJeDMxtu
media_build-bst_w_scan.txt http://pastebin.com/yhwAYjen

Found transponders:
initial_v3_bst.conf http://pastebin.com/ECKQvRWX
initial_v5_bst.conf http://pastebin.com/CbhY6Hpz

Of course, doing a channel-scan using dvbv5-scan on these transponders
worked
too:

dvbv5_sit2.conf http://pastebin.com/3W52bbhv
dvbv5_sit2.log http://pastebin.com/nc66PTkt

Afterwards, I tried to do a channel-scan with the same initial
tuning-file
using the opensource-driver, which also worked:

dvbv5_si2168.conf http://pastebin.com/A6FbqUL1
dvbv5_si2168.log http://pastebin.com/ewyVPJR2

This should verify that tuning PLP 1 without there being PLP 0 is not
the issue.


Additionally, if you compare the two channel-lists, you find
interesting
differences:

The scan with si2168 has AUTO for "MODULATION" and "INVERSION" for
DVB-T2-channels, and for "CODE_RATE_LP" and "INVERSION" for
DV

Re: si2168/dvbsky - blind-scan for DVB-T2 with PLP fails

2015-06-06 Thread Hurda

Thanks, this worked.
The kernel of Ubuntu 15.04 already was compiled with dynamic debug, which saved
me a lot of time.
The driver is properly setting stream_id to 1 when needed.

I tried again with the vanilla source and "cmd.args[2] = 0;".
With the vanilla source, it doesn't find any T2-transponders.

With the modified source, the number of found transponders changes every time
I'm scanning.
I did four runs: twice it found one mux, once it found two and once it found
three, but never all four.
I even tried with w_scan-options for longer tuner- and demux-timeouts.

Without changing the position of the antenna or the stick, after reinstalling
the dvbsky-driver, it found all four T2-muxes on the first try.


On 04.06.2015 21:28, Antti Palosaari wrote:



On 06/04/2015 08:36 PM, Hurda wrote:

How can I enable debug-output to get the log-messages like
http://git.linuxtv.org/cgit.cgi/media_tree.git/tree/drivers/media/dvb-frontends/si2168.c#n164 


?


Compile kernel with dynamic debugs. After that you could enable debugs:
modprobe si2168; echo -n 'module si2168 =pft' > 
/sys/kernel/debug/dynamic_debug/control


Antti




Am 28.05.2015 07:26, schrieb Antti Palosaari:

On 05/28/2015 01:27 AM, Hurda wrote:

Hello.

I think I came across a bug in either of the drivers si2168 and dvbsky
regarding
blind-scanning DVB-T2-frequencies.

HW: Technotrend CT2-4400v2 (afaik based on or the same as DVBSky T330)
 demod: Si2168-B40
 tuner: Si2158-A20
OS: Ubuntu 15.04 (kernel 3.19)

In Austria, the DVB-T2-service "SimpliTV" is currently airing up to four
muxes, next to one or two DVB-T-muxes.
In my region, the frequencies are 490MHz, 546MHz, 690MHz, 714MHz for
DVB-T2,
and 498MHz for DVB-T.
These numbers might be of interest when reading the logs.

The peculiar aspect of these T2-muxes is that they're aired on PLP 1
without
there being a PLP 0. I think this is also the root of my problem.


dvbv5-scan is working, but w_scan not?

Could you hack si2168.c file and test?

if (c->delivery_system == SYS_DVBT2) {
/* select PLP */
cmd.args[0] = 0x52;
cmd.args[1] = c->stream_id & 0xff;
//cmd.args[2] = c->stream_id == NO_STREAM_ID_FILTER ? 0 : 1;
cmd.args[2] = 0;
cmd.wlen = 3;
cmd.rlen = 1;
ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
}

Antti




When doing a blind-scan using w_scan 20140727 on Ubuntu 15.04 (kernel
3.19),
w_scan does not find any of these four DVB-T2-muxes.
It just finds the DVB-T-mux.

Logs:
media-tree_dmesg_lsusb.txt http://pastebin.com/0ixFPMSA
media-tree_w_scan.txt http://pastebin.com/yyG3jSwj

The found transponder:
initial_v3_media_build_trunk.conf http://pastebin.com/LmFQavpy
initial_v5.conf http://pastebin.com/Jx6kymVt

I also tried a fresh checkout from git.linuxtv.org as of last weekend
and the
most recent w_scan version (20141122).

As you can see, w_scan tries to tune(?) the DVB-T2-frequencies, but
ultimately doesn't find anything on them.


Then I tried the DVBSky-linux-driver[1]
(media_build-bst-20150322.tar.gz)[2]
from their site, which is using a binary called sit2 for this card.
Using this driver, w_scan found all four DVB-T2-muxes and the DVB-T-mux.
Additionally, it found the DVB-T2-muxes during the DVB-T-scan.

Logs:
media_build-bst_dmesg_lsusb.txt http://pastebin.com/vJeDMxtu
media_build-bst_w_scan.txt http://pastebin.com/yhwAYjen

Found transponders:
initial_v3_bst.conf http://pastebin.com/ECKQvRWX
initial_v5_bst.conf http://pastebin.com/CbhY6Hpz

Of course, doing a channel-scan using dvbv5-scan on these transponders
worked
too:

dvbv5_sit2.conf http://pastebin.com/3W52bbhv
dvbv5_sit2.log http://pastebin.com/nc66PTkt

Afterwards, I tried to do a channel-scan with the same initial
tuning-file
using the opensource-driver, which also worked:

dvbv5_si2168.conf http://pastebin.com/A6FbqUL1
dvbv5_si2168.log http://pastebin.com/ewyVPJR2

This should verify that tuning PLP 1 without there being PLP 0 is not
the issue.


Additionally, if you compare the two channel-lists, you find interesting
differences:

The scan with si2168 has AUTO for "MODULATION" and "INVERSION" for
DVB-T2-channels, and for "CODE_RATE_LP" and "INVERSION" for
DVB-T-channels.

The scan with sit2 has the respective values in the channel-list.

The dvbv5-scan-logs also differ, as using sit2 also displays the signal
quality
during tuning.


I know that there were changes regarding DVB-T2-scanning[3], but as the
blog-
article specifically mentions si2168 and w_scan to be fully
dvbv5-compliant
and good for using with DVB-T2, I thought you should know about this
particular problem.


In the attachment I've packed the previously linked logs, for archival
reasons.


Thank you for your attention.

[1] http://www.dvbsky.net/Support_linux.html
[2] http://www.dvbsky.net/download/linux/media_build-bst-150322.tar.gz
[3] http://blog.palosaari.fi/2014/09/linux-dvb-t2-tuning-problems.html

PS: Interesting comments regarding auto-detection for si2168:
http://blog.palosaari.fi/2014/09/linux

Re: [PATCH] radio-bcm2048: Enable access to automute and ctrl registers

2015-06-06 Thread Pavel Machek
On Fri 2015-06-05 13:34:01, Hans Verkuil wrote:
> On 05/15/2015 11:31 PM, Pali Rohár wrote:
> > From: maxx 
> > 
> > This enables access to automute function of the chip via sysfs and
> > gives direct access to FM_AUDIO_CTRL0/1 registers, also via sysfs. I
> > don't think this is so important but helps in developing radio scanner
> > apps.
> > 
> > Patch writen by m...@spaceboyz.net
> > 
> > Signed-off-by: Pali Rohár 
> > Cc: m...@spaceboyz.net
> 
> As Pavel mentioned, these patches need to be resend with correct Signed-off-by
> lines.
> 
> Regarding this patch: I don't want to apply this since this really should be a
> control. Or just enable it always. If someone wants to make this a control, 
> then
> let me know: there are two other drivers with an AUTOMUTE control: bttv and 
> saa7134.
> 
> In both cases it is implemented as a private control, but it makes sense to
> promote this to a standard user control. I can make a patch for that.
> 
> And for CTRL0/1: if you want direct register access, then implement
> VIDIOC_DBG_G/S_REGISTER. This makes sure you have the right permissions etc.
> 
> More importantly: is anyone working on getting this driver out of staging? 
> It's
> been here for about a year and a half and I haven't seen any efforts to clean 
> it up.

Yes, there are. Unfortunately, this one depends on bluetooth driver, and we 
have some
fun with that one. So please be patient...


Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.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


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

2015-06-06 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 | 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
@@ -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,44 @@ 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 RX_ON3
+#define TX_ON4
+#define RX_V4L2_DEV_OPEN 5
+#define TX_V4L2_DEV_OPEN 6
+#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;
+
+   /* For RX / TX dev exclusive use */
+   int users;
+   struct mutex v4l2_open_release_mutex;
 
/* 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 +149,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 +206,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:
 

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

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

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 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_TYPE_S

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

2015-06-06 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 | 19 +++
 Documentation/DocBook/media/v4l/v4l2.xml |  1 +
 3 files changed, 24 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index f56faf5..e8f28bf 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_AUTO and
+V4L2_CID_RF_TUNER_RF_GAIN RF Tuner controls.
+   
   
 
 
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 6e1667b..44f7a3a 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -5397,6 +5397,13 @@ fulfill desired bandwidth requirement. Used when 
V4L2_CID_RF_TUNER_BANDWIDTH_AUT
 set. Unit is in Hz. The range and step are driver-specific.
 
 
+  V4L2_CID_RF_TUNER_RF_GAIN_AUTO 
+  boolean
+
+
+  Enables/disables RF amplifier automatic 
gain control (AGC)
+
+
   V4L2_CID_RF_TUNER_LNA_GAIN_AUTO 
   boolean
 
@@ -5418,6 +5425,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
+
+
+  RF amplifier is very first amplifier on
+the receiver signal path, just right after antenna input. Difference between
+LNA gain and RF gain on this document and context is that LNA gain is 
integrated
+to tuner chip whilst RF gain is separate chip. There may be both, RF and LNA
+gain control, on same device. Used when 
V4L2_CID_RF_TUNER_RF_GAIN_AUTO is not set.
+The range and step are driver-specific.
+
+
   V4L2_CID_RF_TUNER_LNA_GAIN 
   integer
 
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml 
b/Documentation/DocBook/media/v4l/v4l2.xml
index c9eedc1..b94d381 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_AUTO and V4L2_CID_RF_TUNER_RF_GAIN controls.

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


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

2015-06-06 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;
+   

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

2015-06-06 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 3d5fc72..3310ce4 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


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

2015-06-06 Thread Antti Palosaari
Add new RF tuner gain control named RF gain. That is aimed for
external LNA (amplifier) chip just right after antenna connector.

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

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index e3a3468..0fc34b8 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -888,6 +888,8 @@ 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_AUTO:return "RF Gain, Auto";
+   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";
@@ -960,6 +962,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum 
v4l2_ctrl_type *type,
case V4L2_CID_WIDE_DYNAMIC_RANGE:
case V4L2_CID_IMAGE_STABILIZATION:
case V4L2_CID_RDS_RECEPTION:
+   case V4L2_CID_RF_TUNER_RF_GAIN_AUTO:
case V4L2_CID_RF_TUNER_LNA_GAIN_AUTO:
case V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO:
case V4L2_CID_RF_TUNER_IF_GAIN_AUTO:
@@ -1161,6 +1164,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..87539be 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -932,6 +932,8 @@ 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_AUTO (V4L2_CID_RF_TUNER_CLASS_BASE + 
31)
+#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


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

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

Signed-off-by: Antti Palosaari 
---
 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 6ad6937..1f9483d 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,
},
@@ -977,7 +975,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


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

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


[PATCH 5/9] DocBook: document SDR transmitter

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

Cc: Hans Verkuil 
Signed-off-by: Antti Palosaari 
---
 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 e8f28bf..a237e36 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_AUTO and
 V4L2_CID_RF_TUNER_RF_GAIN RF Tuner controls.

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

[PATCH 2/8] ts2020: improve filter limit calc

2015-06-06 Thread Antti Palosaari
* We don't need calculate channel bandwidth from symbol rate as it
is calculated by DVB core.

* Use clamp() to force upper/lower limit of filter 3dB frequency.
Upper limit should never exceeded 40MHz (80MHz BW) in any case,
though...

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/ts2020.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index bc48388..590f7e1 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -233,7 +233,6 @@ static int ts2020_set_params(struct dvb_frontend *fe)
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct ts2020_priv *priv = fe->tuner_priv;
int ret;
-   u32 symbol_rate = (c->symbol_rate / 1000);
u32 f3db, gdiv28;
u16 u16tmp, value, lpf_coeff;
u8 buf[3], reg10, lpf_mxdiv, mlpf_max, mlpf_min, nlpf;
@@ -312,12 +311,9 @@ static int ts2020_set_params(struct dvb_frontend *fe)
 
value = ts2020_readreg(fe, 0x26);
 
-   f3db = (symbol_rate * 135) / 200 + 2000;
-   f3db += FREQ_OFFSET_LOW_SYM_RATE;
-   if (f3db < 7000)
-   f3db = 7000;
-   if (f3db > 4)
-   f3db = 4;
+   f3db = (c->bandwidth_hz / 1000 / 2) + 2000;
+   f3db += FREQ_OFFSET_LOW_SYM_RATE; /* FIXME: ~always too wide filter */
+   f3db = clamp(f3db, 7000U, 4U);
 
gdiv28 = gdiv28 * 207 / (value * 2 + 151);
mlpf_max = gdiv28 * 135 / 100;
-- 
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


[PATCH 3/8] ts2020: register I2C driver from legacy media attach

2015-06-06 Thread Antti Palosaari
Register driver using I2C bindings internally when legacy media
attach is used. That is done by registering driver using I2C binding
from legacy attach. That way we can get valid I2C client, which is
needed for proper dev_() logging and regmap for example even legacy
binding is used.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/ts2020.c | 73 
 drivers/media/dvb-frontends/ts2020.h |  7 +++-
 2 files changed, 30 insertions(+), 50 deletions(-)

diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index 590f7e1..7b2f301 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -26,6 +26,7 @@
 #define FREQ_OFFSET_LOW_SYM_RATE 3000
 
 struct ts2020_priv {
+   struct i2c_client *client;
struct dvb_frontend *fe;
/* i2c details */
int i2c_address;
@@ -47,8 +48,12 @@ struct ts2020_reg_val {
 
 static int ts2020_release(struct dvb_frontend *fe)
 {
-   kfree(fe->tuner_priv);
-   fe->tuner_priv = NULL;
+   struct ts2020_priv *priv = fe->tuner_priv;
+   struct i2c_client *client = priv->client;
+
+   dev_dbg(&client->dev, "\n");
+
+   i2c_unregister_device(client);
return 0;
 }
 
@@ -410,50 +415,22 @@ struct dvb_frontend *ts2020_attach(struct dvb_frontend 
*fe,
const struct ts2020_config *config,
struct i2c_adapter *i2c)
 {
-   struct ts2020_priv *priv = NULL;
-   u8 buf;
-
-   priv = kzalloc(sizeof(struct ts2020_priv), GFP_KERNEL);
-   if (priv == NULL)
+   struct i2c_client *client;
+   struct i2c_board_info board_info;
+   struct ts2020_config pdata;
+
+   memcpy(&pdata, config, sizeof(pdata));
+   pdata.fe = fe;
+   pdata.attach_in_use = true;
+
+   memset(&board_info, 0, sizeof(board_info));
+   strlcpy(board_info.type, "ts2020", I2C_NAME_SIZE);
+   board_info.addr = config->tuner_address;
+   board_info.platform_data = &pdata;
+   client = i2c_new_device(i2c, &board_info);
+   if (!client || !client->dev.driver)
return NULL;
 
-   priv->i2c_address = config->tuner_address;
-   priv->i2c = i2c;
-   priv->clk_out = config->clk_out;
-   priv->clk_out_div = config->clk_out_div;
-   priv->frequency_div = config->frequency_div;
-   priv->fe = fe;
-   fe->tuner_priv = priv;
-
-   if (!priv->frequency_div)
-   priv->frequency_div = 106;
-
-   /* Wake Up the tuner */
-   if ((0x03 & ts2020_readreg(fe, 0x00)) == 0x00) {
-   ts2020_writereg(fe, 0x00, 0x01);
-   msleep(2);
-   }
-
-   ts2020_writereg(fe, 0x00, 0x03);
-   msleep(2);
-
-   /* Check the tuner version */
-   buf = ts2020_readreg(fe, 0x00);
-   if ((buf == 0x01) || (buf == 0x41) || (buf == 0x81)) {
-   printk(KERN_INFO "%s: Find tuner TS2020!\n", __func__);
-   priv->tuner = TS2020_M88TS2020;
-   } else if ((buf == 0x83) || (buf == 0xc3)) {
-   printk(KERN_INFO "%s: Find tuner TS2022!\n", __func__);
-   priv->tuner = TS2020_M88TS2022;
-   } else {
-   printk(KERN_ERR "%s: Read tuner reg[0] = %d\n", __func__, buf);
-   kfree(priv);
-   return NULL;
-   }
-
-   memcpy(&fe->ops.tuner_ops, &ts2020_tuner_ops,
-   sizeof(struct dvb_tuner_ops));
-
return fe;
 }
 EXPORT_SYMBOL(ts2020_attach);
@@ -482,6 +459,7 @@ static int ts2020_probe(struct i2c_client *client,
dev->frequency_div = pdata->frequency_div;
dev->fe = fe;
fe->tuner_priv = dev;
+   dev->client = client;
 
/* check if the tuner is there */
ret = ts2020_readreg(fe, 0x00);
@@ -574,7 +552,8 @@ static int ts2020_probe(struct i2c_client *client,
 
memcpy(&fe->ops.tuner_ops, &ts2020_tuner_ops,
sizeof(struct dvb_tuner_ops));
-   fe->ops.tuner_ops.release = NULL;
+   if (!pdata->attach_in_use)
+   fe->ops.tuner_ops.release = NULL;
 
i2c_set_clientdata(client, dev);
return 0;
@@ -587,14 +566,10 @@ err:
 static int ts2020_remove(struct i2c_client *client)
 {
struct ts2020_priv *dev = i2c_get_clientdata(client);
-   struct dvb_frontend *fe = dev->fe;
 
dev_dbg(&client->dev, "\n");
 
-   memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
-   fe->tuner_priv = NULL;
kfree(dev);
-
return 0;
 }
 
diff --git a/drivers/media/dvb-frontends/ts2020.h 
b/drivers/media/dvb-frontends/ts2020.h
index 1714af9..f40bbcf 100644
--- a/drivers/media/dvb-frontends/ts2020.h
+++ b/drivers/media/dvb-frontends/ts2020.h
@@ -52,10 +52,15 @@ struct ts2020_config {
 * pointer to DVB frontend
 */
struct dvb_frontend *fe;
+
+   /*
+* driver private, do not set value
+   

[PATCH 5/8] ts2020: Add a comment about lifetime of on-stack pdata in ts2020_attach()

2015-06-06 Thread Antti Palosaari
From: David Howells 

ts2020_attach() allocates a variable pdata on the stack and then passes a
pointer to it to i2c_new_device() which stashes the pointer in persistent
structures.

Add a comment to the effect that this isn't actually an error because the
contents of the variable are only used in ts2020_probe() and this is only
called ts2020_attach()'s stack frame exists.

Signed-off-by: David Howells 
Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/ts2020.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index 797112b..f674717 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -363,6 +363,8 @@ struct dvb_frontend *ts2020_attach(struct dvb_frontend *fe,
 {
struct i2c_client *client;
struct i2c_board_info board_info;
+
+   /* This is only used by ts2020_probe() so can be on the stack */
struct ts2020_config pdata;
 
memcpy(&pdata, config, sizeof(pdata));
-- 
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


[PATCH 4/8] ts2020: convert to regmap I2C API

2015-06-06 Thread Antti Palosaari
Use regmap to cover I2C register access.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/Kconfig  |   3 +-
 drivers/media/dvb-frontends/ts2020.c | 260 ---
 2 files changed, 124 insertions(+), 139 deletions(-)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 65034a8..ba65a00 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -239,7 +239,8 @@ config DVB_SI21XX
 
 config DVB_TS2020
tristate "Montage Tehnology TS2020 based tuners"
-   depends on DVB_CORE && I2C
+   depends on DVB_CORE
+   select REGMAP_I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
  A DVB-S/S2 silicon tuner. Say Y when you want to support this tuner.
diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index 7b2f301..797112b 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -21,12 +21,16 @@
 
 #include "dvb_frontend.h"
 #include "ts2020.h"
+#include 
 
 #define TS2020_XTAL_FREQ   27000 /* in kHz */
 #define FREQ_OFFSET_LOW_SYM_RATE 3000
 
 struct ts2020_priv {
struct i2c_client *client;
+   struct mutex regmap_mutex;
+   struct regmap_config regmap_config;
+   struct regmap *regmap;
struct dvb_frontend *fe;
/* i2c details */
int i2c_address;
@@ -57,74 +61,6 @@ static int ts2020_release(struct dvb_frontend *fe)
return 0;
 }
 
-static int ts2020_writereg(struct dvb_frontend *fe, int reg, int data)
-{
-   struct ts2020_priv *priv = fe->tuner_priv;
-   u8 buf[] = { reg, data };
-   struct i2c_msg msg[] = {
-   {
-   .addr = priv->i2c_address,
-   .flags = 0,
-   .buf = buf,
-   .len = 2
-   }
-   };
-   int err;
-
-   if (fe->ops.i2c_gate_ctrl)
-   fe->ops.i2c_gate_ctrl(fe, 1);
-
-   err = i2c_transfer(priv->i2c, msg, 1);
-   if (err != 1) {
-   printk(KERN_ERR
-  "%s: writereg error(err == %i, reg == 0x%02x, value == 
0x%02x)\n",
-  __func__, err, reg, data);
-   return -EREMOTEIO;
-   }
-
-   if (fe->ops.i2c_gate_ctrl)
-   fe->ops.i2c_gate_ctrl(fe, 0);
-
-   return 0;
-}
-
-static int ts2020_readreg(struct dvb_frontend *fe, u8 reg)
-{
-   struct ts2020_priv *priv = fe->tuner_priv;
-   int ret;
-   u8 b0[] = { reg };
-   u8 b1[] = { 0 };
-   struct i2c_msg msg[] = {
-   {
-   .addr = priv->i2c_address,
-   .flags = 0,
-   .buf = b0,
-   .len = 1
-   }, {
-   .addr = priv->i2c_address,
-   .flags = I2C_M_RD,
-   .buf = b1,
-   .len = 1
-   }
-   };
-
-   if (fe->ops.i2c_gate_ctrl)
-   fe->ops.i2c_gate_ctrl(fe, 1);
-
-   ret = i2c_transfer(priv->i2c, msg, 2);
-
-   if (ret != 2) {
-   printk(KERN_ERR "%s: reg=0x%x(error=%d)\n",
-  __func__, reg, ret);
-   return ret;
-   }
-
-   if (fe->ops.i2c_gate_ctrl)
-   fe->ops.i2c_gate_ctrl(fe, 0);
-
-   return b1[0];
-}
-
 static int ts2020_sleep(struct dvb_frontend *fe)
 {
struct ts2020_priv *priv = fe->tuner_priv;
@@ -135,7 +71,7 @@ static int ts2020_sleep(struct dvb_frontend *fe)
else
u8tmp = 0x00;
 
-   return ts2020_writereg(fe, u8tmp, 0x00);
+   return regmap_write(priv->regmap, u8tmp, 0x00);
 }
 
 static int ts2020_init(struct dvb_frontend *fe)
@@ -145,14 +81,14 @@ static int ts2020_init(struct dvb_frontend *fe)
u8 u8tmp;
 
if (priv->tuner == TS2020_M88TS2020) {
-   ts2020_writereg(fe, 0x42, 0x73);
-   ts2020_writereg(fe, 0x05, priv->clk_out_div);
-   ts2020_writereg(fe, 0x20, 0x27);
-   ts2020_writereg(fe, 0x07, 0x02);
-   ts2020_writereg(fe, 0x11, 0xff);
-   ts2020_writereg(fe, 0x60, 0xf9);
-   ts2020_writereg(fe, 0x08, 0x01);
-   ts2020_writereg(fe, 0x00, 0x41);
+   regmap_write(priv->regmap, 0x42, 0x73);
+   regmap_write(priv->regmap, 0x05, priv->clk_out_div);
+   regmap_write(priv->regmap, 0x20, 0x27);
+   regmap_write(priv->regmap, 0x07, 0x02);
+   regmap_write(priv->regmap, 0x11, 0xff);
+   regmap_write(priv->regmap, 0x60, 0xf9);
+   regmap_write(priv->regmap, 0x08, 0x01);
+   regmap_write(priv->regmap, 0x00, 0x41);
} else {
static const struct ts2020_reg_val reg_vals[] = {
{0x7d, 0x9d},
@@ -168,8 +104,8 @@ static int ts2020_init(struct dvb_frontend *fe

[PATCH 8/8] em28xx: PCTV 461e use I2C client for demod and SEC

2015-06-06 Thread Antti Palosaari
Use I2C client binding for demod and SEC.

Signed-off-by: Antti Palosaari 
---
 drivers/media/usb/em28xx/em28xx-dvb.c | 136 +-
 1 file changed, 83 insertions(+), 53 deletions(-)

diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
b/drivers/media/usb/em28xx/em28xx-dvb.c
index be0abca..a382483 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -1521,64 +1521,94 @@ static int em28xx_dvb_init(struct em28xx *dev)
}
}
break;
-   case EM28178_BOARD_PCTV_461E:
-   {
-   /* demod I2C adapter */
-   struct i2c_adapter *i2c_adapter;
-   struct i2c_client *client;
-   struct i2c_board_info info;
-   struct ts2020_config ts2020_config = {
-   };
-   memset(&info, 0, sizeof(struct i2c_board_info));
-
-   /* attach demod */
-   dvb->fe[0] = dvb_attach(m88ds3103_attach,
-   &pctv_461e_m88ds3103_config,
-   &dev->i2c_adap[dev->def_i2c_bus],
-   &i2c_adapter);
-   if (dvb->fe[0] == NULL) {
-   result = -ENODEV;
-   goto out_free;
-   }
-
-   /* attach tuner */
-   ts2020_config.fe = dvb->fe[0];
-   strlcpy(info.type, "ts2022", I2C_NAME_SIZE);
-   info.addr = 0x60;
-   info.platform_data = &ts2020_config;
-   request_module("ts2020");
-   client = i2c_new_device(i2c_adapter, &info);
-   if (client == NULL || client->dev.driver == NULL) {
-   dvb_frontend_detach(dvb->fe[0]);
-   result = -ENODEV;
-   goto out_free;
-   }
-
-   if (!try_module_get(client->dev.driver->owner)) {
-   i2c_unregister_device(client);
-   dvb_frontend_detach(dvb->fe[0]);
-   result = -ENODEV;
-   goto out_free;
-   }
+   case EM28178_BOARD_PCTV_461E: {
+   struct i2c_client *client;
+   struct i2c_adapter *i2c_adapter;
+   struct i2c_board_info board_info;
+   struct m88ds3103_platform_data m88ds3103_pdata = {};
+   struct ts2020_config ts2020_config = {};
+   struct a8293_platform_data a8293_pdata = {};
 
-   /* delegate signal strength measurement to tuner */
-   dvb->fe[0]->ops.read_signal_strength =
-   
dvb->fe[0]->ops.tuner_ops.get_rf_strength;
+   /* attach demod */
+   m88ds3103_pdata.clk = 2700;
+   m88ds3103_pdata.i2c_wr_max = 33;
+   m88ds3103_pdata.ts_mode = M88DS3103_TS_PARALLEL;
+   m88ds3103_pdata.ts_clk = 16000;
+   m88ds3103_pdata.ts_clk_pol = 1;
+   m88ds3103_pdata.agc = 0x99;
+   memset(&board_info, 0, sizeof(board_info));
+   strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE);
+   board_info.addr = 0x68;
+   board_info.platform_data = &m88ds3103_pdata;
+   request_module("m88ds3103");
+   client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], 
&board_info);
+   if (client == NULL || client->dev.driver == NULL) {
+   result = -ENODEV;
+   goto out_free;
+   }
+   if (!try_module_get(client->dev.driver->owner)) {
+   i2c_unregister_device(client);
+   result = -ENODEV;
+   goto out_free;
+   }
+   dvb->fe[0] = m88ds3103_pdata.get_dvb_frontend(client);
+   i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client);
+   dvb->i2c_client_demod = client;
 
-   /* attach SEC */
-   if (!dvb_attach(a8293_attach, dvb->fe[0],
-   &dev->i2c_adap[dev->def_i2c_bus],
-   &em28xx_a8293_config)) {
-   module_put(client->dev.driver->owner);
-   i2c_unregister_device(client);
-   dvb_frontend_detach(dvb->fe[0]);
-   result = -ENODEV;
-   goto out_free;
-   }
+   /* attach tuner */
+   ts2020_config.fe = dvb->fe[0];
+   memset(&

[PATCH 1/8] ts2020: re-implement PLL calculations

2015-06-06 Thread Antti Palosaari
Used frequency synthesizer is simple Integer-N PLL, with configurable
reference divider, output divider and of course N itself. Old
calculations were working fine, but not so easy to understand.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/ts2020.c | 76 +---
 1 file changed, 44 insertions(+), 32 deletions(-)

diff --git a/drivers/media/dvb-frontends/ts2020.c 
b/drivers/media/dvb-frontends/ts2020.c
index 90164a3..bc48388 100644
--- a/drivers/media/dvb-frontends/ts2020.c
+++ b/drivers/media/dvb-frontends/ts2020.c
@@ -32,8 +32,8 @@ struct ts2020_priv {
struct i2c_adapter *i2c;
u8 clk_out:2;
u8 clk_out_div:5;
-   u32 frequency;
-   u32 frequency_div;
+   u32 frequency_div; /* LO output divider switch frequency */
+   u32 frequency_khz; /* actual used LO frequency */
 #define TS2020_M88TS2020 0
 #define TS2020_M88TS2022 1
u8 tuner;
@@ -233,45 +233,62 @@ static int ts2020_set_params(struct dvb_frontend *fe)
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct ts2020_priv *priv = fe->tuner_priv;
int ret;
-   u32 frequency = c->frequency;
-   s32 offset_khz;
u32 symbol_rate = (c->symbol_rate / 1000);
u32 f3db, gdiv28;
-   u16 value, ndiv, lpf_coeff;
-   u8 lpf_mxdiv, mlpf_max, mlpf_min, nlpf;
-   u8 lo = 0x01, div4 = 0x0;
-
-   /* Calculate frequency divider */
-   if (frequency < priv->frequency_div) {
-   lo |= 0x10;
-   div4 = 0x1;
-   ndiv = (frequency * 14 * 4) / TS2020_XTAL_FREQ;
-   } else
-   ndiv = (frequency * 14 * 2) / TS2020_XTAL_FREQ;
-   ndiv = ndiv + ndiv % 2;
-   ndiv = ndiv - 1024;
+   u16 u16tmp, value, lpf_coeff;
+   u8 buf[3], reg10, lpf_mxdiv, mlpf_max, mlpf_min, nlpf;
+   unsigned int f_ref_khz, f_vco_khz, div_ref, div_out, pll_n;
+   unsigned int frequency_khz = c->frequency;
+
+   /*
+* Integer-N PLL synthesizer
+* kHz is used for all calculations to keep calculations within 32-bit
+*/
+   f_ref_khz = TS2020_XTAL_FREQ;
+   div_ref = DIV_ROUND_CLOSEST(f_ref_khz, 2000);
+
+   /* select LO output divider */
+   if (frequency_khz < priv->frequency_div) {
+   div_out = 4;
+   reg10 = 0x10;
+   } else {
+   div_out = 2;
+   reg10 = 0x00;
+   }
+
+   f_vco_khz = frequency_khz * div_out;
+   pll_n = f_vco_khz * div_ref / f_ref_khz;
+   pll_n += pll_n % 2;
+   priv->frequency_khz = pll_n * f_ref_khz / div_ref / div_out;
+
+   pr_debug("frequency=%u offset=%d f_vco_khz=%u pll_n=%u div_ref=%u 
div_out=%u\n",
+priv->frequency_khz, priv->frequency_khz - c->frequency,
+f_vco_khz, pll_n, div_ref, div_out);
 
if (priv->tuner == TS2020_M88TS2020) {
lpf_coeff = 2766;
-   ret = ts2020_writereg(fe, 0x10, 0x80 | lo);
+   reg10 |= 0x01;
+   ret = ts2020_writereg(fe, 0x10, reg10);
} else {
lpf_coeff = 3200;
-   ret = ts2020_writereg(fe, 0x10, 0x0b);
+   reg10 |= 0x0b;
+   ret = ts2020_writereg(fe, 0x10, reg10);
ret |= ts2020_writereg(fe, 0x11, 0x40);
}
 
-   /* Set frequency divider */
-   ret |= ts2020_writereg(fe, 0x01, (ndiv >> 8) & 0xf);
-   ret |= ts2020_writereg(fe, 0x02, ndiv & 0xff);
+   u16tmp = pll_n - 1024;
+   buf[0] = (u16tmp >> 8) & 0xff;
+   buf[1] = (u16tmp >> 0) & 0xff;
+   buf[2] = div_ref - 8;
+
+   ret |= ts2020_writereg(fe, 0x01, buf[0]);
+   ret |= ts2020_writereg(fe, 0x02, buf[1]);
+   ret |= ts2020_writereg(fe, 0x03, buf[2]);
 
-   ret |= ts2020_writereg(fe, 0x03, 0x06);
ret |= ts2020_tuner_gate_ctrl(fe, 0x10);
if (ret < 0)
return -ENODEV;
 
-   /* Tuner Frequency Range */
-   ret = ts2020_writereg(fe, 0x10, lo);
-
ret |= ts2020_tuner_gate_ctrl(fe, 0x08);
 
/* Tuner RF */
@@ -335,11 +352,6 @@ static int ts2020_set_params(struct dvb_frontend *fe)
ret |= ts2020_tuner_gate_ctrl(fe, 0x01);
 
msleep(80);
-   /* calculate offset assuming 96000kHz*/
-   offset_khz = (ndiv - ndiv % 2 + 1024) * TS2020_XTAL_FREQ
-   / (6 + 8) / (div4 + 1) / 2;
-
-   priv->frequency = offset_khz;
 
return (ret < 0) ? -EINVAL : 0;
 }
@@ -347,8 +359,8 @@ static int ts2020_set_params(struct dvb_frontend *fe)
 static int ts2020_get_frequency(struct dvb_frontend *fe, u32 *frequency)
 {
struct ts2020_priv *priv = fe->tuner_priv;
-   *frequency = priv->frequency;
 
+   *frequency = priv->frequency_khz;
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

[PATCH 7/8] m88ds3103: use regmap for I2C register access

2015-06-06 Thread Antti Palosaari
Use regmap for I2C register access.
Remove own I2C repeated mutex as it should not be needed. I2C adapter
lock is already taken when I2C mux adapter is called, no need for
double locking.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/Kconfig  |   1 +
 drivers/media/dvb-frontends/m88ds3103.c  | 429 +--
 drivers/media/dvb-frontends/m88ds3103_priv.h |   5 +-
 3 files changed, 145 insertions(+), 290 deletions(-)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index b7627ca..0d35f58 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -38,6 +38,7 @@ config DVB_STV6110x
 config DVB_M88DS3103
tristate "Montage Technology M88DS3103"
depends on DVB_CORE && I2C && I2C_MUX
+   select REGMAP_I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
  Say Y when you want to support this frontend.
diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index c4d5a7a..6c33eca 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -18,141 +18,6 @@
 
 static struct dvb_frontend_ops m88ds3103_ops;
 
-/* write multiple registers */
-static int m88ds3103_wr_regs(struct m88ds3103_dev *dev,
-   u8 reg, const u8 *val, int len)
-{
-#define MAX_WR_LEN 32
-#define MAX_WR_XFER_LEN (MAX_WR_LEN + 1)
-   struct i2c_client *client = dev->client;
-   int ret;
-   u8 buf[MAX_WR_XFER_LEN];
-   struct i2c_msg msg[1] = {
-   {
-   .addr = client->addr,
-   .flags = 0,
-   .len = 1 + len,
-   .buf = buf,
-   }
-   };
-
-   if (WARN_ON(len > MAX_WR_LEN))
-   return -EINVAL;
-
-   buf[0] = reg;
-   memcpy(&buf[1], val, len);
-
-   mutex_lock(&dev->i2c_mutex);
-   ret = i2c_transfer(client->adapter, msg, 1);
-   mutex_unlock(&dev->i2c_mutex);
-   if (ret == 1) {
-   ret = 0;
-   } else {
-   dev_warn(&client->dev, "i2c wr failed=%d reg=%02x len=%d\n",
-ret, reg, len);
-   ret = -EREMOTEIO;
-   }
-
-   return ret;
-}
-
-/* read multiple registers */
-static int m88ds3103_rd_regs(struct m88ds3103_dev *dev,
-   u8 reg, u8 *val, int len)
-{
-#define MAX_RD_LEN 3
-#define MAX_RD_XFER_LEN (MAX_RD_LEN)
-   struct i2c_client *client = dev->client;
-   int ret;
-   u8 buf[MAX_RD_XFER_LEN];
-   struct i2c_msg msg[2] = {
-   {
-   .addr = client->addr,
-   .flags = 0,
-   .len = 1,
-   .buf = ®,
-   }, {
-   .addr = client->addr,
-   .flags = I2C_M_RD,
-   .len = len,
-   .buf = buf,
-   }
-   };
-
-   if (WARN_ON(len > MAX_RD_LEN))
-   return -EINVAL;
-
-   mutex_lock(&dev->i2c_mutex);
-   ret = i2c_transfer(client->adapter, msg, 2);
-   mutex_unlock(&dev->i2c_mutex);
-   if (ret == 2) {
-   memcpy(val, buf, len);
-   ret = 0;
-   } else {
-   dev_warn(&client->dev, "i2c rd failed=%d reg=%02x len=%d\n",
-ret, reg, len);
-   ret = -EREMOTEIO;
-   }
-
-   return ret;
-}
-
-/* write single register */
-static int m88ds3103_wr_reg(struct m88ds3103_dev *dev, u8 reg, u8 val)
-{
-   return m88ds3103_wr_regs(dev, reg, &val, 1);
-}
-
-/* read single register */
-static int m88ds3103_rd_reg(struct m88ds3103_dev *dev, u8 reg, u8 *val)
-{
-   return m88ds3103_rd_regs(dev, reg, val, 1);
-}
-
-/* write single register with mask */
-static int m88ds3103_wr_reg_mask(struct m88ds3103_dev *dev,
-   u8 reg, u8 val, u8 mask)
-{
-   int ret;
-   u8 u8tmp;
-
-   /* no need for read if whole reg is written */
-   if (mask != 0xff) {
-   ret = m88ds3103_rd_regs(dev, reg, &u8tmp, 1);
-   if (ret)
-   return ret;
-
-   val &= mask;
-   u8tmp &= ~mask;
-   val |= u8tmp;
-   }
-
-   return m88ds3103_wr_regs(dev, reg, &val, 1);
-}
-
-/* read single register with mask */
-static int m88ds3103_rd_reg_mask(struct m88ds3103_dev *dev,
-   u8 reg, u8 *val, u8 mask)
-{
-   int ret, i;
-   u8 u8tmp;
-
-   ret = m88ds3103_rd_regs(dev, reg, &u8tmp, 1);
-   if (ret)
-   return ret;
-
-   u8tmp &= mask;
-
-   /* find position of the first bit */
-   for (i = 0; i < 8; i++) {
-   if ((mask >> i) & 0x01)
-   break;
-   }
-   *val = u8tmp >> i;
-
-   return 0;
-}
-
 /* write reg val table using reg addr auto increment */
 static int m88ds3103_wr_reg

[PATCH 6/8] m88ds3103: rename variables and correct logging

2015-06-06 Thread Antti Palosaari
Rename driver state from priv to dev.
Use I2C client for correct logging.
Use adapter and address from I2C client structure where needed.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/Kconfig  |   2 +-
 drivers/media/dvb-frontends/m88ds3103.c  | 538 +--
 drivers/media/dvb-frontends/m88ds3103.h  |   2 +-
 drivers/media/dvb-frontends/m88ds3103_priv.h |   5 +-
 4 files changed, 267 insertions(+), 280 deletions(-)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index ba65a00..b7627ca 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -36,7 +36,7 @@ config DVB_STV6110x
  A Silicon tuner that supports DVB-S and DVB-S2 modes
 
 config DVB_M88DS3103
-   tristate "Montage M88DS3103"
+   tristate "Montage Technology M88DS3103"
depends on DVB_CORE && I2C && I2C_MUX
default m if !MEDIA_SUBDRV_AUTOSELECT
help
diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index 7b21f1a..c4d5a7a 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -1,5 +1,5 @@
 /*
- * Montage M88DS3103/M88RS6000 demodulator driver
+ * Montage Technology M88DS3103/M88RS6000 demodulator driver
  *
  * Copyright (C) 2013 Antti Palosaari 
  *
@@ -19,16 +19,17 @@
 static struct dvb_frontend_ops m88ds3103_ops;
 
 /* write multiple registers */
-static int m88ds3103_wr_regs(struct m88ds3103_priv *priv,
+static int m88ds3103_wr_regs(struct m88ds3103_dev *dev,
u8 reg, const u8 *val, int len)
 {
 #define MAX_WR_LEN 32
 #define MAX_WR_XFER_LEN (MAX_WR_LEN + 1)
+   struct i2c_client *client = dev->client;
int ret;
u8 buf[MAX_WR_XFER_LEN];
struct i2c_msg msg[1] = {
{
-   .addr = priv->cfg->i2c_addr,
+   .addr = client->addr,
.flags = 0,
.len = 1 + len,
.buf = buf,
@@ -41,15 +42,14 @@ static int m88ds3103_wr_regs(struct m88ds3103_priv *priv,
buf[0] = reg;
memcpy(&buf[1], val, len);
 
-   mutex_lock(&priv->i2c_mutex);
-   ret = i2c_transfer(priv->i2c, msg, 1);
-   mutex_unlock(&priv->i2c_mutex);
+   mutex_lock(&dev->i2c_mutex);
+   ret = i2c_transfer(client->adapter, msg, 1);
+   mutex_unlock(&dev->i2c_mutex);
if (ret == 1) {
ret = 0;
} else {
-   dev_warn(&priv->i2c->dev,
-   "%s: i2c wr failed=%d reg=%02x len=%d\n",
-   KBUILD_MODNAME, ret, reg, len);
+   dev_warn(&client->dev, "i2c wr failed=%d reg=%02x len=%d\n",
+ret, reg, len);
ret = -EREMOTEIO;
}
 
@@ -57,21 +57,22 @@ static int m88ds3103_wr_regs(struct m88ds3103_priv *priv,
 }
 
 /* read multiple registers */
-static int m88ds3103_rd_regs(struct m88ds3103_priv *priv,
+static int m88ds3103_rd_regs(struct m88ds3103_dev *dev,
u8 reg, u8 *val, int len)
 {
 #define MAX_RD_LEN 3
 #define MAX_RD_XFER_LEN (MAX_RD_LEN)
+   struct i2c_client *client = dev->client;
int ret;
u8 buf[MAX_RD_XFER_LEN];
struct i2c_msg msg[2] = {
{
-   .addr = priv->cfg->i2c_addr,
+   .addr = client->addr,
.flags = 0,
.len = 1,
.buf = ®,
}, {
-   .addr = priv->cfg->i2c_addr,
+   .addr = client->addr,
.flags = I2C_M_RD,
.len = len,
.buf = buf,
@@ -81,16 +82,15 @@ static int m88ds3103_rd_regs(struct m88ds3103_priv *priv,
if (WARN_ON(len > MAX_RD_LEN))
return -EINVAL;
 
-   mutex_lock(&priv->i2c_mutex);
-   ret = i2c_transfer(priv->i2c, msg, 2);
-   mutex_unlock(&priv->i2c_mutex);
+   mutex_lock(&dev->i2c_mutex);
+   ret = i2c_transfer(client->adapter, msg, 2);
+   mutex_unlock(&dev->i2c_mutex);
if (ret == 2) {
memcpy(val, buf, len);
ret = 0;
} else {
-   dev_warn(&priv->i2c->dev,
-   "%s: i2c rd failed=%d reg=%02x len=%d\n",
-   KBUILD_MODNAME, ret, reg, len);
+   dev_warn(&client->dev, "i2c rd failed=%d reg=%02x len=%d\n",
+ret, reg, len);
ret = -EREMOTEIO;
}
 
@@ -98,19 +98,19 @@ static int m88ds3103_rd_regs(struct m88ds3103_priv *priv,
 }
 
 /* write single register */
-static int m88ds3103_wr_reg(struct m88ds3103_priv *priv, u8 reg, u8 val)
+static int m88ds3103_wr_reg(struct m88ds3103_dev *dev, u8 reg, u8 val)
 {
-   return m88ds3103_wr_regs(priv, reg, &val, 1);
+   return m88d

[GIT PULL 4.2] error handling fixes

2015-06-06 Thread Antti Palosaari
There drivers were converted during 4.2 from media attach to I2C client 
binding. Media attach returns always only NULL on error case, but I2C 
probe uses error codes, so copy & pasting and some error statuses were 
missing.


Antti

The following changes since commit 839aa56d077972170a074bcbe31bf0d7eba37b24:

  [media] v4l2-ioctl: log buffer type 0 correctly (2015-06-06 07:43:49 
-0300)


are available in the git repository at:

  git://linuxtv.org/anttip/media_tree.git 4.2_fixes

for you to fetch changes up to fac47f02e68f2b718c0280d372d633cb9798b2c5:

  fc2580: add missing error status when probe() fails (2015-06-06 
14:15:34 +0300)



Antti Palosaari (2):
  tda10071: add missing error status when probe() fails
  fc2580: add missing error status when probe() fails

Dan Carpenter (1):
  m88ds3103: a couple missing error codes

 drivers/media/dvb-frontends/m88ds3103.c |  5 -
 drivers/media/dvb-frontends/tda10071.c  | 18 +++---
 drivers/media/tuners/fc2580.c   |  1 +
 3 files changed, 20 insertions(+), 4 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


[PATCH 1/2] tda10071: add missing error status when probe() fails

2015-06-06 Thread Antti Palosaari
We must return -ENODEV error on case probe() fails to detect chip.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/tda10071.c | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/tda10071.c 
b/drivers/media/dvb-frontends/tda10071.c
index 3132854..1470a5d 100644
--- a/drivers/media/dvb-frontends/tda10071.c
+++ b/drivers/media/dvb-frontends/tda10071.c
@@ -1348,18 +1348,30 @@ static int tda10071_probe(struct i2c_client *client,
 
/* chip ID */
ret = tda10071_rd_reg(dev, 0xff, &u8tmp);
-   if (ret || u8tmp != 0x0f)
+   if (ret)
+   goto err_kfree;
+   if (u8tmp != 0x0f) {
+   ret = -ENODEV;
goto err_kfree;
+   }
 
/* chip type */
ret = tda10071_rd_reg(dev, 0xdd, &u8tmp);
-   if (ret || u8tmp != 0x00)
+   if (ret)
+   goto err_kfree;
+   if (u8tmp != 0x00) {
+   ret = -ENODEV;
goto err_kfree;
+   }
 
/* chip version */
ret = tda10071_rd_reg(dev, 0xfe, &u8tmp);
-   if (ret || u8tmp != 0x01)
+   if (ret)
goto err_kfree;
+   if (u8tmp != 0x01) {
+   ret = -ENODEV;
+   goto err_kfree;
+   }
 
/* create dvb_frontend */
memcpy(&dev->fe.ops, &tda10071_ops, sizeof(struct dvb_frontend_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


[PATCH 2/2] fc2580: add missing error status when probe() fails

2015-06-06 Thread Antti Palosaari
We must return -ENODEV error on case probe() fails to detect chip.

Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/fc2580.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/tuners/fc2580.c b/drivers/media/tuners/fc2580.c
index db21902..12f916e 100644
--- a/drivers/media/tuners/fc2580.c
+++ b/drivers/media/tuners/fc2580.c
@@ -571,6 +571,7 @@ static int fc2580_probe(struct i2c_client *client,
case 0x5a:
break;
default:
+   ret = -ENODEV;
goto err_kfree;
}
 
-- 
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 v3 2/3] [media] bdisp: 2D blitter driver using v4l2 mem2mem framework

2015-06-06 Thread Mauro Carvalho Chehab
Em Tue, 12 May 2015 18:02:10 +0200
Fabien Dessenne  escreveu:

> This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
> It uses the v4l2 mem2mem framework.
> 
> The following features are supported and tested:
> - Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
> - Copy
> - Scale
> - Flip
> - Deinterlace
> - Wide (4K) picture support
> - Crop
> 
> Signed-off-by: Fabien Dessenne 

Hmm...

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#77: 
new file mode 100644


Who will maintain this driver? Please add the maintainers name at the
MAINTAINERS file.

Thanks,
Mauro

> ---
>  drivers/media/platform/Kconfig  |   10 +
>  drivers/media/platform/Makefile |2 +
>  drivers/media/platform/sti/bdisp/Kconfig|9 +
>  drivers/media/platform/sti/bdisp/Makefile   |3 +
>  drivers/media/platform/sti/bdisp/bdisp-filter.h |  346 ++
>  drivers/media/platform/sti/bdisp/bdisp-hw.c |  783 +
>  drivers/media/platform/sti/bdisp/bdisp-reg.h|  235 
>  drivers/media/platform/sti/bdisp/bdisp-v4l2.c   | 1404 
> +++
>  drivers/media/platform/sti/bdisp/bdisp.h|  186 +++
>  9 files changed, 2978 insertions(+)
>  create mode 100644 drivers/media/platform/sti/bdisp/Kconfig
>  create mode 100644 drivers/media/platform/sti/bdisp/Makefile
>  create mode 100644 drivers/media/platform/sti/bdisp/bdisp-filter.h
>  create mode 100644 drivers/media/platform/sti/bdisp/bdisp-hw.c
>  create mode 100644 drivers/media/platform/sti/bdisp/bdisp-reg.h
>  create mode 100644 drivers/media/platform/sti/bdisp/bdisp-v4l2.c
>  create mode 100644 drivers/media/platform/sti/bdisp/bdisp.h
> 
> diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
> index 2e30be5..005be89 100644
> --- a/drivers/media/platform/Kconfig
> +++ b/drivers/media/platform/Kconfig
> @@ -210,6 +210,16 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
>   help
> This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.
>  
> +config VIDEO_STI_BDISP
> + tristate "STMicroelectronics BDISP 2D blitter driver"
> + depends on VIDEO_DEV && VIDEO_V4L2
> + depends on ARCH_STI || COMPILE_TEST
> + depends on HAS_DMA
> + select VIDEOBUF2_DMA_CONTIG
> + select V4L2_MEM2MEM_DEV
> + help
> +   This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
> +
>  config VIDEO_SH_VEU
>   tristate "SuperH VEU mem2mem video processing driver"
>   depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
> diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
> index 3ec1547..b1fc862 100644
> --- a/drivers/media/platform/Makefile
> +++ b/drivers/media/platform/Makefile
> @@ -34,6 +34,8 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV)  += s5p-tv/
>  obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)  += s5p-g2d/
>  obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC)   += exynos-gsc/
>  
> +obj-$(CONFIG_VIDEO_STI_BDISP)+= sti/bdisp/
> +
>  obj-$(CONFIG_BLACKFIN)  += blackfin/
>  
>  obj-$(CONFIG_ARCH_DAVINCI)   += davinci/
> diff --git a/drivers/media/platform/sti/bdisp/Kconfig 
> b/drivers/media/platform/sti/bdisp/Kconfig
> new file mode 100644
> index 000..afaf4a6
> --- /dev/null
> +++ b/drivers/media/platform/sti/bdisp/Kconfig
> @@ -0,0 +1,9 @@
> +config VIDEO_STI_BDISP
> + tristate "STMicroelectronics BDISP 2D blitter driver"
> + depends on VIDEO_DEV && VIDEO_V4L2
> + select VIDEOBUF2_DMA_CONTIG
> + select V4L2_MEM2MEM_DEV
> + help
> +  This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
> +  To compile this driver as a module, choose M here: the module will
> +  be called bdisp.ko.
> diff --git a/drivers/media/platform/sti/bdisp/Makefile 
> b/drivers/media/platform/sti/bdisp/Makefile
> new file mode 100644
> index 000..2605094
> --- /dev/null
> +++ b/drivers/media/platform/sti/bdisp/Makefile
> @@ -0,0 +1,3 @@
> +obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o
> +
> +bdisp-objs := bdisp-v4l2.o bdisp-hw.o
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-filter.h 
> b/drivers/media/platform/sti/bdisp/bdisp-filter.h
> new file mode 100644
> index 000..fc8c54f
> --- /dev/null
> +++ b/drivers/media/platform/sti/bdisp/bdisp-filter.h
> @@ -0,0 +1,346 @@
> +/*
> + * Copyright (C) STMicroelectronics SA 2014
> + * Authors: Fabien Dessenne  for STMicroelectronics.
> + * License terms:  GNU General Public License (GPL), version 2
> + */
> +
> +#define BDISP_HF_NB 64
> +#define BDISP_VF_NB 40
> +
> +/**
> + * struct bdisp_filter_h_spec - Horizontal filter specification
> + *
> + * @min:min scale factor for this filter (6.10 fixed point)
> + * @max:max scale factor for this filter (6.10 fixed point)
> + * coef:filter coefficients
> + */
> +struct bdisp_filter_h_spec {
> + const u16 min;
> + const u16 max;
> + const u8 coef[BDISP_HF_NB];
> +};
> +
> +static const stru

Re: [PATCH 2/2] Revert "[media] saa7164: Improvements for I2C handling"

2015-06-06 Thread Antti Palosaari

On 06/06/2015 10:44 AM, Olli Salonen wrote:

This reverts commit ad90b6b0f10566d4a5546e27fe455ce3b5e6b6c7.

This patch breaks I2C communication towards Si2168. After reverting and
applying the other patch in this series the I2C communication is
correct.

Signed-off-by: Olli Salonen 


Reviewed-by: Antti Palosaari 

Antti


---
  drivers/media/pci/saa7164/saa7164-api.c | 11 +--
  1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/media/pci/saa7164/saa7164-api.c 
b/drivers/media/pci/saa7164/saa7164-api.c
index e807703..e7e586c 100644
--- a/drivers/media/pci/saa7164/saa7164-api.c
+++ b/drivers/media/pci/saa7164/saa7164-api.c
@@ -1385,8 +1385,7 @@ int saa7164_api_i2c_read(struct saa7164_i2c *bus, u8 
addr, u32 reglen, u8 *reg,
 *   08... register address
 */
memset(buf, 0, sizeof(buf));
-   if (reg)
-   memcpy((buf + 2 * sizeof(u32) + 0), reg, reglen);
+   memcpy((buf + 2 * sizeof(u32) + 0), reg, reglen);
*((u32 *)(buf + 0 * sizeof(u32))) = reglen;
*((u32 *)(buf + 1 * sizeof(u32))) = datalen;

@@ -1475,14 +1474,6 @@ int saa7164_api_i2c_write(struct saa7164_i2c *bus, u8 
addr, u32 datalen,
 *   04-07 dest bytes to write
 *   08... register address
 */
-   if (datalen == 1) {
-   /* Workaround for issues with i2c components
-* that issue writes with no data. IE: SI2168/2157
-* Increase reglen by 1, strobe out an additional byte,
-* ignored by SI2168/2157.
-*/
-   datalen++;
-   }
*((u32 *)(buf + 0 * sizeof(u32))) = reglen;
*((u32 *)(buf + 1 * sizeof(u32))) = datalen - reglen;
memcpy((buf + 2 * sizeof(u32)), data, datalen);



--
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 1/2] saa7164: change Si2168 reglen to 0 bit

2015-06-06 Thread Antti Palosaari

On 06/06/2015 10:44 AM, Olli Salonen wrote:

The i2c_reg_len for Si2168 should be 0 for correct I2C communication.

Signed-off-by: Olli Salonen 


Reviewed-by: Antti Palosaari 

PS. As I mentioned few times already, that kind I2C client register map 
layout information does not belongs to adapter level at all. I wonder 
why it is here. Likely some further clean-ups are possible.


regards
Antti



---
  drivers/media/pci/saa7164/saa7164-cards.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/saa7164/saa7164-cards.c 
b/drivers/media/pci/saa7164/saa7164-cards.c
index 8a6455d..c2b7382 100644
--- a/drivers/media/pci/saa7164/saa7164-cards.c
+++ b/drivers/media/pci/saa7164/saa7164-cards.c
@@ -621,7 +621,7 @@ struct saa7164_board saa7164_boards[] = {
.name   = "SI2168-1",
.i2c_bus_nr = SAA7164_I2C_BUS_2,
.i2c_bus_addr   = 0xc8 >> 1,
-   .i2c_reg_len= REGLEN_8bit,
+   .i2c_reg_len= REGLEN_0bit,
}, {
.id = 0x25,
.type   = SAA7164_UNIT_TUNER,
@@ -635,7 +635,7 @@ struct saa7164_board saa7164_boards[] = {
.name   = "SI2168-2",
.i2c_bus_nr = SAA7164_I2C_BUS_2,
.i2c_bus_addr   = 0xcc >> 1,
-   .i2c_reg_len= REGLEN_8bit,
+   .i2c_reg_len= REGLEN_0bit,
} },
},
  };



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


[PATCH] cx231xx: fix compiler warning

2015-06-06 Thread Hans Verkuil
Fix this compiler warning by allocating a structure to read the eeprom instead
of doing it on the stack and worse: the eeprom array is static, so that can
cause problems if there are multiple cx231xx instances.

cx231xx-cards.c: In function 'cx231xx_card_setup':
cx231xx-cards.c:1110:1: warning: the frame size of 2064 bytes is larger than 
2048 bytes [-Wframe-larger-than=]
 }
 ^

I did consider removing the code altogether since the result is actually
not used at the moment, but I decided against it since it is used in other
drivers and someone might want to start using it in this driver as well. And
then it is useful that the code is already there.

Signed-of-by: Hans Verkuil 

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c 
b/drivers/media/usb/cx231xx/cx231xx-cards.c
index fe00da1..a4aa285 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1092,17 +1092,25 @@ void cx231xx_card_setup(struct cx231xx *dev)
case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx:
case CX231XX_BOARD_HAUPPAUGE_955Q:
{
-   struct tveeprom tvee;
-   static u8 eeprom[256];
-   struct i2c_client client;
-
-   memset(&client, 0, sizeof(client));
-   client.adapter = cx231xx_get_i2c_adap(dev, I2C_1_MUX_1);
-   client.addr = 0xa0 >> 1;
+   struct eeprom {
+   struct tveeprom tvee;
+   u8 eeprom[256];
+   struct i2c_client client;
+   };
+   struct eeprom *e = kzalloc(sizeof(*e), GFP_KERNEL);
+
+   if (e == NULL) {
+   dev_err(dev->dev,
+   "failed to allocate memory to read 
eeprom\n");
+   break;
+   }
+   e->client.adapter = cx231xx_get_i2c_adap(dev, 
I2C_1_MUX_1);
+   e->client.addr = 0xa0 >> 1;
 
-   read_eeprom(dev, &client, eeprom, sizeof(eeprom));
-   tveeprom_hauppauge_analog(&client,
-   &tvee, eeprom + 0xc0);
+   read_eeprom(dev, &e->client, e->eeprom, 
sizeof(e->eeprom));
+   tveeprom_hauppauge_analog(&e->client,
+   &e->tvee, e->eeprom + 0xc0);
+   kfree(e);
break;
}
}
--
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] Revert "[media] saa7164: Improvements for I2C handling"

2015-06-06 Thread Olli Salonen
This reverts commit ad90b6b0f10566d4a5546e27fe455ce3b5e6b6c7.

This patch breaks I2C communication towards Si2168. After reverting and 
applying the other patch in this series the I2C communication is 
correct.

Signed-off-by: Olli Salonen 
---
 drivers/media/pci/saa7164/saa7164-api.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/media/pci/saa7164/saa7164-api.c 
b/drivers/media/pci/saa7164/saa7164-api.c
index e807703..e7e586c 100644
--- a/drivers/media/pci/saa7164/saa7164-api.c
+++ b/drivers/media/pci/saa7164/saa7164-api.c
@@ -1385,8 +1385,7 @@ int saa7164_api_i2c_read(struct saa7164_i2c *bus, u8 
addr, u32 reglen, u8 *reg,
 *   08... register address
 */
memset(buf, 0, sizeof(buf));
-   if (reg)
-   memcpy((buf + 2 * sizeof(u32) + 0), reg, reglen);
+   memcpy((buf + 2 * sizeof(u32) + 0), reg, reglen);
*((u32 *)(buf + 0 * sizeof(u32))) = reglen;
*((u32 *)(buf + 1 * sizeof(u32))) = datalen;
 
@@ -1475,14 +1474,6 @@ int saa7164_api_i2c_write(struct saa7164_i2c *bus, u8 
addr, u32 datalen,
 *   04-07 dest bytes to write
 *   08... register address
 */
-   if (datalen == 1) {
-   /* Workaround for issues with i2c components
-* that issue writes with no data. IE: SI2168/2157
-* Increase reglen by 1, strobe out an additional byte,
-* ignored by SI2168/2157.
-*/
-   datalen++;
-   }
*((u32 *)(buf + 0 * sizeof(u32))) = reglen;
*((u32 *)(buf + 1 * sizeof(u32))) = datalen - reglen;
memcpy((buf + 2 * sizeof(u32)), data, datalen);
-- 
1.9.1

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


[PATCH 1/2] saa7164: change Si2168 reglen to 0 bit

2015-06-06 Thread Olli Salonen
The i2c_reg_len for Si2168 should be 0 for correct I2C communication.

Signed-off-by: Olli Salonen 
---
 drivers/media/pci/saa7164/saa7164-cards.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/saa7164/saa7164-cards.c 
b/drivers/media/pci/saa7164/saa7164-cards.c
index 8a6455d..c2b7382 100644
--- a/drivers/media/pci/saa7164/saa7164-cards.c
+++ b/drivers/media/pci/saa7164/saa7164-cards.c
@@ -621,7 +621,7 @@ struct saa7164_board saa7164_boards[] = {
.name   = "SI2168-1",
.i2c_bus_nr = SAA7164_I2C_BUS_2,
.i2c_bus_addr   = 0xc8 >> 1,
-   .i2c_reg_len= REGLEN_8bit,
+   .i2c_reg_len= REGLEN_0bit,
}, {
.id = 0x25,
.type   = SAA7164_UNIT_TUNER,
@@ -635,7 +635,7 @@ struct saa7164_board saa7164_boards[] = {
.name   = "SI2168-2",
.i2c_bus_nr = SAA7164_I2C_BUS_2,
.i2c_bus_addr   = 0xcc >> 1,
-   .i2c_reg_len= REGLEN_8bit,
+   .i2c_reg_len= REGLEN_0bit,
} },
},
 };
-- 
1.9.1

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


Re: [PATCH][media] SI2168: Resolve unknown chip version errors with different HVR22x5 models

2015-06-06 Thread Olli Salonen
Hi,

Indeed, the HVR-2205 I have works fine with that patch reverted and
after setting REGLEN_0bit for the Si2168 chips in the saa7164-cards.

The chip detection and firmware load is correct now.

[ 2046.684246] si2168 2-0064: found a 'Silicon Labs Si2168-B40'
[ 2046.684278] si2168 2-0064: downloading firmware from file
'dvb-demod-si2168-b40-01.fw'
[ 2049.242810] si2168 2-0064: firmware version: 4.0.11
[ 2049.261896] si2157 0-0060: found a 'Silicon Labs Si2157-A30'
[ 2049.294328] si2157 0-0060: firmware version: 3.0.5

I'll send the patches on to linux-media so Steven can evaluate the
impact on other boards, if any.

Cheers,
-olli


On 5 June 2015 at 16:18, Antti Palosaari  wrote:
> On 06/05/2015 04:40 PM, Olli Salonen wrote:
>>
>> Hi Steven,
>>
>> It seems to me that that part of the code is identical to your driver, no?
>>
>> The media_tree driver:
>>
>> retval = saa7164_api_i2c_read(bus,
>>   msgs[i].addr,
>>   0 /* reglen */,
>>   NULL /* reg */, msgs[i].len, msgs[i].buf);
>>
>> It's exactly the same with a little bit different formatting.
>
>
> And that looks correct.
>
> But the patch which does not look correct, or is at least unclear, is that
> [media] saa7164: Improvements for I2C handling
> http://permalink.gmane.org/gmane.comp.video.linuxtv.scm/22211
>
> First change does not have any effect as len should be zero in any case and
> memcpy() should do nothing.
>
> Second change looks something that is likely wrong. There is some hack which
> increases data len. All that register len stuff is logically wrong - I2C
> adapter handles just bytes and should not know nothing about client register
> layout. OK, there is some exceptions (like af9035) where I2C firmware
> actually knows register layout for some strange reason.
>
> So could you remove that patch and test?
>
> 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