Re: [PATCH] em28xx: return -ENOTTY for tuner + frequency ioctls if the device has no tuner

2013-01-14 Thread Hans Verkuil
On Sun January 13 2013 13:50:50 Frank Schäfer wrote:
 Signed-off-by: Frank Schäfer fschaefer@googlemail.com
 ---
  drivers/media/usb/em28xx/em28xx-video.c |8 
  1 Datei geändert, 8 Zeilen hinzugefügt(+)
 
 diff --git a/drivers/media/usb/em28xx/em28xx-video.c 
 b/drivers/media/usb/em28xx/em28xx-video.c
 index 2eabf2a..4a7f73c 100644
 --- a/drivers/media/usb/em28xx/em28xx-video.c
 +++ b/drivers/media/usb/em28xx/em28xx-video.c
 @@ -1204,6 +1204,8 @@ static int vidioc_g_tuner(struct file *file, void *priv,
   struct em28xx *dev = fh-dev;
   int   rc;
  
 + if (dev-tuner_type == TUNER_ABSENT)
 + return -ENOTTY;
   rc = check_dev(dev);
   if (rc  0)
   return rc;
 @@ -1224,6 +1226,8 @@ static int vidioc_s_tuner(struct file *file, void *priv,
   struct em28xx *dev = fh-dev;
   int   rc;
  
 + if (dev-tuner_type == TUNER_ABSENT)
 + return -ENOTTY;
   rc = check_dev(dev);
   if (rc  0)
   return rc;
 @@ -1241,6 +1245,8 @@ static int vidioc_g_frequency(struct file *file, void 
 *priv,
   struct em28xx_fh  *fh  = priv;
   struct em28xx *dev = fh-dev;
  
 + if (dev-tuner_type == TUNER_ABSENT)
 + return -ENOTTY;
   if (0 != f-tuner)
   return -EINVAL;
  
 @@ -1255,6 +1261,8 @@ static int vidioc_s_frequency(struct file *file, void 
 *priv,
   struct em28xx *dev = fh-dev;
   int   rc;
  
 + if (dev-tuner_type == TUNER_ABSENT)
 + return -ENOTTY;
   rc = check_dev(dev);
   if (rc  0)
   return rc;
 

Rather than doing this in each ioctl, I recommend using v4l2_disable_ioctl
instead. See for example drivers/media/pci/ivtv/ivtv-streams.c.

Regards,

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


[PATCH/RFC 0/3] Add proper timestamp types handling in videobuf2

2013-01-14 Thread Kamil Debski
Hi,

The recent addition of timestamp types (and monotonic timestamp) left some room
for improvement. First of all not all drivers use monotonic timestamp. There are
for example mem2mem drivers that copy the timestamp from the OUTPUT buffer to
the corresponding CAPTURE buffer. Some videobuf2 drivers do not fill the
timestamp field altogether (yeah, I can agree that a constant is monotonic, but
still...).

Hence, I propose the following change to videobuf2. After applying this patch
the default timestamp type is UNKNOWN. It is up to the driver to set the
timestamp type to either MONOTONIC or COPY in vb2_queue_init.

This patch also adds setting proper timestamp type value in case of drivers
where I determined that type. This list might be missing some drivers, but
in these cases it will leave the UNKNOWN type which is a safe assumption.

Best wishes,
Kamil Debski

Kamil Debski (3):
  v4l: Define video buffer flag for the COPY timestamp type
  vb2: Add support for non monotonic timestamps
  v4l: Set proper timestamp type in selected drivers which use
videobuf2

 Documentation/DocBook/media/v4l/io.xml |6 ++
 drivers/media/platform/blackfin/bfin_capture.c |1 +
 drivers/media/platform/davinci/vpif_capture.c  |1 +
 drivers/media/platform/davinci/vpif_display.c  |1 +
 drivers/media/platform/s3c-camif/camif-capture.c   |1 +
 drivers/media/platform/s5p-fimc/fimc-capture.c |1 +
 drivers/media/platform/s5p-fimc/fimc-lite.c|1 +
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |2 ++
 drivers/media/platform/soc_camera/atmel-isi.c  |1 +
 drivers/media/platform/soc_camera/mx2_camera.c |1 +
 drivers/media/platform/soc_camera/mx3_camera.c |1 +
 .../platform/soc_camera/sh_mobile_ceu_camera.c |1 +
 drivers/media/platform/vivi.c  |1 +
 drivers/media/usb/pwc/pwc-if.c |1 +
 drivers/media/usb/stk1160/stk1160-v4l.c|1 +
 drivers/media/usb/uvc/uvc_queue.c  |1 +
 drivers/media/v4l2-core/videobuf2-core.c   |5 +++--
 include/media/videobuf2-core.h |1 +
 include/uapi/linux/videodev2.h |1 +
 19 files changed, 27 insertions(+), 2 deletions(-)

-- 
1.7.9.5

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


[PATCH 3/3] v4l: Set proper timestamp type in selected drivers which use videobuf2

2013-01-14 Thread Kamil Debski
Set proper timestamp type in drivers that I am sure that use either
MONOTONIC or COPY timestamps. Other drivers will correctly report
UNKNOWN timestamp type instead of assuming that all drivers use monotonic
timestamps.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/blackfin/bfin_capture.c |1 +
 drivers/media/platform/davinci/vpif_capture.c  |1 +
 drivers/media/platform/davinci/vpif_display.c  |1 +
 drivers/media/platform/s3c-camif/camif-capture.c   |1 +
 drivers/media/platform/s5p-fimc/fimc-capture.c |1 +
 drivers/media/platform/s5p-fimc/fimc-lite.c|1 +
 drivers/media/platform/s5p-mfc/s5p_mfc.c   |2 ++
 drivers/media/platform/soc_camera/atmel-isi.c  |1 +
 drivers/media/platform/soc_camera/mx2_camera.c |1 +
 drivers/media/platform/soc_camera/mx3_camera.c |1 +
 .../platform/soc_camera/sh_mobile_ceu_camera.c |1 +
 drivers/media/platform/vivi.c  |1 +
 drivers/media/usb/pwc/pwc-if.c |1 +
 drivers/media/usb/stk1160/stk1160-v4l.c|1 +
 drivers/media/usb/uvc/uvc_queue.c  |1 +
 15 files changed, 16 insertions(+)

diff --git a/drivers/media/platform/blackfin/bfin_capture.c 
b/drivers/media/platform/blackfin/bfin_capture.c
index d422d3c..365d6ef 100644
--- a/drivers/media/platform/blackfin/bfin_capture.c
+++ b/drivers/media/platform/blackfin/bfin_capture.c
@@ -939,6 +939,7 @@ static int __devinit bcap_probe(struct platform_device 
*pdev)
q-buf_struct_size = sizeof(struct bcap_buffer);
q-ops = bcap_video_qops;
q-mem_ops = vb2_dma_contig_memops;
+   q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
vb2_queue_init(q);
 
diff --git a/drivers/media/platform/davinci/vpif_capture.c 
b/drivers/media/platform/davinci/vpif_capture.c
index 5892d2b..1943e41 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1035,6 +1035,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
q-ops = video_qops;
q-mem_ops = vb2_dma_contig_memops;
q-buf_struct_size = sizeof(struct vpif_cap_buffer);
+   q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
ret = vb2_queue_init(q);
if (ret) {
diff --git a/drivers/media/platform/davinci/vpif_display.c 
b/drivers/media/platform/davinci/vpif_display.c
index dd249c9..5477c2c 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1001,6 +1001,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
q-ops = video_qops;
q-mem_ops = vb2_dma_contig_memops;
q-buf_struct_size = sizeof(struct vpif_disp_buffer);
+   q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
ret = vb2_queue_init(q);
if (ret) {
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c 
b/drivers/media/platform/s3c-camif/camif-capture.c
index a55793c..e91f350 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -1153,6 +1153,7 @@ int s3c_camif_register_video_node(struct camif_dev 
*camif, int idx)
q-mem_ops = vb2_dma_contig_memops;
q-buf_struct_size = sizeof(struct camif_buffer);
q-drv_priv = vp;
+   q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
ret = vb2_queue_init(q);
if (ret)
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index ddd689b..02cfb2b 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -1747,6 +1747,7 @@ static int fimc_register_capture_device(struct fimc_dev 
*fimc,
q-ops = fimc_capture_qops;
q-mem_ops = vb2_dma_contig_memops;
q-buf_struct_size = sizeof(struct fimc_vid_buffer);
+   q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
ret = vb2_queue_init(q);
if (ret)
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 1b309a7..39ea893 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -1251,6 +1251,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev 
*sd)
q-mem_ops = vb2_dma_contig_memops;
q-buf_struct_size = sizeof(struct flite_buffer);
q-drv_priv = fimc;
+   q-timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
ret = vb2_queue_init(q);
if (ret  0)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index a527f85..30b4d15 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -807,6 +807,7 @@ static int s5p_mfc_open(struct file *file)
 

[PATCH 1/3] v4l: Define video buffer flag for the COPY timestamp type

2013-01-14 Thread Kamil Debski
Define video buffer flag for the COPY timestamp. In this case the timestamp
value is copied from the OUTPUT to the corresponding CAPTURE buffer.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/DocBook/media/v4l/io.xml |6 ++
 include/uapi/linux/videodev2.h |1 +
 2 files changed, 7 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 73f202f..fdd1822 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -1145,6 +1145,12 @@ in which case caches have not been used./entry
same clock outside V4L2, use
functionclock_gettime(2)/function ./entry
  /row
+ row
+   entryconstantV4L2_BUF_FLAG_TIMESTAMP_COPY/constant/entry
+   entry0x4000/entry
+   entryThe CAPTURE buffer timestamp has been taken from the
+   corresponding OUTPUT buffer./entry
+ /row
/tbody
   /tgroup
 /table
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 72e9921..d5a59af 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -697,6 +697,7 @@ struct v4l2_buffer {
 #define V4L2_BUF_FLAG_TIMESTAMP_MASK   0xe000
 #define V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN0x
 #define V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC  0x2000
+#define V4L2_BUF_FLAG_TIMESTAMP_COPY   0x4000
 
 /**
  * struct v4l2_exportbuffer - export of video buffer as DMABUF file descriptor
-- 
1.7.9.5

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


[PATCH 2/3] vb2: Add support for non monotonic timestamps

2013-01-14 Thread Kamil Debski
Not all drivers use monotonic timestamps. This patch adds a way to set the
timestamp type per every queue.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/v4l2-core/videobuf2-core.c |5 +++--
 include/media/videobuf2-core.h   |1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index 85e3c22..c02472c 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -403,7 +403,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, 
struct v4l2_buffer *b)
 * Clear any buffer state related flags.
 */
b-flags = ~V4L2_BUFFER_MASK_FLAGS;
-   b-flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+   b-flags |= q-timestamp_type;
 
switch (vb-state) {
case VB2_BUF_STATE_QUEUED:
@@ -2032,7 +2032,8 @@ int vb2_queue_init(struct vb2_queue *q)
WARN_ON(!q-type) ||
WARN_ON(!q-io_modes) ||
WARN_ON(!q-ops-queue_setup) ||
-   WARN_ON(!q-ops-buf_queue))
+   WARN_ON(!q-ops-buf_queue)   ||
+   WARN_ON(q-timestamp_type  ~V4L2_BUF_FLAG_TIMESTAMP_MASK))
return -EINVAL;
 
INIT_LIST_HEAD(q-queued_list);
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 9cfd4ee..7ce4656 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -326,6 +326,7 @@ struct vb2_queue {
const struct vb2_mem_ops*mem_ops;
void*drv_priv;
unsigned intbuf_struct_size;
+   u32 timestamp_type;
 
 /* private: internal use only */
enum v4l2_memorymemory;
-- 
1.7.9.5

--
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 RFC v1 2/2] V4L: Add driver for OV9650/52 image sensors

2013-01-14 Thread Hans Verkuil
On Mon January 14 2013 00:14:39 Sylwester Nawrocki wrote:
 Hi Hans,
 
 Thank you for the review!
 
 On 01/07/2013 02:38 PM, Hans Verkuil wrote:
  +
  +/* V4L2 private controls */
  +
  +/* Auto exposure frame reference area */
  +#define V4L2_CID_EXPOSURE_REFERENCE_AREA (V4L2_CTRL_CLASS_CAMERA | 0x1001)
  +/* Maximum gain value */
  +#define V4L2_CID_GAIN_CEILING  (V4L2_CTRL_CLASS_CAMERA | 
  0x1002)
 
  Private controls should be added to uapi/linux/v4l2-controls.h. By having
  all controls in the same header it is easy to ensure that there are no
  duplicate IDs in use.
 
  The name of the driver should be part of the control name, so something 
  like:
 
  V4L2_CID_OV9650_EXP_REFERENCE_AREA
  V4L2_CID_OV9650_GAIN_CEILING
 
 Ok, to avoid overlapping with couple of existing camera class private 
 controls
 I have defined them as:
 
 +/* OV965X image sensor driver private controls */
 +
 +/* Auto exposure frame reference area */
 +#define V4L2_CID_OV965X_EXPOSURE_REF_AREA  (V4L2_CTRL_CLASS_CAMERA 
 | 0x1010)
 +/* Automatic gain algorithm's gain limit */
 +#define V4L2_CID_OV965X_GAIN_CEILING   (V4L2_CTRL_CLASS_CAMERA 
 | 0x1011)
 
 I've checked the datasheets and the gain ceiling control is supported by
 virtually every Omnivision sensor: OV2655, OV3640, OV5630, OV9650, OV9655,
 OV7690, with even identical range 2x...128x.
 
 The _OV965X prefix for the control doesn't seem right then. Should I make
 it something (ugly) like V4L2_CID_OV_GAIN_CEILING ?

In that case it would make sense to make this a documented chipset control.
See e.g. the cx2341x and mfc51 MPEG controls:

http://hverkuil.home.xs4all.nl/spec/media.html#mpeg-controls

I'd drop the  in that case.

 
 And should ranges be reserved for each driver ?

Both, actually. Chipset specific controls get a range, and so do driver specific
controls.

 Or maybe only per 
 manufacturer?
 
 If I get it right, there is room for 0x - 0x1000 = 61439 private 
 controls
 in each control class for all drivers.
 
 According to the notes from the Kernel Summit 2012 Media Workshop
 (http://lwn.net/Articles/514527):
 
 New controls should not overlap.
 Having all driver-specific controls in a single header file would 
 probably be
 overkill.  We can instead reserve a range of CIDs for each driver, and 
 define
 the range base CID only in a common header file.
 Driver-specific CIDs themselves would be defined in driver-specific 
 headers.
 
 Since there shouldn't generally be many private controls per driver it may
 make more sense to have all put in v4l2-controls.h.

I agree with that.

 
 ...
  +static void ov965x_update_exposure_ctrl(struct ov965x *ov965x)
  +{
  +  struct v4l2_ctrl *ctrl = ov965x-ctrls.exposure;
  +  unsigned long fint, trow;
  +  int max;
  +  u8 clkrc;
  +
  +  mutex_lock(ov965x-lock);
  +
  +  if (WARN_ON(!ctrl || !ov965x-frame_size)) {
  +  mutex_unlock(ov965x-lock);
  +  return;
  +  }
  +  clkrc = DEF_CLKRC + ov965x-fiv-clkrc_div;
  +  /* Calculate internal clock frequency */
  +  fint = ov965x-mclk_frequency * ((clkrc  7) + 1) /
  +  ((2 * ((clkrc  0x3f) + 1)));
  +  /* and the row interval (in us). */
  +  trow = (2 * 1520 * 100UL) / fint;
  +  max = ov965x-frame_size-max_exp_lines * trow;
  +  ov965x-exp_row_interval = trow;
  +
  +  mutex_unlock(ov965x-lock);
  +  v4l2_dbg(1, debug,ov965x-sd, clkrc: %#x, fi: %lu, tr: %lu, %d\n,
  +   clkrc, fint, trow, max);
  +
  +  /* Update exposure time min/max to match current frame format. */
  +  v4l2_ctrl_lock(ctrl);
  +
  +  ctrl-minimum = (trow + 100) / 100;
  +  ctrl-maximum = (max - 100) / 100;
  +  if (ctrl-cur.val  ctrl-maximum)
  +  ctrl-cur.val = ctrl-maximum;
  +  if (ctrl-cur.val  ctrl-minimum)
  +  ctrl-cur.val = ctrl-minimum;
 
  You can't do this like that. To do this correctly you need to create a new
  function in v4l2-ctrl.c that allows you to change the control attributes
  minimum, maximum, step and default_value.
 
  That function can then call send_event() to tell external apps that these
  attributes have changed. That also requires a new flag 
  V4L2_EVENT_CTRL_CH_RANGE.
 
  v4l2_ctrl_modify_range() would probably be a good name for such a function.
 
 Hh, extra work, great! ;)
 
 So I've created v4l2_ctrl_modify_range() function, with this old patch as
 a reference: http://patchwork.linuxtv.org/patch/8654.
 
 I'm going to add missing documentation and post it in few days.
 
  +
  +  v4l2_ctrl_unlock(ctrl);
  +}
  +
 ...
  +static int ov965x_set_contrast(struct ov965x *ov965x, int value)
  +{
  +  /* TODO */
  +  return -EINVAL;
  +}
 
  Perhaps this should just be removed?
 
 OK, let me remove it. If I find more time I'll implement it as a separate
 patch. I left it out for a moment since it requires quite a few register
 values to be rewritten from the datasheet. Not sure if there is any sane
 method to calculate those arrays dynamically in the driver.
 
  +static int 

[PATCH v2] [media] iguanair: intermittent initialization failure

2013-01-14 Thread Sean Young
On cold boot the device does not initialize until the first packet is
received, and that packet is not processed.

Signed-off-by: Sean Young s...@mess.org
---
 drivers/media/rc/iguanair.c | 25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index a569c69..8d390a8 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -58,6 +58,7 @@ struct iguanair {
char phys[64];
 };
 
+#define CMD_NOP0x00
 #define CMD_GET_VERSION0x01
 #define CMD_GET_BUFSIZE0x11
 #define CMD_GET_FEATURES   0x10
@@ -196,6 +197,10 @@ static void iguanair_irq_out(struct urb *urb)
 
if (urb-status)
dev_dbg(ir-dev, Error: out urb status = %d\n, urb-status);
+
+   /* if we sent an nop packet, do not expect a response */
+   if (urb-status == 0  ir-packet-header.cmd == CMD_NOP)
+   complete(ir-completion);
 }
 
 static int iguanair_send(struct iguanair *ir, unsigned size)
@@ -219,10 +224,17 @@ static int iguanair_get_features(struct iguanair *ir)
 {
int rc;
 
+   /*
+* On cold boot, the iguanair initializes on the first packet
+* received but does not process that packet. Send an empty
+* packet.
+*/
ir-packet-header.start = 0;
ir-packet-header.direction = DIR_OUT;
-   ir-packet-header.cmd = CMD_GET_VERSION;
+   ir-packet-header.cmd = CMD_NOP;
+   iguanair_send(ir, sizeof(ir-packet-header));
 
+   ir-packet-header.cmd = CMD_GET_VERSION;
rc = iguanair_send(ir, sizeof(ir-packet-header));
if (rc) {
dev_info(ir-dev, failed to get version\n);
@@ -255,19 +267,14 @@ static int iguanair_get_features(struct iguanair *ir)
ir-packet-header.cmd = CMD_GET_FEATURES;
 
rc = iguanair_send(ir, sizeof(ir-packet-header));
-   if (rc) {
+   if (rc)
dev_info(ir-dev, failed to get features\n);
-   goto out;
-   }
-
 out:
return rc;
 }
 
 static int iguanair_receiver(struct iguanair *ir, bool enable)
 {
-   int rc;
-
ir-packet-header.start = 0;
ir-packet-header.direction = DIR_OUT;
ir-packet-header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF;
@@ -275,9 +282,7 @@ static int iguanair_receiver(struct iguanair *ir, bool 
enable)
if (enable)
ir_raw_event_reset(ir-rc);
 
-   rc = iguanair_send(ir, sizeof(ir-packet-header));
-
-   return rc;
+   return iguanair_send(ir, sizeof(ir-packet-header));
 }
 
 /*
-- 
1.7.11.7

--
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/1] [media] s5p-mfc: Use NULL instead of 0 for pointer

2013-01-14 Thread Sachin Kamat
Fixes the following warning:
drivers/media/platform/s5p-mfc/s5p_mfc_opr.c:56:27: warning:
Using plain integer as NULL pointer

Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
index b4c1943..10f8ac3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
@@ -53,7 +53,7 @@ void s5p_mfc_release_priv_buf(struct device *dev,
 {
if (b-virt) {
dma_free_coherent(dev, b-size, b-virt, b-dma);
-   b-virt = 0;
+   b-virt = NULL;
b-dma = 0;
b-size = 0;
}
-- 
1.7.4.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 1/1] [media] s5p-mfc: Use NULL instead of 0 for pointer

2013-01-14 Thread Hans Verkuil
On Mon January 14 2013 11:09:41 Sachin Kamat wrote:
 Fixes the following warning:
 drivers/media/platform/s5p-mfc/s5p_mfc_opr.c:56:27: warning:
 Using plain integer as NULL pointer
 
 Signed-off-by: Sachin Kamat sachin.ka...@linaro.org

Acked-by: Hans Verkuil hans.verk...@cisco.com

 ---
  drivers/media/platform/s5p-mfc/s5p_mfc_opr.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c 
 b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
 index b4c1943..10f8ac3 100644
 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
 +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.c
 @@ -53,7 +53,7 @@ void s5p_mfc_release_priv_buf(struct device *dev,
  {
   if (b-virt) {
   dma_free_coherent(dev, b-size, b-virt, b-dma);
 - b-virt = 0;
 + b-virt = NULL;
   b-dma = 0;
   b-size = 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


[GIT PULL FOR v3.9] DocBook fixes/improvements

2013-01-14 Thread Hans Verkuil
Hi Mauro,

Here are a bunch of validation fixes and control documentation improvements.

Patchwork commands:

pwclient -u 'accepted' 16216
pwclient -u 'accepted' 16217
pwclient -u 'accepted' 16218

Regards,

Hans

The following changes since commit 73ec66c000e9816806c7380ca3420f4e0638c40e:
 

 
  [media] stv0900: Multistream support (2013-01-06 11:08:44 -0200)  
 

 
are available in the git repository at: 
 

 
  git://linuxtv.org/hverkuil/media_tree.git docs
 

 
for you to fetch changes up to 30dc7961be7e7d2a24ef152bfdeae48c8b8a:
 

 
  DocBook: mention that EINVAL can be returned for invalid menu indices. 
(2013-01-11 14:51:13 +0100) 

 

 
Hans Verkuil (3):   
 
  DocBook: fix various validation errors
 
  DocBook: improve the error_idx field documentation.   
 
  DocBook: mention that EINVAL can be returned for invalid menu indices.
 

 
 Documentation/DocBook/media/v4l/common.xml  |2 +-  
 
 Documentation/DocBook/media/v4l/io.xml  |4 ++--
 
 Documentation/DocBook/media/v4l/pixfmt-srggb10alaw8.xml |2 +-  
 
 Documentation/DocBook/media/v4l/v4l2.xml|5 +   
 
 Documentation/DocBook/media/v4l/vidioc-expbuf.xml   |   28 

 
 Documentation/DocBook/media/v4l/vidioc-g-ctrl.xml   |8 ++--
 
 Documentation/DocBook/media/v4l/vidioc-g-ext-ctrls.xml  |   57 
+++--   
 
 7 files changed, 70 insertions(+), 36 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


Re: [PATCH] [RFC] video: exynos dp: Making Exynos DP Compliant with CDF

2013-01-14 Thread Leela Krishna Amudala
Hello Sean,
Thanks for reviewing the patch.

On Sat, Jan 12, 2013 at 1:30 AM, Sean Paul seanp...@chromium.org wrote:
 On Fri, Jan 11, 2013 at 5:35 AM, Leela Krishna Amudala
 l.kris...@samsung.com wrote:
 The Exynos DP transmitter is treated as an end entity in the display pipeline
 and made this RFC patch compliant with CDF.

 Any suggestions are welcome.


 A few comments below. It's hard to get too much of an appreciation for
 what you're trying to do since a bunch of the interesting parts are
 stubbed out.

 Signed-off-by: Leela Krishna Amudala l.kris...@samsung.com
 ---
  drivers/video/display/display-core.c  |  2 +-
  drivers/video/exynos/exynos_dp_core.c | 88 
 +++
  drivers/video/exynos/exynos_dp_core.h |  6 +++
  3 files changed, 95 insertions(+), 1 deletion(-)

 diff --git a/drivers/video/display/display-core.c 
 b/drivers/video/display/display-core.c
 index 5f8be30..dbad7e9 100644
 --- a/drivers/video/display/display-core.c
 +++ b/drivers/video/display/display-core.c
 @@ -15,7 +15,7 @@
  #include linux/list.h
  #include linux/module.h
  #include linux/mutex.h
 -#include linux/videomode.h
 +#include video/videomode.h

  #include video/display.h

 diff --git a/drivers/video/exynos/exynos_dp_core.c 
 b/drivers/video/exynos/exynos_dp_core.c
 index 4ef18e2..0f8de27b 100644
 --- a/drivers/video/exynos/exynos_dp_core.c
 +++ b/drivers/video/exynos/exynos_dp_core.c
 @@ -23,6 +23,9 @@
  #include video/exynos_dp.h

  #include exynos_dp_core.h
 +#include video/videomode.h
 +#include video/display.h
 +#define to_panel(p) container_of(p, struct exynos_dp_device, entity)

  static int exynos_dp_init_dp(struct exynos_dp_device *dp)
  {
 @@ -1033,6 +1036,81 @@ static void exynos_dp_phy_exit(struct 
 exynos_dp_device *dp)
  }
  #endif /* CONFIG_OF */

 +static int exynos_dp_power_on(struct exynos_dp_device *dp)
 +{
 +   struct platform_device *pdev = to_platform_device(dp-dev);
 +   struct exynos_dp_platdata *pdata = pdev-dev.platform_data;
 +
 +   if (dp-dev-of_node) {
 +   if (dp-phy_addr)
 +   exynos_dp_phy_init(dp);
 +   } else {
 +   if (pdata-phy_init)
 +   pdata-phy_init();
 +   }
 +
 +   clk_prepare_enable(dp-clock);
 +   exynos_dp_init_dp(dp);
 +   enable_irq(dp-irq);
 +
 +   return 0;
 +}
 +
 +static int dp_set_state(struct display_entity *entity,
 +   enum display_entity_state state)
 +{
 +   struct exynos_dp_device *dp = to_panel(entity);
 +   struct platform_device *pdev = to_platform_device(dp-dev);
 +   int ret = 0;
 +
 +   switch (state) {
 +   case DISPLAY_ENTITY_STATE_OFF:
 +   case DISPLAY_ENTITY_STATE_STANDBY:
 +   ret = exynos_dp_remove(pdev);

 This is incorrect, that is the module remove function. It seems like
 it works right now since there's nothing permanent happening (like
 platform data being freed), but there's no guarantee that this will
 remain like that in the future.

 IMO, you should factor out the common bits from remove and suspend
 into a new function which is called from all three.


Yes, I used the module remove function because it works fine with its
current state.
I'll factor out the common things and will create a common function.

 +   break;
 +   case DISPLAY_ENTITY_STATE_ON:
 +   ret = exynos_dp_power_on(dp);
 +   break;
 +   }
 +   return ret;
 +}
 +
 +static int dp_get_modes(struct display_entity *entity,
 +   const struct videomode **modes)
 +{
 +   /* Rework has to be done here*/
 +   return 1;

 Returning 1 here is pretty risky since you didn't actually allocate or
 populate a mode. I'm surprised this isn't causing some weird
 side-effects for you.


This current code is a dummy function, That is the reason to mention
Rework has to be done here
The current DP driver is not receiving any video mode properties. So I
have to think out how to get the same and will do the implementation.

 +}
 +
 +static int dp_get_size(struct display_entity *entity,
 +   unsigned int *width, unsigned int *height)
 +{
 +   struct exynos_dp_device *dp = to_panel(entity);
 +   struct platform_device *pdev = to_platform_device(dp-dev);
 +   /*getting pdata in older way, rework has to be done  here to
 + parse it from dt node */
 +   struct exynos_dp_platdata *pdata = pdev-dev.platform_data;
 +
 +   /*Rework has to be done here */
 +   *width = 1280;
 +   *height = 800;
 +   return 0;
 +}
 +
 +static int dp_update(struct display_entity *entity,
 +   void (*callback)(int, void *), void *data)
 +{
 +   /*Rework has to be done here*/
 +   return 0;
 +}
 +
 +static const struct display_entity_control_ops dp_control_ops = {
 +   .set_state = dp_set_state,
 +   .get_modes = dp_get_modes,
 +   .get_size = dp_get_size,
 +   .update = 

[PATCH] Correctly set data for USB request in case of a previous failure.

2013-01-14 Thread Hans Petter Selasky
From 89326793e2429dc55d951f336b3e3e3b73bedb95 Mon Sep 17 00:00:00 2001
From: Hans Petter Selasky hsela...@c2i.net
Date: Mon, 14 Jan 2013 13:53:21 +0100
Subject: [PATCH] Correctly set data for USB request in case of a previous
 failure.

Found-by: Jan Beich
Signed-off-by: Hans Petter Selasky hsela...@c2i.net
---
 drivers/input/tablet/wacom_sys.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index f92d34f..aaf23ae 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -553,10 +553,10 @@ static int wacom_set_device_mode(struct usb_interface 
*intf, int report_id, int
if (!rep_data)
return error;
 
-   rep_data[0] = report_id;
-   rep_data[1] = mode;
-
do {
+   rep_data[0] = report_id;
+   rep_data[1] = mode;
+
error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
 report_id, rep_data, length, 1);
if (error = 0)
-- 
1.7.11.4

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


Re: [PATCH] Correctly set data for USB request in case of a previous failure.

2013-01-14 Thread Hans Petter Selasky
Improved patch follows:

--HPS

From a88d72d2108f92f004a3f050a708d9b7f661f924 Mon Sep 17 00:00:00 2001
From: Hans Petter Selasky hsela...@c2i.net
Date: Mon, 14 Jan 2013 13:53:21 +0100
Subject: [PATCH] Correctly initialize data for USB request.

Found-by: Jan Beich
Signed-off-by: Hans Petter Selasky hsela...@c2i.net
---
 drivers/input/tablet/wacom.h | 1 +
 drivers/input/tablet/wacom_sys.c | 8 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index b79d451..d6fad87 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -89,6 +89,7 @@
 #include linux/init.h
 #include linux/usb/input.h
 #include linux/power_supply.h
+#include linux/string.h
 #include asm/unaligned.h
 
 /*
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index f92d34f..23bc71e 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -553,10 +553,12 @@ static int wacom_set_device_mode(struct usb_interface 
*intf, int report_id, int
if (!rep_data)
return error;
 
-   rep_data[0] = report_id;
-   rep_data[1] = mode;
-
do {
+   memset(rep_data, 0, length);
+
+   rep_data[0] = report_id;
+   rep_data[1] = mode;
+
error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
 report_id, rep_data, length, 1);
if (error = 0)
-- 
1.7.11.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


Problem between DMB-TH USB dongle drivers and Frontend broken (DVBv3 migrate to DVBv5)

2013-01-14 Thread nise.design

Hello,
 I'm a Ubuntu and DMB-TH digital TV USB dongle user.  The USB 
dongle working flawlessly in Ubuntu 10.XX, but it failed after migrate 
to latest Ubuntu 12.10.  Then I using google to find out the problem and 
suspect the problem come from DVBv3 migrate to DVBv5.  Because of 
creator of original DMB-TH drivers passed away so I wanted to continue 
his work to migrate DMB-TH drivers to new DVBv5 system.  I need some 
help to perform this task and the situation as below:


I plugged the USB dongle to USB port and it init normally:
[103542.354826] usb 2-1.7: new high-speed USB device number 9 using ehci_hcd
[103542.448349] usb 2-1.7: New USB device found, idVendor=0572, 
idProduct=d811
[103542.448353] usb 2-1.7: New USB device strings: Mfr=1, Product=2, 
SerialNumber=3

[103542.448356] usb 2-1.7: Product: USB Stick
[103542.448358] usb 2-1.7: Manufacturer: Geniatech
[103542.448360] usb 2-1.7: SerialNumber: 080116
[103542.449395] dvb-usb: found a 'Mygica D689 DMB-TH' in warm state.
[103542.790351] dvb-usb: will pass the complete MPEG2 transport stream 
to the software demuxer.

[103542.790666] DVB: registering new adapter (Mygica D689 DMB-TH)
[103543.038504] usb 2-1.7: DVB: registering adapter 0 frontend 0 
(AltoBeam ATBM8830/8831 DMB-TH)...
[103543.055041] input: IR-receiver inside an USB DVB receiver as 
/devices/pci:00/:00:1d.0/usb2/2-1/2-1.7/input/input18

[103543.055119] dvb-usb: schedule remote query interval to 100 msecs.
[103543.055215] dvb-usb: Mygica D689 DMB-TH successfully initialized and 
connected.


It failed after issued scan or any other command with messages:
[103835.202015] usb 2-1.7: dtv_property_cache_sync: doesn't know how to 
handle a DVBv3 call to delivery system 0


Its alway show : doesn't know how to handle a DVBv3 call to delivery 
system 0.  I have two dongles using altobeam 8830 chip and LG8GXX chip 
but both had same issued.


After google search I think the problem may be come from connection 
between DMB-TH drivers and dvb_frontend.c broken. I wanted to know any 
example code or instruction about DVBv3 driver connect to 
dvb_frontend.c.  Thank you for any advice.


KP Lee.

google search attached:

[PATCHv2 00/94] Only use DVBv5 internally on frontend drivers

Subject: [PATCHv2 00/94] Only use DVBv5 internally on frontend drivers
From: Mauro Carvalho Chehab mchehab@xx
Date: Fri, 30 Dec 2011 13:06:57 -0200
Cc: Mauro Carvalho Chehab mchehab@xx, Linux Media Mailing 
List linux-media@xxx


This patch series comes after the previous series of 47 patches. 
Basically, changes all DVB frontend drivers to work directly with the 
DVBv5 structure. This warrants that all drivers will be getting/setting 
frontend parameters on a consistent way, and opens space for improving 
the DVB core, in order to avoid copying data from/to the DVBv3 structs 
without need. Most of the patches on this series are trivial changes. 
Yet, it would be great to test them, in order to be sure that nothing 
broke. The last patch in this series hide the DVBv3 parameters struct 
from the frontend drivers, keeping them visible only to the dvb_core. 
This helps to warrant that everything were ported, and that newer 
patches won't re-introduce DVBv3 structs by mistake. There aren't many 
cleanups inside the dvb_frontend.c yet. Before cleaning up the core, I 
intend to do some tests with a some devices, in order to be sure that 
nothing broke with all those changes. Test reports are welcome.


[media] atbm8830: convert set_fontend to new way and fix delivery system
[media] lgs8gl5: convert set_fontend to use DVBv5 parameters
[media] lgs8gxx: convert set_fontend to use DVBv5 parameters

drivers/media/dvb/frontends/atbm8830.c | 24 ++--
drivers/media/dvb/frontends/lgs8gl5.c | 26 ++--
drivers/media/dvb/frontends/lgs8gxx.c | 23 ++--
--
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: Problem between DMB-TH USB dongle drivers and Frontend broken (DVBv3 migrate to DVBv5)

2013-01-14 Thread Devin Heitmueller
On Mon, Jan 14, 2013 at 1:01 PM, nise.design nise.des...@gmail.com wrote:
 After google search I think the problem may be come from connection between
 DMB-TH drivers and dvb_frontend.c broken. I wanted to know any example code
 or instruction about DVBv3 driver connect to dvb_frontend.c.  Thank you for
 any advice.

Before suggesting that this is the cause, you should do a kenrel
bisect and identify whether it worked before the patch series in
question, but fails after it is applied.  That will tell you whether
the patch[es] are really the problem, or whether you're just
speculating.

Devin
-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] uvc: Replace memcpy with struct assignment

2013-01-14 Thread Ezequiel Garcia
This kind of memcpy() is error-prone. Its replacement with a struct
assignment is prefered because it's type-safe and much easier to read.

Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Peter Senna Tschudin peter.se...@gmail.com
Signed-off-by: Ezequiel Garcia elezegar...@gmail.com
---
Changes from v1: 
 * Replaced a memcpy() in ucv_ctrl_add_info(),
   originally missed by the coccinelle script.

 drivers/media/usb/uvc/uvc_ctrl.c |2 +-
 drivers/media/usb/uvc/uvc_v4l2.c |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 516a5b1..f2f6443 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1839,7 +1839,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, 
struct uvc_control *ctrl,
 {
int ret = 0;
 
-   memcpy(ctrl-info, info, sizeof(*info));
+   ctrl-info = *info;
INIT_LIST_HEAD(ctrl-info.mappings);
 
/* Allocate an array to save control values (cur, def, max, etc.) */
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 8e05604..36e79ed 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -315,7 +315,7 @@ static int uvc_v4l2_set_format(struct uvc_streaming *stream,
goto done;
}
 
-   memcpy(stream-ctrl, probe, sizeof probe);
+   stream-ctrl = probe;
stream-cur_format = format;
stream-cur_frame = frame;
 
@@ -387,7 +387,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming 
*stream,
return -EBUSY;
}
 
-   memcpy(probe, stream-ctrl, sizeof probe);
+   probe = stream-ctrl;
probe.dwFrameInterval =
uvc_try_frame_interval(stream-cur_frame, interval);
 
@@ -398,7 +398,7 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming 
*stream,
return ret;
}
 
-   memcpy(stream-ctrl, probe, sizeof probe);
+   stream-ctrl = probe;
mutex_unlock(stream-mutex);
 
/* Return the actual frame period. */
-- 
1.7.4.4

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


Re: [RFC PATCH] saa7134: Add AverMedia Satelllite Hybrid+FM A706 (and FM radio problems)

2013-01-14 Thread Ondrej Zary
On Saturday 12 January 2013 21:24:50 Ondrej Zary wrote:
 Partially working: FM radio
 Radio seems to be a long-standing problem with saa7134 cards using silicon
 tuners (according to various mailing lists).

 On this card, GPIO11 controls 74HC4052 MUX. It switches two things:
 something at TDA18271 V_IFAGC pin and something that goes to SAA7131E.
 GPIO11 is enabled for radio and disabled for TV in Windows. I did the same
 thing in this patch.

 Windows INF file says:
 ; Setting FM radio of the Silicon tuner via SIF (GPIO 21 in use/ 5.5MHz)
 HKR, Audio, FM Radio IF, 0x00010001, 0xDEEAAB

 But that seems not to be true. GPIO21 does nothing and RegSpy (from
 DScaler, modified to include 0x42c register) says that the register is
 0x80729555. That matches the value present in saa7134-tvaudio.c (except the
 first 0x80).

 With this value, the radio stations are off by about 4.2-4.3 MHz, e.g.:
 station at 97.90 MHz is tuned as 102.20 MHz
 station at 101.80 MHz is tuned as 106.0 MHz

 I also tried 0xDEEAAB. With this, the offset is different, about 0.4 MHz:
 station at 101.80 MHz is tuned as 102.2 MHz

The offset seems bogus, maybe affected by my TV antenna (cable).

For debugging, tried another card with similar chips: Pinnacle PCTV 
40i/50i/110i. It has SAA7131E chip too, but different tuner - TDA8275A. And 
the radio problem is the same as found first on the A706 - the tuned station 
sound starts but then turns into noise. So it seems that the problem is not 
in tda18271 but in tda8290 or saa7134.

With tda8290.debug=1, I see this:
tda829x 2-004b: tda8290 not locked, no signal?
tda829x 2-004b: tda8290 not locked, no signal?
tda829x 2-004b: tda8290 not locked, no signal?
tda829x 2-004b: adjust gain, step 1. Agc: 193, ADC stat: 255, lock: 0
tda829x 2-004b: adjust gain, step 2. Agc: 255, lock: 0
tda829x 2-004b: adjust gain, step 3. Agc: 173

During that, the sound is good. Then it turns into noise.
When I increased the number of lock detections in tda8290_set_params() from 3 
to (e.g.) 10, it works longer. And when I'm quick enough to stop the console 
output using scroll lock, the radio remains working.

 And what's worst, connecting analog TV antenna (cable TV) affects the radio
 tuner! E.g. the radio is tuned to 106.0 MHz (real 101.80 MHz) with nice
 clean sound. Connecting TV antenna adds strong noise to the sound, tuning
 does not help. This problem is not present in Windows.

I've found a tiny chip marked S79 near the analog tuner. It's Skyworks 
AS179-92LF antenna switch that switches either the TV or FM antenna to the 
TDA18271 FM_IN pin! That's why TV antenna affected the radio. The switch is 
probably controlled by some other GPIO pin (haven't tested this yet). What's 
the best way to expose this switch to userspace?

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


cron job: media_tree daily build: ERRORS

2013-01-14 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:Mon Jan 14 19:00:15 CET 2013
git hash:3151d14aa6e983aa36d51a80d0477859f9ba12af
gcc version:  i686-linux-gcc (GCC) 4.7.1
host hardware:x86_64
host os:  3.4.07-marune

linux-git-arm-eabi-davinci: WARNINGS
linux-git-arm-eabi-exynos: WARNINGS
linux-git-arm-eabi-omap: ERRORS
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.31.12-i686: WARNINGS
linux-2.6.32.6-i686: WARNINGS
linux-2.6.33-i686: WARNINGS
linux-2.6.34-i686: WARNINGS
linux-2.6.35.3-i686: WARNINGS
linux-2.6.36-i686: WARNINGS
linux-2.6.37-i686: WARNINGS
linux-2.6.38.2-i686: WARNINGS
linux-2.6.39.1-i686: WARNINGS
linux-3.0-i686: WARNINGS
linux-3.1-i686: WARNINGS
linux-3.2.1-i686: WARNINGS
linux-3.3-i686: WARNINGS
linux-3.4-i686: WARNINGS
linux-3.5-i686: WARNINGS
linux-3.6-i686: WARNINGS
linux-3.7-i686: WARNINGS
linux-3.8-rc1-i686: OK
linux-2.6.31.12-x86_64: WARNINGS
linux-2.6.32.6-x86_64: WARNINGS
linux-2.6.33-x86_64: WARNINGS
linux-2.6.34-x86_64: WARNINGS
linux-2.6.35.3-x86_64: WARNINGS
linux-2.6.36-x86_64: WARNINGS
linux-2.6.37-x86_64: WARNINGS
linux-2.6.38.2-x86_64: WARNINGS
linux-2.6.39.1-x86_64: WARNINGS
linux-3.0-x86_64: WARNINGS
linux-3.1-x86_64: WARNINGS
linux-3.2.1-x86_64: WARNINGS
linux-3.3-x86_64: WARNINGS
linux-3.4-x86_64: WARNINGS
linux-3.5-x86_64: WARNINGS
linux-3.6-x86_64: WARNINGS
linux-3.7-x86_64: WARNINGS
linux-3.8-rc1-x86_64: OK
apps: WARNINGS
spec-git: OK
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

The V4L-DVB specification from this daily build is here:

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


Re: [PATCH] omap3isp: Add support for interlaced input data

2013-01-14 Thread William Swanson

On 01/09/2013 02:35 PM, Laurent Pinchart wrote:

On Tuesday 08 January 2013 14:49:41 William Swanson wrote:

I believe the data is combined in a single buffer, with alternate fields
interleaved.


Could you please double-check that ? I'd like to be sure, not just believe :-)


Sorry for the delay in getting back to you. I have checked it, and the 
fields are indeed interlaced into a single buffer. On the other hand, 
looking at this caused me to discover another problem with the patch.


According to the TI documentation, the CCDC_SDOFST register controls the 
deinterlacing process. My patch never configures this register, however, 
which is surprising. The reason things work on our boards is because we 
are carrying a separate patch which changes the register by accident. 
Oops! I have fixed this, and will be sending another patch with the 
CCDC_SDOFST changes.



In that case the OMAP3 ISP driver should set the v4l2_pix_format::field to
V4L2_FIELD_INTERLACED in the format-related ioctl when an interlaced format is
used. I suppose this could be added later - Sakari, any opinion ?


I don't have a lot of time to work on this stuff, so my main focus is 
just getting the data to flow. Changing the output format information 
involves other parts of the driver that I am not familiar with, so I 
don't know if I will be able to work on that bit.


By the way, thanks for taking the time to review this, Laurent.

-William
--
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] Support Digivox Mini HD (rtl2832)

2013-01-14 Thread Eddi De Pieri
Add support for Digivox Mini HD (rtl2832)

The tuner works, but with worst performance then realtek linux driver,
due to incomplete implementation of fc2580.c

Signed-off-by: Eddi De Pieri e...@depieri.net
Tested-by: Lorenzo Dongarrà lorenzo...@katamail.com

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index b6f4849..c05ea16 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1368,6 +1368,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = {
rtl2832u_props, ASUS My Cinema-U3100Mini Plus V2, NULL) },
{ DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd393,
rtl2832u_props, GIGABYTE U7300, NULL) },
+   { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1104,
+   rtl2832u_props, Digivox Micro Hd, NULL) },
{ }
 };
 MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
--
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] omap3isp: Add support for interlaced input data

2013-01-14 Thread William Swanson
If the remote video sensor reports an interlaced video mode, the CCDC block
should configure itself appropriately.

This patch reintroduces code with was removed in commit
cf7a3d91ade6c56bfd860b377f84bd58132f7a81, but in a way that is compatible
with the new media pipeline work.

This patch also cleans up the ccdc_config_outlineoffset function, which was
exposing too may low-level configuration bits. The only useful register
settings correspond to deinterlacing the video and flipping the image
vertically. Vertical flipping isn't used, so the function simply exposes
a boolean flag to enable deinterlacing. A flag for vertical flipping could
be added later.

Signed-off-by: William Swanson william.swan...@fuel7.com
---
 drivers/media/platform/omap3isp/ispccdc.c |   57 +++--
 drivers/media/platform/omap3isp/ispreg.h  |4 --
 include/media/omap3isp.h  |3 ++
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispccdc.c 
b/drivers/media/platform/omap3isp/ispccdc.c
index 60e60aa..7b795e6e 100644
--- a/drivers/media/platform/omap3isp/ispccdc.c
+++ b/drivers/media/platform/omap3isp/ispccdc.c
@@ -876,19 +876,15 @@ static void ccdc_enable_vp(struct isp_ccdc_device *ccdc, 
u8 enable)
  * ccdc_config_outlineoffset - Configure memory saving output line offset
  * @ccdc: Pointer to ISP CCDC device.
  * @offset: Address offset to start a new line. Must be twice the
- *  Output width and aligned on 32 byte boundary
- * @oddeven: Specifies the odd/even line pattern to be chosen to store the
- *   output.
- * @numlines: Set the value 0-3 for +1-4lines, 4-7 for -1-4lines.
+ *  output width and aligned on 32 byte boundary
+ * @interlaced: Write alternate frames to memory with an even/odd pattern.
  *
  * - Configures the output line offset when stored in memory
- * - Sets the odd/even line pattern to store the output
- *(EVENEVEN (1), ODDEVEN (2), EVENODD (3), ODDODD (4))
  * - Configures the number of even and odd line fields in case of rearranging
  * the lines.
  */
 static void ccdc_config_outlineoffset(struct isp_ccdc_device *ccdc,
-   u32 offset, u8 oddeven, u8 numlines)
+   u32 offset, bool interlaced)
 {
struct isp_device *isp = to_isp_device(ccdc);
 
@@ -901,25 +897,18 @@ static void ccdc_config_outlineoffset(struct 
isp_ccdc_device *ccdc,
isp_reg_clr(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SDOFST,
ISPCCDC_SDOFST_FOFST_4L);
 
-   switch (oddeven) {
-   case EVENEVEN:
+   if (interlaced) {
isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SDOFST,
-   (numlines  0x7)  ISPCCDC_SDOFST_LOFST0_SHIFT);
-   break;
-   case ODDEVEN:
-   isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SDOFST,
-   (numlines  0x7)  ISPCCDC_SDOFST_LOFST1_SHIFT);
-   break;
-   case EVENODD:
-   isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SDOFST,
-   (numlines  0x7)  ISPCCDC_SDOFST_LOFST2_SHIFT);
-   break;
-   case ODDODD:
-   isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SDOFST,
-   (numlines  0x7)  ISPCCDC_SDOFST_LOFST3_SHIFT);
-   break;
-   default:
-   break;
+   1  ISPCCDC_SDOFST_LOFST0_SHIFT |
+   1  ISPCCDC_SDOFST_LOFST1_SHIFT |
+   1  ISPCCDC_SDOFST_LOFST2_SHIFT |
+   1  ISPCCDC_SDOFST_LOFST3_SHIFT );
+   } else {
+   isp_reg_clr(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_SDOFST,
+   0x7  ISPCCDC_SDOFST_LOFST0_SHIFT |
+   0x7  ISPCCDC_SDOFST_LOFST1_SHIFT |
+   0x7  ISPCCDC_SDOFST_LOFST2_SHIFT |
+   0x7  ISPCCDC_SDOFST_LOFST3_SHIFT );
}
 }
 
@@ -970,10 +959,11 @@ void omap3isp_ccdc_max_rate(struct isp_ccdc_device *ccdc,
  * @ccdc: Pointer to ISP CCDC device.
  * @pdata: Parallel interface platform data (may be NULL)
  * @data_size: Data size
+ * @interlaced: Use interlaced mode instead of progressive mode
  */
 static void ccdc_config_sync_if(struct isp_ccdc_device *ccdc,
struct isp_parallel_platform_data *pdata,
-   unsigned int data_size)
+   unsigned int data_size, bool interlaced)
 {
struct isp_device *isp = to_isp_device(ccdc);
const struct v4l2_mbus_framefmt *format;
@@ -1004,9 +994,15 @@ static void ccdc_config_sync_if(struct isp_ccdc_device 
*ccdc,
break;
}
 
+   if (interlaced)
+   syn_mode |= ISPCCDC_SYN_MODE_FLDMODE;
+
if (pdata  pdata-data_pol)
syn_mode |= ISPCCDC_SYN_MODE_DATAPOL;
 
+   if (pdata  

Re: [PATCH] Support Digivox Mini HD (rtl2832)

2013-01-14 Thread Eddi De Pieri
usb 1-2.2: DVB: registering adapter 1 frontend 0 (Realtek RTL2832 (DVB-T))...
i2c i2c-4: fc2580: FCI FC2580 successfully identified
usb 1-2.2: dvb_usb_v2: 'Digivox Micro Hd' successfully initialized and connected

On Mon, Jan 14, 2013 at 11:21 PM, Eddi De Pieri e...@depieri.net wrote:
 Add support for Digivox Mini HD (rtl2832)

 The tuner works, but with worst performance then realtek linux driver,
 due to incomplete implementation of fc2580.c

 Signed-off-by: Eddi De Pieri e...@depieri.net
 Tested-by: Lorenzo Dongarrà lorenzo...@katamail.com

 diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
 b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
 index b6f4849..c05ea16 100644
 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
 +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
 @@ -1368,6 +1368,8 @@ static const struct usb_device_id rtl28xxu_id_table[] = 
 {
 rtl2832u_props, ASUS My Cinema-U3100Mini Plus V2, NULL) },
 { DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd393,
 rtl2832u_props, GIGABYTE U7300, NULL) },
 +   { DVB_USB_DEVICE(USB_VID_DEXATEK, 0x1104,
 +   rtl2832u_props, Digivox Micro Hd, NULL) },
 { }
  };
  MODULE_DEVICE_TABLE(usb, rtl28xxu_id_table);
--
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 RFC v1 2/2] V4L: Add driver for OV9650/52 image sensors

2013-01-14 Thread Sylwester Nawrocki

On 01/14/2013 10:45 AM, Hans Verkuil wrote:

On Mon January 14 2013 00:14:39 Sylwester Nawrocki wrote:

...

I've checked the datasheets and the gain ceiling control is supported by
virtually every Omnivision sensor: OV2655, OV3640, OV5630, OV9650, OV9655,
OV7690, with even identical range 2x...128x.

The _OV965X prefix for the control doesn't seem right then. Should I make
it something (ugly) like V4L2_CID_OV_GAIN_CEILING ?


In that case it would make sense to make this a documented chipset control.
See e.g. the cx2341x and mfc51 MPEG controls:

http://hverkuil.home.xs4all.nl/spec/media.html#mpeg-controls

I'd drop the  in that case.


That makes sense. I'm not sure if I'll manage to complete all this in time
for v3.9. I guess it would be OK to postpone adding these 2 private 
controls

to the next kernel release ? In fact they are only nice to have ones.


And should ranges be reserved for each driver ?


Both, actually. Chipset specific controls get a range, and so do driver specific
controls.


OK. I will likely need to create such a control set for Exynos4412/Exynos5
camera ISP. There should be not many of them but I suspect we'll need some.


Or maybe only per
manufacturer?

...

+static int ov965x_set_gain(struct ov965x *ov965x, int auto_gain, bool init)
+{
+   struct i2c_client *client = ov965x-client;
+   struct ov965x_ctrls *ctrls =ov965x-ctrls;
+   int ret = 0;
+   u8 reg;
+   /*
+* For manual mode we need to disable AGC first, so
+* gain value in REG_VREF, REG_GAIN is not overwritten.
+*/
+   if (ctrls-auto_gain-is_new || init) {
+   ret = ov965x_read(client, REG_COM8,reg);
+   if (ret   0)
+   return ret;
+   if (ctrls-auto_gain-val)
+   reg |= COM8_AGC;
+   else
+   reg= ~COM8_AGC;
+   ret = ov965x_write(client, REG_COM8, reg);
+   if (ret   0)
+   return ret;
+   }
+
+   if ((ctrls-gain-is_new || init)   !auto_gain) {
+   unsigned int gain = ctrls-gain-val;
+   unsigned int rgain;
+   int m;
+   /*
+* Convert gain control value to the sensor's gain
+* registers (VREF[7:6], GAIN[7:0]) format.
+*/
+   for (m = 6; m= 0; m--)
+   if (gain= (1   m) * 16)
+   break;
+   rgain = (gain - ((1   m) * 16)) / (1   m);
+   rgain |= (((1   m) - 1)   4);
+
+   ret = ov965x_write(client, REG_GAIN, rgain   0xff);
+   if (ret   0)
+   return ret;
+   ret = ov965x_read(client, REG_VREF,reg);
+   if (ret   0)
+   return ret;
+   reg= ~VREF_GAIN_MASK;
+   reg |= (((rgain   8)   0x3)   6);
+   ret = ov965x_write(client, REG_VREF, reg);
+   if (ret   0)
+   return ret;
+   /* Return updated control's value to userspace */
+   ctrls-gain-val = (1   m) * (16 + (rgain   0xf));
+   }
+
+   if (ctrls-gain_ceiling-is_new || init) {
+   u8 gc = ctrls-gain_ceiling-val;
+   ret = ov965x_read(client, REG_COM9,reg);
+   if (!ret) {
+   reg= ~COM9_GAIN_CEIL_MASK;
+   reg |= ((gc   0x07)   4);
+   ret = ov965x_write(client, REG_COM9, reg);
+   }
+   }
+   if (auto_gain)
+   ctrls-gain-flags |= CTRL_FLAG_READ_ONLY_VOLATILE;
+   else
+   ctrls-gain-flags= ~CTRL_FLAG_READ_ONLY_VOLATILE;
+
+   return ret;
+}

...

+static int ov965x_set_exposure(struct ov965x *ov965x, int exp, bool init)
+{
+   struct i2c_client *client = ov965x-client;
+   struct ov965x_ctrls *ctrls =ov965x-ctrls;
+   bool auto_exposure = (exp == V4L2_EXPOSURE_AUTO);
+   int ret;
+   u8 reg;
+
+   if (ctrls-auto_exp-is_new || init) {
+   ret = ov965x_read(client, REG_COM8,reg);
+   if (ret   0)
+   return ret;
+   if (auto_exposure)
+   reg |= (COM8_AEC | COM8_AGC);
+   else
+   reg= ~(COM8_AEC | COM8_AGC);
+   ret = ov965x_write(client, REG_COM8, reg);
+   if (ret   0)
+   return ret;
+   }
+
+   if (!auto_exposure   (ctrls-exposure-is_new || init)) {
+   unsigned int exposure = (ctrls-exposure-val * 100)
+/ ov965x-exp_row_interval;
+   /*
+* Manual exposure value
+* [b15:b0] - AECHM (b15:b10), AECH (b9:b2), COM1 (b1:b0)
+*/
+   ret = ov965x_write(client, REG_COM1, exposure   0x3);
+   if (!ret)
+   ret = 

Re: [PATCH 0/2] OMAP3 ISP: Simplify clock usage

2013-01-14 Thread Mike Turquette
Quoting Laurent Pinchart (2013-01-08 05:43:52)
 Hello,
 
 Now that the OMAP3 supports the common clock framework, clock rate
 back-propagation is available for the ISP clocks. Instead of setting the
 cam_mclk parent clock rate to control the cam_mclk clock rate, we can mark the
 dpll4_m5x2_ck_3630 and cam_mclk clocks as supporting back-propagation, and set
 the cam_mclk rate directly. This simplifies the ISP clocks configuration.


I'm pleased to see this feature get used on OMAP.  Plus your driver gets
a negative diffstat :)

Reviewed-by: Mike Turquette mturque...@linaro.org
 
 Laurent Pinchart (2):
   ARM: OMAP3: clock: Back-propagate rate change from cam_mclk to
 dpll4_m5
   omap3isp: Set cam_mclk rate directly
 
  arch/arm/mach-omap2/cclock3xxx_data.c |   10 +-
  drivers/media/platform/omap3isp/isp.c |   18 ++
  drivers/media/platform/omap3isp/isp.h |8 +++-
  3 files changed, 14 insertions(+), 22 deletions(-)
 
 -- 
 Regards,
 
 Laurent Pinchart
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFCv10 00/15] DVB QoS statistics API

2013-01-14 Thread Mauro Carvalho Chehab
Add DVBv5 methods to retrieve QoS statistics.

Those methods allow per-layer and global statistics.

Implemented 2 QoS statistics on mb86a20s, one global only
(signal strengh), and one per layer (BER).

Tested with a modified version of dvbv5-zap, that allows monitoring
those stats. Test data follows

Tested with 1-segment at layer A, and 12-segment at layer B:

[ 3735.973058] i2c i2c-4: mb86a20s_layer_bitrate: layer A bitrate: 440 kbps; 
counter = 196608 (0x03)
[ 3735.976803] i2c i2c-4: mb86a20s_layer_bitrate: layer B bitrate: 16851 kbps; 
counter = 8257536 (0x7e)

a) Global stats:

Signal strength:
QOS_SIGNAL_STRENGTH[0] = 4096

BER (sum of BE count and bit counts for both layers):
QOS_BIT_ERROR_COUNT[0] = 1087865
QOS_TOTAL_BITS_COUNT[0] = 67043313

b) Per-layer stats:

Layer A BER:
QOS_BIT_ERROR_COUNT[1] = 236
QOS_TOTAL_BITS_COUNT[1] = 917490

Layer B BER:
QOS_BIT_ERROR_COUNT[2] = 1087629
QOS_TOTAL_BITS_COUNT[2] = 66125823

TODO:
- add more statistics at mb86a20s;
- implement support for DTV_QOS_ENUM;
- some cleanups at get_frontend logic at dvb core, to avoid
  it to be called outside the DVB thread loop.

All the above changes can be done a little later during this development
cycle, so my plan is to merge it upstream at the beginning of the 
next week, to allow others to test.

I added an ugly hack on my experimental v4l-utils tree, to allow
testing it:

http://git.linuxtv.org/mchehab/experimental-v4l-utils.git/shortlog/refs/heads/stats

GIT url for it is:
git://linuxtv.org/mchehab/experimental-v4l-utils.git stats


---

v6: Add DocBook documentation.
v7: Some fixes as suggested by Antti
v8: Documentation fix, compilation fix and name the stats struct,
for its reusage inside the core
v9: counters need 32 bits. So, change the return data types to
s32/u32 types
v10: Counters changed to 64 bits for monotonic increment
 Don't create a separate get_stats callback. get_frontend
 is already good enough for it.


Mauro Carvalho Chehab (15):
  mb86a20s: improve error handling at get_frontend
  dvb: Add DVBv5 stats properties for Quality of Service
  dvb: the core logic to handle the DVBv5 QoS properties
  mb86a20s: Update QoS statistics at FE read_status
  mb86a20s: functions reorder
  mb86a20s: Fix i2c gate on error
  mb86a20s: improve debug for RF level
  mb86a20s: fix interleaving and FEC retrival
  mb86a20s: convert it to use dev_info/dev_err/dev_dbg
  mb86a20s: -EBUSY is expected when getting QoS measures
  mb86a20s: make AGC work better
  mb86a20s: Some improvements for BER measurement
  mb86a20s: improve bit error count for BER
  dvb: increase API version
  mb86a20s: global stat is just a sum, and not an increment

 Documentation/DocBook/media/dvb/dvbapi.xml  |2 +-
 Documentation/DocBook/media/dvb/dvbproperty.xml |  115 ++-
 drivers/media/dvb-core/dvb_frontend.c   |   53 ++
 drivers/media/dvb-core/dvb_frontend.h   |   11 +
 drivers/media/dvb-frontends/mb86a20s.c  | 1024 ++-
 include/uapi/linux/dvb/frontend.h   |   83 +-
 include/uapi/linux/dvb/version.h|2 +-
 7 files changed, 1066 insertions(+), 224 deletions(-)

-- 
1.7.11.7

--
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 RFCv10 04/15] mb86a20s: Update QoS statistics at FE read_status

2013-01-14 Thread Mauro Carvalho Chehab
Instead of providing separate callbacks to read the several FE
status properties, the better seems to use just one method that will:

- Read lock status;
- Read signal strength;
- if locked, get TMCC data;
- if locked, get DVB status.

As the DVB frontend thread will call this method on every 3 seconds,
all QoS data will be updated together, with is a good thing.

It also prevents userspace to generate undesired I2C traffic.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 372 +
 1 file changed, 336 insertions(+), 36 deletions(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index 4ff3a0c..0f8d9bc 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -43,6 +43,12 @@ struct mb86a20s_state {
struct dvb_frontend frontend;
 
bool need_init;
+
+   /*
+* QoS measure flags to be used to know when it is possible to
+* artificially generate a global measure, based on all 3 layers
+*/
+   bool read_ber[3];
 };
 
 struct regdata {
@@ -92,7 +98,7 @@ static struct regdata mb86a20s_init[] = {
{ 0x04, 0x13 }, { 0x05, 0xff },
{ 0x04, 0x15 }, { 0x05, 0x4e },
{ 0x04, 0x16 }, { 0x05, 0x20 },
-   { 0x52, 0x01 },
+   { 0x52, 0x01 }, /* Turn on BER before Viterbi */
{ 0x50, 0xa7 }, { 0x51, 0xff },
{ 0x50, 0xa8 }, { 0x51, 0xff },
{ 0x50, 0xa9 }, { 0x51, 0xff },
@@ -117,8 +123,8 @@ static struct regdata mb86a20s_init[] = {
{ 0x50, 0xb6 }, { 0x51, 0xff },
{ 0x50, 0xb7 }, { 0x51, 0xff },
{ 0x50, 0x50 }, { 0x51, 0x02 },
-   { 0x50, 0x51 }, { 0x51, 0x04 },
-   { 0x45, 0x04 },
+   { 0x50, 0x51 }, { 0x51, 0x04 }, /* MER symbol 4 */
+   { 0x45, 0x04 }, /* CN symbol 4 */
{ 0x48, 0x04 },
{ 0x50, 0xd5 }, { 0x51, 0x01 }, /* Serial */
{ 0x50, 0xd6 }, { 0x51, 0x1f },
@@ -174,6 +180,20 @@ static struct regdata mb86a20s_reset_reception[] = {
{ 0x08, 0x00 },
 };
 
+static struct regdata mb86a20s_vber_reset[] = {
+   { 0x53, 0x00 }, /* VBER Counter reset */
+   { 0x53, 0x07 },
+};
+
+static struct regdata mb86a20s_clear_stats[] = {
+   { 0x5f, 0x00 }, /* SBER Counter reset */
+   { 0x5f, 0x07 },
+
+   { 0x50, 0xb1 }, /* PBER Counter reset */
+   { 0x51, 0x07 },
+   { 0x51, 0x01 },
+};
+
 static int mb86a20s_i2c_writereg(struct mb86a20s_state *state,
 u8 i2c_addr, int reg, int data)
 {
@@ -221,7 +241,7 @@ static int mb86a20s_i2c_readreg(struct mb86a20s_state 
*state,
 
if (rc != 2) {
rc(%s: reg=0x%x (error=%d)\n, __func__, reg, rc);
-   return rc;
+   return (rc  0) ? rc : -EIO;
}
 
return val;
@@ -276,59 +296,61 @@ err:
return rc;
 }
 
-static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 
*strength)
+static int mb86a20s_read_signal_strength(struct dvb_frontend *fe)
 {
struct mb86a20s_state *state = fe-demodulator_priv;
+   int rc;
unsigned rf_max, rf_min, rf;
-   u8   val;
-
-   dprintk(\n);
-
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
 
/* Does a binary search to get RF strength */
rf_max = 0xfff;
rf_min = 0;
do {
rf = (rf_max + rf_min) / 2;
-   mb86a20s_writereg(state, 0x04, 0x1f);
-   mb86a20s_writereg(state, 0x05, rf  8);
-   mb86a20s_writereg(state, 0x04, 0x20);
-   mb86a20s_writereg(state, 0x04, rf);
+   rc = mb86a20s_writereg(state, 0x04, 0x1f);
+   if (rc  0)
+   return rc;
+   rc = mb86a20s_writereg(state, 0x05, rf  8);
+   if (rc  0)
+   return rc;
+   rc = mb86a20s_writereg(state, 0x04, 0x20);
+   if (rc  0)
+   return rc;
+   rc = mb86a20s_writereg(state, 0x04, rf);
+   if (rc  0)
+   return rc;
 
-   val = mb86a20s_readreg(state, 0x02);
-   if (val  0x08)
+   rc = mb86a20s_readreg(state, 0x02);
+   if (rc  0)
+   return rc;
+   if (rc  0x08)
rf_min = (rf_max + rf_min) / 2;
else
rf_max = (rf_max + rf_min) / 2;
if (rf_max - rf_min  4) {
-   *strength = (((rf_max + rf_min) / 2) * 65535) / 4095;
-   break;
+   rf = (rf_max + rf_min) / 2;
+
+   /* Rescale it from 2^12 (4096) to 2^16 */
+   rf = (16 - 12);
+   dprintk(signal strength = %d\n, rf);
+

[PATCH RFCv10 06/15] mb86a20s: Fix i2c gate on error

2013-01-14 Thread Mauro Carvalho Chehab
If an error happens, restore tuner I2C gate to the right
value.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index c91e9b9..06e5d35 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -814,10 +814,10 @@ static int mb86a20s_initfe(struct dvb_frontend *fe)
goto err;
}
 
+err:
if (fe-ops.i2c_gate_ctrl)
fe-ops.i2c_gate_ctrl(fe, 1);
 
-err:
if (rc  0) {
state-need_init = true;
printk(KERN_INFO mb86a20s: Init failed. Will try again 
later\n);
@@ -841,6 +841,10 @@ static int mb86a20s_set_frontend(struct dvb_frontend *fe)
 
dprintk(\n);
 
+   /*
+* Gate should already be opened, but it doesn't hurt to
+* double-check
+*/
if (fe-ops.i2c_gate_ctrl)
fe-ops.i2c_gate_ctrl(fe, 1);
dprintk(Calling tuner set parameters\n);
-- 
1.7.11.7

--
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 RFCv10 13/15] mb86a20s: improve bit error count for BER

2013-01-14 Thread Mauro Carvalho Chehab
Do a better job on setting the bit error counters, in order to
have all layer measures to happen in a little less than one
second.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 204 +
 1 file changed, 179 insertions(+), 25 deletions(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index 0d13c87..2f3e4b3 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -30,6 +30,8 @@ struct mb86a20s_state {
 
struct dvb_frontend frontend;
 
+   u32 estimated_rate[3];
+
bool need_init;
 
/*
@@ -89,31 +91,20 @@ static struct regdata mb86a20s_init[] = {
 
/*
 * On this demod, when the bit count reaches the count below,
-* it collects the bit error count.
-*
-* As FE thread runs on every 3 seconds, adjust the counters to
-* provide one collect before 3 seconds, at the worse case (DQPSK,
-* 1/4 guard interval, 1/2 FEC, 1-seg rate is 280 Mbps, and
-* 3 seconds takes 0xcdb9f bits. Rounds it down to 0xccfff
-*
-* It should be noticed, however, that, with QAM-64 1/32 guard interval,
-* 1 segment bit rate is 1.78 Mbps, and 12-seg is about 21.5 Mbps.
-* At such rate, the time to measure BER is about 40 ms.
-*
-* It makes sense to change the logic there to use TMCC parameters and
-* adjust the counters in order to have all of them to take a little
-* less than 3 seconds, in order to have a more realistic BER rate,
-* instead of having short samples for 12-segs.
+* it collects the bit error count. The bit counters are initialized
+* to 65535 here. This warrants that all of them will be quickly
+* calculated when device gets locked. As TMCC is parsed, the values
+* will be adjusted later in the driver's code.
 */
{ 0x52, 0x01 }, /* Turn on BER before Viterbi */
-   { 0x50, 0xa7 }, { 0x51, 0x0c },
-   { 0x50, 0xa8 }, { 0x51, 0xcf },
+   { 0x50, 0xa7 }, { 0x51, 0x00 },
+   { 0x50, 0xa8 }, { 0x51, 0xff },
{ 0x50, 0xa9 }, { 0x51, 0xff },
-   { 0x50, 0xaa }, { 0x51, 0x0c },
-   { 0x50, 0xab }, { 0x51, 0xcf },
+   { 0x50, 0xaa }, { 0x51, 0x00 },
+   { 0x50, 0xab }, { 0x51, 0xff },
{ 0x50, 0xac }, { 0x51, 0xff },
-   { 0x50, 0xad }, { 0x51, 0x0c },
-   { 0x50, 0xae }, { 0x51, 0xcf },
+   { 0x50, 0xad }, { 0x51, 0x00 },
+   { 0x50, 0xae }, { 0x51, 0xff },
{ 0x50, 0xaf }, { 0x51, 0xff },
 
{ 0x5e, 0x07 },
@@ -208,7 +199,7 @@ static struct regdata mb86a20s_clear_stats[] = {
  */
 
 static int mb86a20s_i2c_writereg(struct mb86a20s_state *state,
-u8 i2c_addr, int reg, int data)
+u8 i2c_addr, u8 reg, u8 data)
 {
u8 buf[] = { reg, data };
struct i2c_msg msg = {
@@ -440,7 +431,21 @@ static int mb86a20s_get_interleaving(struct mb86a20s_state 
*state,
rc = mb86a20s_readreg(state, 0x6e);
if (rc  0)
return rc;
-   return (rc  4)  0x07;
+
+   switch ((rc  4)  0x07) {
+   case 1:
+   return GUARD_INTERVAL_1_4;
+   case 2:
+   return GUARD_INTERVAL_1_8;
+   case 3:
+   return GUARD_INTERVAL_1_16;
+   case 4:
+   return GUARD_INTERVAL_1_32;
+
+   default:
+   case 0:
+   return GUARD_INTERVAL_AUTO;
+   }
 }
 
 static int mb86a20s_get_segment_count(struct mb86a20s_state *state,
@@ -490,6 +495,112 @@ static void mb86a20s_reset_frontend_cache(struct 
dvb_frontend *fe)
c-isdbt_sb_segment_count = 0;
 }
 
+/*
+ * Estimates the bit rate using the per-segment bit rate given by
+ * ABNT/NBR 15601 spec (table 4).
+ */
+static u32 isdbt_rate[3][5][4] = {
+   {   /* DQPSK/QPSK */
+   {  280850,  312060,  330420,  340430 }, /* 1/2 */
+   {  374470,  416080,  440560,  453910 }, /* 2/3 */
+   {  421280,  468090,  495630,  510650 }, /* 3/4 */
+   {  468090,  520100,  550700,  567390 }, /* 5/6 */
+   {  491500,  546110,  578230,  595760 }, /* 7/8 */
+   }, {/* QAM16 */
+   {  561710,  624130,  660840,  680870 }, /* 1/2 */
+   {  748950,  832170,  881120,  907820 }, /* 2/3 */
+   {  842570,  936190,  991260, 1021300 }, /* 3/4 */
+   {  936190, 1040210, 1101400, 1134780 }, /* 5/6 */
+   {  983000, 1092220, 1156470, 1191520 }, /* 7/8 */
+   }, {/* QAM64 */
+   {  842570,  936190,  991260, 1021300 }, /* 1/2 */
+   { 1123430, 1248260, 1321680, 1361740 }, /* 2/3 */
+   { 1263860, 1404290, 1486900, 1531950 }, /* 3/4 */
+   { 1404290, 1560320, 1652110, 1702170 }, /* 5/6 */
+   { 

[PATCH RFCv10 14/15] dvb: increase API version

2013-01-14 Thread Mauro Carvalho Chehab
Due to statistics, we should update the DVB API version.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 Documentation/DocBook/media/dvb/dvbapi.xml | 2 +-
 include/uapi/linux/dvb/version.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/DocBook/media/dvb/dvbapi.xml 
b/Documentation/DocBook/media/dvb/dvbapi.xml
index 757488b..0197bcc 100644
--- a/Documentation/DocBook/media/dvb/dvbapi.xml
+++ b/Documentation/DocBook/media/dvb/dvbapi.xml
@@ -84,7 +84,7 @@ Added ISDB-T test originally written by Patrick Boettcher
 
 
 titleLINUX DVB API/title
-subtitleVersion 5.8/subtitle
+subtitleVersion 5.10/subtitle
 !-- ADD THE CHAPTERS HERE --
   chapter id=dvb_introdution
 sub-intro;
diff --git a/include/uapi/linux/dvb/version.h b/include/uapi/linux/dvb/version.h
index 827cce7..e53e2ad 100644
--- a/include/uapi/linux/dvb/version.h
+++ b/include/uapi/linux/dvb/version.h
@@ -24,6 +24,6 @@
 #define _DVBVERSION_H_
 
 #define DVB_API_VERSION 5
-#define DVB_API_VERSION_MINOR 9
+#define DVB_API_VERSION_MINOR 10
 
 #endif /*_DVBVERSION_H_*/
-- 
1.7.11.7

--
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 RFCv10 11/15] mb86a20s: make AGC work better

2013-01-14 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index c4bf428..21e7e68 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -120,7 +120,8 @@ static struct regdata mb86a20s_init[] = {
{ 0x50, 0xd7 }, { 0x51, 0x3f },
{ 0x28, 0x74 }, { 0x29, 0x00 }, { 0x28, 0x74 }, { 0x29, 0x40 },
{ 0x28, 0x46 }, { 0x29, 0x2c }, { 0x28, 0x46 }, { 0x29, 0x0c },
-   { 0x04, 0x40 }, { 0x05, 0x01 },
+
+   { 0x04, 0x40 }, { 0x05, 0x00 },
{ 0x28, 0x00 }, { 0x29, 0x10 },
{ 0x28, 0x05 }, { 0x29, 0x02 },
{ 0x1c, 0x01 },
-- 
1.7.11.7

--
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 RFCv10 03/15] dvb: the core logic to handle the DVBv5 QoS properties

2013-01-14 Thread Mauro Carvalho Chehab
Add the logic to poll, reset counters and report the QoS stats
to the end user.

The idea is that the core will periodically poll the frontend for
the stats. The frontend may return -EBUSY, if the previous collect
didn't finish, or it may fill the cached data.

The value returned to the end user is always the cached data.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-core/dvb_frontend.c | 53 +++
 drivers/media/dvb-core/dvb_frontend.h | 11 
 2 files changed, 64 insertions(+)

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index dd35fa9..e48e46fb 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -1053,6 +1053,15 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = 
{
_DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_B, 0, 0),
_DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_C, 0, 0),
_DTV_CMD(DTV_ATSCMH_SCCC_CODE_MODE_D, 0, 0),
+
+   /* Statistics API */
+   _DTV_CMD(DTV_QOS_ENUM, 0, 0),
+   _DTV_CMD(DTV_QOS_SIGNAL_STRENGTH, 0, 0),
+   _DTV_CMD(DTV_QOS_CNR, 0, 0),
+   _DTV_CMD(DTV_QOS_BIT_ERROR_COUNT, 0, 0),
+   _DTV_CMD(DTV_QOS_TOTAL_BITS_COUNT, 0, 0),
+   _DTV_CMD(DTV_QOS_ERROR_BLOCK_COUNT, 0, 0),
+   _DTV_CMD(DTV_QOS_TOTAL_BLOCKS_COUNT, 0, 0),
 };
 
 static void dtv_property_dump(struct dvb_frontend *fe, struct dtv_property 
*tvp)
@@ -1443,6 +1452,25 @@ static int dtv_property_process_get(struct dvb_frontend 
*fe,
tvp-u.data = c-lna;
break;
 
+   /* Fill quality measures */
+   case DTV_QOS_SIGNAL_STRENGTH:
+   tvp-u.st = c-strength;
+   break;
+   case DTV_QOS_CNR:
+   tvp-u.st = c-cnr;
+   break;
+   case DTV_QOS_BIT_ERROR_COUNT:
+   tvp-u.st = c-bit_error;
+   break;
+   case DTV_QOS_TOTAL_BITS_COUNT:
+   tvp-u.st = c-bit_count;
+   break;
+   case DTV_QOS_ERROR_BLOCK_COUNT:
+   tvp-u.st = c-block_error;
+   break;
+   case DTV_QOS_TOTAL_BLOCKS_COUNT:
+   tvp-u.st = c-block_count;
+   break;
default:
return -EINVAL;
}
@@ -1646,6 +1674,26 @@ static int set_delivery_system(struct dvb_frontend *fe, 
u32 desired_system)
return 0;
 }
 
+static int reset_qos_counters(struct dvb_frontend *fe)
+{
+   struct dtv_frontend_properties *c = fe-dtv_property_cache;
+
+   /* Reset QoS cache */
+
+   memset (c-strength, 0, sizeof(c-strength));
+   memset (c-cnr, 0, sizeof(c-cnr));
+   memset (c-bit_error, 0, sizeof(c-bit_error));
+   memset (c-bit_count, 0, sizeof(c-bit_count));
+   memset (c-block_error, 0, sizeof(c-block_error));
+   memset (c-block_count, 0, sizeof(c-block_count));
+
+   /* Call frontend reset counter method, if available */
+   if (fe-ops.reset_qos_counters)
+   return fe-ops.reset_qos_counters(fe);
+
+   return 0;
+}
+
 static int dtv_property_process_set(struct dvb_frontend *fe,
struct dtv_property *tvp,
struct file *file)
@@ -1705,6 +1753,8 @@ static int dtv_property_process_set(struct dvb_frontend 
*fe,
break;
case DTV_DELIVERY_SYSTEM:
r = set_delivery_system(fe, tvp-u.data);
+   if (r = 0)
+   reset_qos_counters(fe);
break;
case DTV_VOLTAGE:
c-voltage = tvp-u.data;
@@ -2305,6 +2355,9 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
if (err)
break;
err = dtv_set_frontend(fe);
+   if (err = 0)
+   reset_qos_counters(fe);
+
break;
case FE_GET_EVENT:
err = dvb_frontend_get_event (fe, parg, file-f_flags);
diff --git a/drivers/media/dvb-core/dvb_frontend.h 
b/drivers/media/dvb-core/dvb_frontend.h
index 97112cd..b7aa815 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -315,6 +315,9 @@ struct dvb_frontend_ops {
 
int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
+
+   /* QoS statistics callbacks */
+   int (*reset_qos_counters)(struct dvb_frontend *fe);
 };
 
 #ifdef __DVB_CORE__
@@ -393,6 +396,14 @@ struct dtv_frontend_properties {
u8  atscmh_sccc_code_mode_d;
 
u32 lna;
+
+   /* QoS statistics data */
+   struct dtv_fe_stats strength;
+   struct dtv_fe_stats cnr;
+   struct dtv_fe_stats bit_error;
+   struct dtv_fe_stats bit_count;
+   struct dtv_fe_stats block_error;
+   struct dtv_fe_stats block_count;
 };
 
 struct 

[PATCH RFCv10 12/15] mb86a20s: Some improvements for BER measurement

2013-01-14 Thread Mauro Carvalho Chehab
Reduce the bit count from 2^24-1 to 2^16-1 to speedup
BER measurement;

Do a per-layer reset, instead of waiting for data on all
layers;

Global stats now start to appear as soon as the first layer
(e. g. the one with the biggest number of segments) start to
have collected data.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 52 +-
 1 file changed, 39 insertions(+), 13 deletions(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index 21e7e68..0d13c87 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -86,16 +86,36 @@ static struct regdata mb86a20s_init[] = {
{ 0x04, 0x13 }, { 0x05, 0xff },
{ 0x04, 0x15 }, { 0x05, 0x4e },
{ 0x04, 0x16 }, { 0x05, 0x20 },
+
+   /*
+* On this demod, when the bit count reaches the count below,
+* it collects the bit error count.
+*
+* As FE thread runs on every 3 seconds, adjust the counters to
+* provide one collect before 3 seconds, at the worse case (DQPSK,
+* 1/4 guard interval, 1/2 FEC, 1-seg rate is 280 Mbps, and
+* 3 seconds takes 0xcdb9f bits. Rounds it down to 0xccfff
+*
+* It should be noticed, however, that, with QAM-64 1/32 guard interval,
+* 1 segment bit rate is 1.78 Mbps, and 12-seg is about 21.5 Mbps.
+* At such rate, the time to measure BER is about 40 ms.
+*
+* It makes sense to change the logic there to use TMCC parameters and
+* adjust the counters in order to have all of them to take a little
+* less than 3 seconds, in order to have a more realistic BER rate,
+* instead of having short samples for 12-segs.
+*/
{ 0x52, 0x01 }, /* Turn on BER before Viterbi */
-   { 0x50, 0xa7 }, { 0x51, 0xff },
-   { 0x50, 0xa8 }, { 0x51, 0xff },
+   { 0x50, 0xa7 }, { 0x51, 0x0c },
+   { 0x50, 0xa8 }, { 0x51, 0xcf },
{ 0x50, 0xa9 }, { 0x51, 0xff },
-   { 0x50, 0xaa }, { 0x51, 0xff },
-   { 0x50, 0xab }, { 0x51, 0xff },
+   { 0x50, 0xaa }, { 0x51, 0x0c },
+   { 0x50, 0xab }, { 0x51, 0xcf },
{ 0x50, 0xac }, { 0x51, 0xff },
-   { 0x50, 0xad }, { 0x51, 0xff },
-   { 0x50, 0xae }, { 0x51, 0xff },
+   { 0x50, 0xad }, { 0x51, 0x0c },
+   { 0x50, 0xae }, { 0x51, 0xcf },
{ 0x50, 0xaf }, { 0x51, 0xff },
+
{ 0x5e, 0x07 },
{ 0x50, 0xdc }, { 0x51, 0x01 },
{ 0x50, 0xdd }, { 0x51, 0xf4 },
@@ -711,6 +731,14 @@ static int mb86a20s_get_ber_before_vterbi(struct 
dvb_frontend *fe,
%s: bit count before Viterbi for layer %c: %d.\n,
__func__, 'A' + layer, *count);
 
+   /* Reset counter to collect new data */
+   rc = mb86a20s_writereg(state, 0x53, 0x07  ~(1  layer));
+   if (rc  0)
+   return rc;
+   rc = mb86a20s_writereg(state, 0x53, 0x07);
+   if (rc  0)
+   return rc;
+
return 0;
 }
 
@@ -799,7 +827,11 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe)
}
}
 
-   if (active_layers == ber_layers) {
+   /*
+* Start showing global count if at least one error count is
+* available.
+*/
+   if (ber_layers) {
/*
 * All BER values are read. We can now calculate the total BER
 * And ask for another BER measure
@@ -812,12 +844,6 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe)
c-bit_count.stat[0].scale = FE_SCALE_COUNTER;
c-bit_count.stat[0].uvalue += t_bit_count;
 
-   /* Reset counters to collect new data */
-   rc = mb86a20s_writeregdata(state, mb86a20s_vber_reset);
-   if (rc  0)
-   dev_err(state-i2c-dev,
-   %s: Can't reset VBER registers.\n, __func__);
-
/* All BER measures need to be collected when ready */
for (i = 0; i  3; i++)
state-read_ber[i] = true;
-- 
1.7.11.7

--
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 RFCv10 08/15] mb86a20s: fix interleaving and FEC retrival

2013-01-14 Thread Mauro Carvalho Chehab
Get the proper bits from the TMCC table registers.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index e069c9b..d14824a 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -360,7 +360,7 @@ static int mb86a20s_get_modulation(struct mb86a20s_state 
*state,
rc = mb86a20s_readreg(state, 0x6e);
if (rc  0)
return rc;
-   switch ((rc  0x70)  4) {
+   switch ((rc  4)  0x07) {
case 0:
return DQPSK;
case 1:
@@ -393,7 +393,7 @@ static int mb86a20s_get_fec(struct mb86a20s_state *state,
rc = mb86a20s_readreg(state, 0x6e);
if (rc  0)
return rc;
-   switch (rc) {
+   switch ((rc  4)  0x07) {
case 0:
return FEC_1_2;
case 1:
@@ -428,9 +428,7 @@ static int mb86a20s_get_interleaving(struct mb86a20s_state 
*state,
rc = mb86a20s_readreg(state, 0x6e);
if (rc  0)
return rc;
-   if (rc  3)
-   return -EINVAL; /* Not used */
-   return rc;
+   return (rc  4)  0x07;
 }
 
 static int mb86a20s_get_segment_count(struct mb86a20s_state *state,
-- 
1.7.11.7

--
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 RFCv10 15/15] mb86a20s: global stat is just a sum, and not an increment

2013-01-14 Thread Mauro Carvalho Chehab
As global BER stat is already summing both BER counters, it should
not be incremented with its previous value.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index 2f3e4b3..8fee4b3 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -994,9 +994,9 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe)
 * bit errors on all active layers.
 */
c-bit_error.stat[0].scale = FE_SCALE_COUNTER;
-   c-bit_error.stat[0].uvalue += t_bit_error;
+   c-bit_error.stat[0].uvalue = t_bit_error;
c-bit_count.stat[0].scale = FE_SCALE_COUNTER;
-   c-bit_count.stat[0].uvalue += t_bit_count;
+   c-bit_count.stat[0].uvalue = t_bit_count;
 
/* All BER measures need to be collected when ready */
for (i = 0; i  3; i++)
-- 
1.7.11.7

--
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 RFCv10 02/15] dvb: Add DVBv5 stats properties for Quality of Service

2013-01-14 Thread Mauro Carvalho Chehab
The DVBv3 quality parameters are limited on several ways:

- Doesn't provide any way to indicate the used measure,
  so userspace need to guess how to calculate the measure;

- Only a limited set of stats are supported;

- Can't be called in a way to require them to be filled
  all at once (atomic reads from the hardware), with may
  cause troubles on interpreting them on userspace;

- On some OFDM delivery systems, the carriers can be
  independently modulated, having different properties.
  Currently, there's no way to report per-layer stats.

To address the above issues, adding a new DVBv5-based stats
API.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com

---

v6: Add DocBook documentation.
v7: Some fixes as suggested by Antti
v8: Documentation fix, compilation fix and name the stats struct,
for its reusage inside the core
v9: counters need 32 bits. So, change the return data types to
s32/u32 types
v10: Counters changed to 64 bits for monotonic increment
---
 Documentation/DocBook/media/dvb/dvbproperty.xml | 115 +++-
 include/uapi/linux/dvb/frontend.h   |  83 -
 2 files changed, 195 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/media/dvb/dvbproperty.xml 
b/Documentation/DocBook/media/dvb/dvbproperty.xml
index 957e3ac..b46a3d8 100644
--- a/Documentation/DocBook/media/dvb/dvbproperty.xml
+++ b/Documentation/DocBook/media/dvb/dvbproperty.xml
@@ -7,16 +7,46 @@ the capability ioctls weren't implemented yet via the new 
way./para
 paraThe typical usage for the 
constantFE_GET_PROPERTY/FE_SET_PROPERTY/constant
 API is to replace the ioctl's were the link linkend=dvb-frontend-parameters
 struct constantdvb_frontend_parameters/constant/link were used./para
+section id=dtv-stats
+titleDTV stats type/title
+programlisting
+struct dtv_stats {
+   __u8 scale; /* enum fecap_scale_params type */
+   union {
+   __u64 uvalue;   /* for counters and relative scales */
+   __s64 svalue;   /* for 0.1 dB measures */
+   };
+} __attribute__ ((packed));
+/programlisting
+/section
+section id=dtv-fe-stats
+titleDTV stats type/title
+programlisting
+#define MAX_QOS_STATS   4
+
+struct dtv_fe_stats {
+   __u8 len;
+   struct dtv_stats stat[MAX_QOS_STATS];
+} __attribute__ ((packed));
+/programlisting
+/section
+
 section id=dtv-property
 titleDTV property type/title
 programlisting
 /* Reserved fields should be set to 0 */
+
 struct dtv_property {
__u32 cmd;
+   __u32 reserved[3];
union {
__u32 data;
+   struct dtv_fe_stats st;
struct {
-   __u8 data[32];
+   union {
+   __u8 data[32];
+   __u16 data16[16];
+   };
__u32 len;
__u32 reserved1[3];
void *reserved2;
@@ -850,6 +880,79 @@ enum fe_interleaving {
parause the special macro LNA_AUTO to set LNA auto/para
/section
 /section
+
+   section id=frontend-qos-properties
+   titleFrontend Quality of Service/Statistics indicators/title
+   paraExcept for link 
linkend=DTV-QOS-ENUMconstantDTV_QOS_ENUM/constant/link,
+   the values are returned via 
constantdtv_property.stat/constant./para
+   paraFor most delivery systems, this will return a single value for 
each parameter./para
+   paraIt should be noticed, however, that new OFDM delivery systems
+   like ISDB can use different modulation types for each group of carriers.
+   On such standards, up to 3 groups of statistics can be provided, one
+   for each carrier group (called layer on ISDB).
+   In order to be consistent with other delivery systems, the first
+   value at link 
linkend=dtv-statsconstantdtv_property.stat.dtv_stats/constant/link 
array refers to
+   a global indicator, if any. The other elements of the array represent
+   each layer, starting from layer A(index 1), layer B (index 2) and so 
on/para
+   paraThe number of filled elements are stored at 
constantdtv_property.stat.len/constant./para
+   paraEach element of the 
constantdtv_property.stat.dtv_stats/constant array consists on two 
elements:/para
+   itemizedlist mark='opencircle'
+   listitemparaconstantvalue/constant - Value of the 
measure/para/listitem
+   listitemparaconstantscale/constant - Scale for the 
value. It can be:/para
+   section id = fecap-scale-params
+   itemizedlist mark='bullet'
+   
listitemparaconstantFE_SCALE_NOT_AVAILABLE/constant - If it is not 
possible to collect a given parameter (could be a transitory or permanent 
condition)/para/listitem
+   

[PATCH RFCv10 10/15] mb86a20s: -EBUSY is expected when getting QoS measures

2013-01-14 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index e73f66d..c4bf428 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -964,12 +964,13 @@ static int mb86a20s_read_status_and_stats(struct 
dvb_frontend *fe,
 
/* Get QoS statistics */
rc = mb86a20s_get_stats(fe);
-   if (rc  0) {
+   if (rc  0  rc != -EBUSY) {
dev_err(state-i2c-dev,
%s: Can't get FE QoS statistics.\n, __func__);
rc = 0;
goto error;
}
+   rc = 0; /* Don't return EBUSY to userspace */
}
goto ok;
 
-- 
1.7.11.7

--
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 RFCv10 09/15] mb86a20s: convert it to use dev_info/dev_err/dev_dbg

2013-01-14 Thread Mauro Carvalho Chehab
Also add some additional debug and error messages when needed.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 156 +++--
 1 file changed, 111 insertions(+), 45 deletions(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index d14824a..e73f66d 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -24,18 +24,6 @@ static int debug = 1;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, Activates frontend debugging (default:0));
 
-#define rc(args...)  do {  \
-   printk(KERN_ERR  mb86a20s:  args);\
-} while (0)
-
-#define dprintk(args...)   \
-   do {\
-   if (debug) {\
-   printk(KERN_DEBUG mb86a20s: %s: , __func__);  \
-   printk(args);   \
-   }   \
-   } while (0)
-
 struct mb86a20s_state {
struct i2c_adapter *i2c;
const struct mb86a20s_config *config;
@@ -209,8 +197,9 @@ static int mb86a20s_i2c_writereg(struct mb86a20s_state 
*state,
 
rc = i2c_transfer(state-i2c, msg, 1);
if (rc != 1) {
-   printk(%s: writereg error (rc == %i, reg == 0x%02x,
- data == 0x%02x)\n, __func__, rc, reg, data);
+   dev_err(state-i2c-dev,
+   %s: writereg error (rc == %i, reg == 0x%02x, data == 
0x%02x)\n,
+   __func__, rc, reg, data);
return rc;
}
 
@@ -244,7 +233,8 @@ static int mb86a20s_i2c_readreg(struct mb86a20s_state 
*state,
rc = i2c_transfer(state-i2c, msg, 2);
 
if (rc != 2) {
-   rc(%s: reg=0x%x (error=%d)\n, __func__, reg, rc);
+   dev_err(state-i2c-dev, %s: reg=0x%x (error=%d)\n,
+   __func__, reg, rc);
return (rc  0) ? rc : -EIO;
}
 
@@ -270,7 +260,6 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
struct mb86a20s_state *state = fe-demodulator_priv;
int val;
 
-   dprintk(\n);
*status = 0;
 
val = mb86a20s_readreg(state, 0x0a)  0xf;
@@ -292,7 +281,8 @@ static int mb86a20s_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
if (val = 8)   /* Maybe 9? */
*status |= FE_HAS_LOCK;
 
-   dprintk(val = %d, status = 0x%02x\n, val, *status);
+   dev_dbg(state-i2c-dev, %s: Status = 0x%02x (state = %d)\n,
+__func__, *status, val);
 
return 0;
 }
@@ -333,8 +323,9 @@ static int mb86a20s_read_signal_strength(struct 
dvb_frontend *fe)
 
/* Rescale it from 2^12 (4096) to 2^16 */
rf = (16 - 12);
-   dprintk(signal strength = %d (%d  RF=%d  %d)\n, rf,
-   rf_min, rf, rf_max);
+   dev_dbg(state-i2c-dev,
+   %s: signal strength = %d (%d  RF=%d  %d)\n,
+   __func__, rf, rf_min, rf  4, rf_max);
return (rf);
}
} while (1);
@@ -435,15 +426,17 @@ static int mb86a20s_get_segment_count(struct 
mb86a20s_state *state,
  unsigned layer)
 {
int rc, count;
-
static unsigned char reg[] = {
[0] = 0x89, /* Layer A */
[1] = 0x8d, /* Layer B */
[2] = 0x91, /* Layer C */
};
 
+   dev_dbg(state-i2c-dev, %s called.\n, __func__);
+
if (layer = ARRAY_SIZE(reg))
return -EINVAL;
+
rc = mb86a20s_writereg(state, 0x6d, reg[layer]);
if (rc  0)
return rc;
@@ -452,13 +445,18 @@ static int mb86a20s_get_segment_count(struct 
mb86a20s_state *state,
return rc;
count = (rc  4)  0x0f;
 
+   dev_dbg(state-i2c-dev, %s: segments: %d.\n, __func__, count);
+
return count;
 }
 
 static void mb86a20s_reset_frontend_cache(struct dvb_frontend *fe)
 {
+   struct mb86a20s_state *state = fe-demodulator_priv;
struct dtv_frontend_properties *c = fe-dtv_property_cache;
 
+   dev_dbg(state-i2c-dev, %s called.\n, __func__);
+
/* Fixed parameters */
c-delivery_system = SYS_ISDBT;
c-bandwidth_hz = 600;
@@ -477,6 +475,8 @@ static int mb86a20s_get_frontend(struct dvb_frontend *fe)
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int i, rc;
 
+   dev_dbg(state-i2c-dev, %s called.\n, __func__);
+
/* Reset frontend cache to default values */

[PATCH RFCv10 01/15] mb86a20s: improve error handling at get_frontend

2013-01-14 Thread Mauro Carvalho Chehab
The read/write errors are not handled well on get_frontend. Fix it,
by letting the frontend cached values to represent the DVB properties
that were successfully retrieved.

While here, use c for dtv_frontend_properties cache, instead of
p, as this is more common.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 138 +++--
 1 file changed, 80 insertions(+), 58 deletions(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index fade566..4ff3a0c 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -1,11 +1,9 @@
 /*
  *   Fujitu mb86a20s ISDB-T/ISDB-Tsb Module driver
  *
- *   Copyright (C) 2010 Mauro Carvalho Chehab mche...@redhat.com
+ *   Copyright (C) 2010-2013 Mauro Carvalho Chehab mche...@redhat.com
  *   Copyright (C) 2009-2010 Douglas Landgraf dougsl...@redhat.com
  *
- *   FIXME: Need to port to DVB v5.2 API
- *
  *   This program is free software; you can redistribute it and/or
  *   modify it under the terms of the GNU General Public License as
  *   published by the Free Software Foundation version 2.
@@ -360,7 +358,7 @@ static int mb86a20s_set_frontend(struct dvb_frontend *fe)
/*
 * FIXME: Properly implement the set frontend properties
 */
-   struct dtv_frontend_properties *p = fe-dtv_property_cache;
+   struct dtv_frontend_properties *c = fe-dtv_property_cache;
 #endif
 
dprintk(\n);
@@ -507,93 +505,117 @@ static int mb86a20s_get_segment_count(struct 
mb86a20s_state *state,
return count;
 }
 
+static void mb86a20s_reset_frontend_cache(struct dvb_frontend *fe)
+{
+   struct dtv_frontend_properties *c = fe-dtv_property_cache;
+
+   /* Fixed parameters */
+   c-delivery_system = SYS_ISDBT;
+   c-bandwidth_hz = 600;
+
+   /* Initialize values that will be later autodetected */
+   c-isdbt_layer_enabled = 0;
+   c-transmission_mode = TRANSMISSION_MODE_AUTO;
+   c-guard_interval = GUARD_INTERVAL_AUTO;
+   c-isdbt_sb_mode = 0;
+   c-isdbt_sb_segment_count = 0;
+}
+
 static int mb86a20s_get_frontend(struct dvb_frontend *fe)
 {
struct mb86a20s_state *state = fe-demodulator_priv;
-   struct dtv_frontend_properties *p = fe-dtv_property_cache;
+   struct dtv_frontend_properties *c = fe-dtv_property_cache;
int i, rc;
 
-   /* Fixed parameters */
-   p-delivery_system = SYS_ISDBT;
-   p-bandwidth_hz = 600;
+   /* Reset frontend cache to default values */
+   mb86a20s_reset_frontend_cache(fe);
 
if (fe-ops.i2c_gate_ctrl)
fe-ops.i2c_gate_ctrl(fe, 0);
 
/* Check for partial reception */
rc = mb86a20s_writereg(state, 0x6d, 0x85);
-   if (rc = 0)
-   rc = mb86a20s_readreg(state, 0x6e);
-   if (rc = 0)
-   p-isdbt_partial_reception = (rc  0x10) ? 1 : 0;
+   if (rc  0)
+   return rc;
+   rc = mb86a20s_readreg(state, 0x6e);
+   if (rc  0)
+   return rc;
+   c-isdbt_partial_reception = (rc  0x10) ? 1 : 0;
 
/* Get per-layer data */
-   p-isdbt_layer_enabled = 0;
+
for (i = 0; i  3; i++) {
rc = mb86a20s_get_segment_count(state, i);
-   if (rc = 0  rc  14)
-   p-layer[i].segment_count = rc;
-   if (rc == 0x0f)
+   if (rc  0)
+   goto error;
+   if (rc = 0  rc  14)
+   c-layer[i].segment_count = rc;
+   else {
+   c-layer[i].segment_count = 0;
continue;
-   p-isdbt_layer_enabled |= 1  i;
+   }
+   c-isdbt_layer_enabled |= 1  i;
rc = mb86a20s_get_modulation(state, i);
-   if (rc = 0)
-   p-layer[i].modulation = rc;
+   if (rc  0)
+   goto error;
+   c-layer[i].modulation = rc;
rc = mb86a20s_get_fec(state, i);
-   if (rc = 0)
-   p-layer[i].fec = rc;
+   if (rc  0)
+   goto error;
+   c-layer[i].fec = rc;
rc = mb86a20s_get_interleaving(state, i);
-   if (rc = 0)
-   p-layer[i].interleaving = rc;
+   if (rc  0)
+   goto error;
+   c-layer[i].interleaving = rc;
}
 
-   p-isdbt_sb_mode = 0;
rc = mb86a20s_writereg(state, 0x6d, 0x84);
-   if ((rc = 0)  ((rc  0x60) == 0x20)) {
-   p-isdbt_sb_mode = 1;
+   if (rc  0)
+   return rc;
+   if ((rc  0x60) == 0x20) {
+   c-isdbt_sb_mode = 1;
/* At least, one segment should exist */
-   if 

[PATCH RFCv10 05/15] mb86a20s: functions reorder

2013-01-14 Thread Mauro Carvalho Chehab
No functional changes here. Just re-organizes the functions
inside the file.

Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 217 +
 1 file changed, 115 insertions(+), 102 deletions(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index 0f8d9bc..c91e9b9 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -194,6 +194,10 @@ static struct regdata mb86a20s_clear_stats[] = {
{ 0x51, 0x01 },
 };
 
+/*
+ * I2C read/write functions and macros
+ */
+
 static int mb86a20s_i2c_writereg(struct mb86a20s_state *state,
 u8 i2c_addr, int reg, int data)
 {
@@ -255,45 +259,42 @@ static int mb86a20s_i2c_readreg(struct mb86a20s_state 
*state,
mb86a20s_i2c_writeregdata(state, state-config-demod_address, \
regdata, ARRAY_SIZE(regdata))
 
-static int mb86a20s_initfe(struct dvb_frontend *fe)
+/*
+ * Ancillary internal routines (likely compiled inlined)
+ *
+ * The functions below assume that gateway lock has already obtained
+ */
+
+static int mb86a20s_read_status(struct dvb_frontend *fe, fe_status_t *status)
 {
struct mb86a20s_state *state = fe-demodulator_priv;
-   int rc;
-   u8  regD5 = 1;
+   int val;
 
dprintk(\n);
+   *status = 0;
 
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
+   val = mb86a20s_readreg(state, 0x0a)  0xf;
+   if (val  0)
+   return val;
 
-   /* Initialize the frontend */
-   rc = mb86a20s_writeregdata(state, mb86a20s_init);
-   if (rc  0)
-   goto err;
+   if (val = 2)
+   *status |= FE_HAS_SIGNAL;
 
-   if (!state-config-is_serial) {
-   regD5 = ~1;
+   if (val = 4)
+   *status |= FE_HAS_CARRIER;
 
-   rc = mb86a20s_writereg(state, 0x50, 0xd5);
-   if (rc  0)
-   goto err;
-   rc = mb86a20s_writereg(state, 0x51, regD5);
-   if (rc  0)
-   goto err;
-   }
+   if (val = 5)
+   *status |= FE_HAS_VITERBI;
 
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 1);
+   if (val = 7)
+   *status |= FE_HAS_SYNC;
 
-err:
-   if (rc  0) {
-   state-need_init = true;
-   printk(KERN_INFO mb86a20s: Init failed. Will try again 
later\n);
-   } else {
-   state-need_init = false;
-   dprintk(Initialization succeeded.\n);
-   }
-   return rc;
+   if (val = 8)   /* Maybe 9? */
+   *status |= FE_HAS_LOCK;
+
+   dprintk(val = %d, status = 0x%02x\n, val, *status);
+
+   return 0;
 }
 
 static int mb86a20s_read_signal_strength(struct dvb_frontend *fe)
@@ -340,78 +341,6 @@ static int mb86a20s_read_signal_strength(struct 
dvb_frontend *fe)
return 0;
 }
 
-static int mb86a20s_read_status(struct dvb_frontend *fe, fe_status_t *status)
-{
-   struct mb86a20s_state *state = fe-demodulator_priv;
-   int val;
-
-   dprintk(\n);
-   *status = 0;
-
-   val = mb86a20s_readreg(state, 0x0a)  0xf;
-   if (val  0)
-   return val;
-
-   if (val = 2)
-   *status |= FE_HAS_SIGNAL;
-
-   if (val = 4)
-   *status |= FE_HAS_CARRIER;
-
-   if (val = 5)
-   *status |= FE_HAS_VITERBI;
-
-   if (val = 7)
-   *status |= FE_HAS_SYNC;
-
-   if (val = 8)   /* Maybe 9? */
-   *status |= FE_HAS_LOCK;
-
-   dprintk(val = %d, status = 0x%02x\n, val, *status);
-
-   return 0;
-}
-
-static int mb86a20s_set_frontend(struct dvb_frontend *fe)
-{
-   struct mb86a20s_state *state = fe-demodulator_priv;
-   int rc;
-#if 0
-   /*
-* FIXME: Properly implement the set frontend properties
-*/
-   struct dtv_frontend_properties *c = fe-dtv_property_cache;
-#endif
-
-   dprintk(\n);
-
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 1);
-   dprintk(Calling tuner set parameters\n);
-   fe-ops.tuner_ops.set_params(fe);
-
-   /*
-* Make it more reliable: if, for some reason, the initial
-* device initialization doesn't happen, initialize it when
-* a SBTVD parameters are adjusted.
-*
-* Unfortunately, due to a hard to track bug at tda829x/tda18271,
-* the agc callback logic is not called during DVB attach time,
-* causing mb86a20s to not be initialized with Kworld SBTVD.
-* So, this hack is needed, in order to make Kworld SBTVD to work.
-*/
-   if (state-need_init)
-   mb86a20s_initfe(fe);
-
-   if (fe-ops.i2c_gate_ctrl)
-   fe-ops.i2c_gate_ctrl(fe, 0);
-   rc = mb86a20s_writeregdata(state, 

[PATCH RFCv10 07/15] mb86a20s: improve debug for RF level

2013-01-14 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com
---
 drivers/media/dvb-frontends/mb86a20s.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/mb86a20s.c 
b/drivers/media/dvb-frontends/mb86a20s.c
index 06e5d35..e069c9b 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -333,7 +333,8 @@ static int mb86a20s_read_signal_strength(struct 
dvb_frontend *fe)
 
/* Rescale it from 2^12 (4096) to 2^16 */
rf = (16 - 12);
-   dprintk(signal strength = %d\n, rf);
+   dprintk(signal strength = %d (%d  RF=%d  %d)\n, rf,
+   rf_min, rf, rf_max);
return (rf);
}
} while (1);
-- 
1.7.11.7

--
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: tvp514x: remove field description

2013-01-14 Thread Lad, Prabhakar
This patch removes the field description of fields that no
longer exists, along side aligns the field description of
fields.

Signed-off-by: Lad, Prabhakar prabhakar@ti.com
---
 include/media/tvp514x.h |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/include/media/tvp514x.h b/include/media/tvp514x.h
index 74387e8..86ed7e8 100644
--- a/include/media/tvp514x.h
+++ b/include/media/tvp514x.h
@@ -96,12 +96,9 @@ enum tvp514x_output {
 
 /**
  * struct tvp514x_platform_data - Platform data values and access functions.
- * @power_set: Power state access function, zero is off, non-zero is on.
- * @ifparm: Interface parameters access function.
- * @priv_data_set: Device private data (pointer) access function.
  * @clk_polarity: Clock polarity of the current interface.
- * @ hs_polarity: HSYNC Polarity configuration for current interface.
- * @ vs_polarity: VSYNC Polarity configuration for current interface.
+ * @hs_polarity: HSYNC Polarity configuration for current interface.
+ * @vs_polarity: VSYNC Polarity configuration for current interface.
  */
 struct tvp514x_platform_data {
/* Interface control params */
-- 
1.7.4.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