[PATCH for 3.19] vivid: fix CROP_BOUNDS typo for video output

2014-12-06 Thread Hans Verkuil
An error was returned if composing was not supported, instead of if
cropping was not supported.

A classic copy-and-paste bug. Found with v4l2-compliance.

Signed-off-by: Hans Verkuil 
Cc:   # for v3.18
---
 drivers/media/platform/vivid/vivid-vid-out.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/vivid/vivid-vid-out.c 
b/drivers/media/platform/vivid/vivid-vid-out.c
index ee5c399..39ff79f 100644
--- a/drivers/media/platform/vivid/vivid-vid-out.c
+++ b/drivers/media/platform/vivid/vivid-vid-out.c
@@ -625,7 +625,7 @@ int vivid_vid_out_g_selection(struct file *file, void *priv,
sel->r = dev->fmt_out_rect;
break;
case V4L2_SEL_TGT_CROP_BOUNDS:
-   if (!dev->has_compose_out)
+   if (!dev->has_crop_out)
return -EINVAL;
sel->r = vivid_max_rect;
break;
-- 
2.1.3

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


Re: [REVIEW PATCH 1/2] v4l: Add data_offset to struct v4l2_buffer

2014-12-06 Thread Sakari Ailus
Hi Hans,

On Fri, Dec 05, 2014 at 04:10:05PM +0100, Hans Verkuil wrote:
> On 12/03/2014 12:14 PM, Sakari Ailus wrote:
> > From: Sakari Ailus 
> > 
> > The data_offset field tells the start of the image data from the beginning
> > of the buffer. The bsize field 
> 
> bsize field? There is no bsize field in v4l2_buffer, so I'm confused.

This is a brain'o. It should have been "bytesused". I'll fix that to the
next version.

> > in struct v4l2_buffer includes this, but the
> > sizeimage field in struct v4l2_pix_format does not.
> > 
> > Signed-off-by: Sakari Ailus 
> > ---
> >  Documentation/DocBook/media/v4l/compat.xml  | 11 +++
> >  Documentation/DocBook/media/v4l/io.xml  | 18 +++---
> >  Documentation/DocBook/media/v4l/vidioc-qbuf.xml |  3 +--
> >  drivers/media/usb/cpia2/cpia2_v4l.c |  2 +-
> >  drivers/media/v4l2-core/v4l2-compat-ioctl32.c   |  4 ++--
> >  drivers/media/v4l2-core/videobuf2-core.c| 17 -
> >  include/uapi/linux/videodev2.h  |  4 +++-
> >  7 files changed, 45 insertions(+), 14 deletions(-)
> > 
> > diff --git a/Documentation/DocBook/media/v4l/compat.xml 
> > b/Documentation/DocBook/media/v4l/compat.xml
> > index 0a2debf..ad54e72 100644
> > --- a/Documentation/DocBook/media/v4l/compat.xml
> > +++ b/Documentation/DocBook/media/v4l/compat.xml
> > @@ -2579,6 +2579,17 @@ fields changed from _s32 to _u32.
> >
> >  
> >  
> > +
> > +  V4L2 in Linux 3.20
> > +  
> > +   
> > + Replaced reserved2 by
> > + data_offset in struct
> > + v4l2_buffer.
> > +   
> > +  
> > +
> > +
> >  
> >Relation of V4L2 to other Linux multimedia APIs
> >  
> > diff --git a/Documentation/DocBook/media/v4l/io.xml 
> > b/Documentation/DocBook/media/v4l/io.xml
> > index 1c17f80..13baeac 100644
> > --- a/Documentation/DocBook/media/v4l/io.xml
> > +++ b/Documentation/DocBook/media/v4l/io.xml
> > @@ -839,10 +839,22 @@ is the file descriptor associated with a DMABUF 
> > buffer.
> >   
> >   
> > __u32
> > -   reserved2
> > +   data_offset
> > 
> > -   A place holder for future extensions. Applications
> > -should set this to 0.
> > +   
> > + Start of the image data from the beginning of the buffer in
> > + bytes. Applications must set this for both
> 
> Drop 'both'.

Fixed.

> > + V4L2_BUF_TYPE_VIDEO_OUTPUT buffers
> > + whereas driver must set this for
> > + V4L2_BUF_TYPE_VIDEO_CAPTURE buffers
> > + before &VIDIOC-PREPARE-BUF; and &VIDIOC-QBUF; IOCTLs. Note
> 
> s/IOCTLs/ioctls/

Fixed.

> > + that data_offset is included in
> > + bytesused. So the size of the image
> > + in the plane is bytesused-
> > + data_offset at offset
> > + data_offset from the start of the
> > + plane.
> > +   
> >   
> >   
> > __u32
> > diff --git a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml 
> > b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
> > index 3504a7f..f529e4d 100644
> > --- a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
> > +++ b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
> > @@ -72,8 +72,7 @@ initialize the bytesused,
> >  timestamp fields, see  >  linkend="buffer" /> for details.
> >  Applications must also set flags to 0.
> > -The reserved2 and
> > -reserved fields must be set to 0. When using
> > +The reserved field must be set to 0. When using
> >  the multi-planar API, the
> >  m.planes field must contain a userspace pointer
> >  to a filled-in array of &v4l2-plane; and the 
> > length
> > diff --git a/drivers/media/usb/cpia2/cpia2_v4l.c 
> > b/drivers/media/usb/cpia2/cpia2_v4l.c
> > index 9caea83..a94e83a 100644
> > --- a/drivers/media/usb/cpia2/cpia2_v4l.c
> > +++ b/drivers/media/usb/cpia2/cpia2_v4l.c
> > @@ -952,7 +952,7 @@ static int cpia2_dqbuf(struct file *file, void *fh, 
> > struct v4l2_buffer *buf)
> > buf->sequence = cam->buffers[buf->index].seq;
> > buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer;
> > buf->length = cam->frame_size;
> > -   buf->reserved2 = 0;
> > +   buf->data_offset = 0;
> > buf->reserved = 0;
> > memset(&buf->timecode, 0, sizeof(buf->timecode));
> >  
> > diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 
> > b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> > index af63543..e238066 100644
> > --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> > +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
> > @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
> > __s32   fd;
> > } m;
> > __u32   length;
> > -   __u32   reserved2;
> > +   __u32   data_offset;
> > __u32   reserved;
> >  };
> >  
> > @@ -491,7 +491,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, 
> > struct v4l2_buffer32 __user
> > put_user(kp->timestamp.tv_usec, &up->timestamp.tv_use

Re: [REVIEW PATCH 2/2] v4l: Add packed Bayer raw10 pixel formats

2014-12-06 Thread Sakari Ailus
Hi Hans,

Thank you for the review.

On Fri, Dec 05, 2014 at 04:12:31PM +0100, Hans Verkuil wrote:
> On 12/03/2014 12:14 PM, Sakari Ailus wrote:
> > From: Aviv Greenberg 
> > 
> > These formats are just like 10-bit raw bayer formats that exist already, but
> > the pixels are not padded to byte boundaries. Instead, the eight high order
> > bits of four consecutive pixels are stored in four bytes, followed by a byte
> > of two low order bits of each of the four pixels.
> > 
> > Signed-off-by: Aviv Greenberg 
> > Signed-off-by: Sakari Ailus 
> > ---
> >  .../DocBook/media/v4l/pixfmt-srggb10p.xml  | 83 
> > ++
> >  Documentation/DocBook/media/v4l/pixfmt.xml |  1 +
> >  include/uapi/linux/videodev2.h |  5 ++
> >  3 files changed, 89 insertions(+)
> >  create mode 100644 Documentation/DocBook/media/v4l/pixfmt-srggb10p.xml
> > 
> > diff --git a/Documentation/DocBook/media/v4l/pixfmt-srggb10p.xml 
> > b/Documentation/DocBook/media/v4l/pixfmt-srggb10p.xml
> > new file mode 100644
> > index 000..3e88d8d
> > --- /dev/null
> > +++ b/Documentation/DocBook/media/v4l/pixfmt-srggb10p.xml
> > @@ -0,0 +1,83 @@
> > +
> > +  
> > +   V4L2_PIX_FMT_SRGGB10P ('pRAA'),
> > +V4L2_PIX_FMT_SGRBG10P ('pgAA'),
> > +V4L2_PIX_FMT_SGBRG10P ('pGAA'),
> > +V4L2_PIX_FMT_SBGGR10P ('pBAA'),
> > +
> > +   &manvol;
> > +  
> > +  
> > +> id="V4L2-PIX-FMT-SRGGB10P">V4L2_PIX_FMT_SRGGB10P
> > +> id="V4L2-PIX-FMT-SGRBG10P">V4L2_PIX_FMT_SGRBG10P
> > +> id="V4L2-PIX-FMT-SGBRG10P">V4L2_PIX_FMT_SGBRG10P
> > +> id="V4L2-PIX-FMT-SBGGR10P">V4L2_PIX_FMT_SBGGR10P
> > +   10-bit packed Bayer formats
> > +  
> > +  
> > +   Description
> > +
> > +   The following four pixel formats are packed raw sRGB /
> > +   Bayer formats with 10 bits per colour. Every four consequtive
> 
> Typo: consecutive
> 
> > +   colour components are packed into 5 bytes such that each of
> > +   the first 4 bytes contain their 8 high bits, and the fifth
> > +   byte contains 4 groups of 2 their low bits. Bytes are stored
> > +   in memory in little endian order.
> > +
> > +   Each n-pixel row contains n/2 green samples and n/2 blue
> > +   or red samples, with alternating green-red and green-blue
> > +   rows. They are conventionally described as GRGR... BGBG...,
> > +   RGRG... GBGB..., etc. Below is an example of one of these
> > +   formats
> 
> s/formats/formats:/

Will fix the two.

> > +
> > +
> > +  V4L2_PIX_FMT_SBGGR10P 4 × 4
> > +  pixel image
> > +
> > +  
> > +   Byte Order.
> > +   Each cell is one byte.
> > + 
> > +   
> > + 
> > + 
> > +   
> > + start + 0:
> > + B00high
> > + G01high
> > + B02high
> > + G03high
> > + B+G0-3low
> > +   
> > +   
> > + start + 5:
> > + G04high
> > + R05high
> > + G06high
> > + R07high
> > + G+R4-7low
> > +   
> > +   
> > + start + 10:
> > + B08high
> > + G09high
> > + B10high
> > + G11high
> > + B+G8-11low
> > +   
> > +   
> > +  start + 15:
> > + G12high
> > + R13high
> > + G14high
> > + R15high
> > + G+R12-15low
> > +   
> > + 
> > +   
> > + 
> > +   
> > +  
> > +
> > +  
> > +
> > diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml 
> > b/Documentation/DocBook/media/v4l/pixfmt.xml
> > index df5b23d..5a83d9c 100644
> > --- a/Documentation/DocBook/media/v4l/pixfmt.xml
> > +++ b/Documentation/DocBook/media/v4l/pixfmt.xml
> > @@ -716,6 +716,7 @@ access the palette, this must be done with ioctls of 
> > the Linux framebuffer API.<
> >  &sub-srggb10alaw8;
> >  &sub-srggb10dpcm8;
> >  &sub-srggb12;
> > +&sub-srggb10p;

I'll bump this up as well.

> >
> >  
> >
> > diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> > index e9806c6..faba23a 100644
> > --- a/include/uapi/linux/videodev2.h
> > +++ b/include/uapi/linux/videodev2.h
> > @@ -402,6 +402,11 @@ struct v4l2_pix_format {
> >  #define V4L2_PIX_FMT_SGBRG10DPCM8 v4l2_fourcc('b', 'G', 'A', '8')
> >  #define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
> >  #define V4L2_PIX_FMT_SRGGB10DPCM8 v4l2_fourcc('b', 'R', 'A', '8')
> > +   /* 10bit raw bayer packed, 5 bytes for every 4 pixels */
> > +#define V4L2_PIX_FMT_SBGGR10P v4l2_fourcc('p', 'B', 'A', 'A')
> > +#define V4L2_PIX_FMT_SGBRG10P v4l2_fourcc('p', 'G', 'A', 'A')
> > +#define V4L2_PIX_FMT_SGRBG10P v4l2_fourcc('p', 'g', 'A', 'A')
> > +#define V4L2_PIX_FMT_SRGGB10P v4l2_fourcc('p', 'R', 'A', 'A')
> > /*
> >  * 10bit raw bayer, expanded to 16 bits
> >  * rrgg ggbb...
> > 
> 
> After fixing th

Re: [REVIEW PATCH 1/2] v4l: Add data_offset to struct v4l2_buffer

2014-12-06 Thread Hans Verkuil
On 12/06/2014 12:48 PM, Sakari Ailus wrote:
> Hi Hans,
> 
> On Fri, Dec 05, 2014 at 04:10:05PM +0100, Hans Verkuil wrote:
>> On 12/03/2014 12:14 PM, Sakari Ailus wrote:
>>> From: Sakari Ailus 



>> I think we need to add new helper functions that give back the real plane 
>> size
>> (i.e. bytesused - data_offset) and the actual plane start position (plane 
>> start
>> + data_offset). It will be a bit tricky though to check existing drivers.
> 
> I think this mostly applies to OUTPUT buffers.
> 
> I find the definition for multi-plane buffers a little bit odd --- why not
> allow setting this for CAPTURE buffers as well, on hardware that supports
> it? This makes sense, in order to use the buffers on other interfaces
> without memory copies this may be even mandatory.

It's meant for drivers that have a header before the actual image (e.g. sensor
metadata passed on before the image). Userspace has no control over that, so
that's why it is set by the driver at capture time.

> 
> I wonder if we should change the spec regarding this, even if no driver
> support was added yet.

I don't think so. There is a good and clear reason for this.

> 
>> AFAICT vivid is one driver that uses vb2_plane_size() to check if enough 
>> space
>> is available for the image, but that doesn't take the data_offset into 
>> account.
>>
>> I suspect that similar problems occur for output drivers. And what isn't 
>> properly
>> defined at the moment is what should happen if an output driver doesn't 
>> support
>> a particular data_offset value.
>>
>> I think the only thing you can do in that case is to return an error when 
>> QBUF
>> is called.
> 
> I'd think so. Same for PREPARE_BUF.
> 
> I suppose very few drivers support this at the moment, and the ones that
> don't would return -EINVAL on QBUF. This could reveal broken user space
> applications. An alternative would be to silently assign a valid value to
> the field, but I'm not sure if that's any better.

I wouldn't do that. In my opinion it is a clear error.

Regards,

Hans

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


Re: [PATCH/RFC v8 02/14] Documentation: leds: Add description of LED Flash class extension

2014-12-06 Thread Pavel Machek

> > The format of a sysfs attribute should be concise.
> > The error codes are generic and map directly to the V4L2 Flash
> > error codes.
> >
> 
> Actually I'd like to see those flash fault code defined in LED
> subsystem. And V4L2 will just include LED flash header file to use it.
> Because flash fault code is not for V4L2 specific but it's a feature
> of LED flash devices.
> 
> For clearing error code of flash devices, I think it depends on the
> hardware. If most of our LED flash is using reading to clear error
> code, we probably can make it simple as this now. But what if some
> other LED flash devices are using writing to clear error code? we
> should provide a API to that?

Actually, we should provide API that makes sense, and that is easy to
use by userspace.

I believe "read" is called read because it does not change anything,
and it should stay that way in /sysfs. You may want to talk to sysfs
maintainers if you plan on doing another semantics.
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors

2014-12-06 Thread Antti Palosaari

Moikka!
I am very surprised about that patch, especially because it *increases* 
polling interval from 400ms to 200ms. For me it has been always worked 
rather well, but now I suspect it could be due to I disable always 
remote controller... I have to test that.


regards
Antti

On 12/06/2014 02:25 AM, Benjamin Larsson wrote:

The Astrometa device has issues with i2c transfers. Lowering the
poll time somehow makes these errors disappear.

Signed-off-by: Benjamin Larsson 
---
  drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c 
b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 705c6c3..9ec4223 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -1567,7 +1567,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device 
*d,
rc->allowed_protos = RC_BIT_ALL;
rc->driver_type = RC_DRIVER_IR_RAW;
rc->query = rtl2832u_rc_query;
-   rc->interval = 400;
+   rc->interval = 200;

return 0;
  }



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


[PATCH v4] media: platform: add VPFE capture driver support for AM437X

2014-12-06 Thread Lad, Prabhakar
From: Benoit Parrot 

This patch adds Video Processing Front End (VPFE) driver for
AM437X family of devices
Driver supports the following:
- V4L2 API using MMAP buffer access based on videobuf2 api
- Asynchronous sensor/decoder sub device registration
- DT support

Signed-off-by: Benoit Parrot 
Signed-off-by: Darren Etheridge 
Signed-off-by: Lad, Prabhakar 
---
 Changes for v4:
 1: Fixed review comments pointed by Hans to check
ycbcr_enc and quantization while comparing formats,
fixed the release function and dropped compose cases
for vpfe_g_selection as compose isn't supported.

 .../devicetree/bindings/media/ti-am437x-vpfe.txt   |   61 +
 MAINTAINERS|9 +
 drivers/media/platform/Kconfig |1 +
 drivers/media/platform/Makefile|2 +
 drivers/media/platform/am437x/Kconfig  |   11 +
 drivers/media/platform/am437x/Makefile |3 +
 drivers/media/platform/am437x/am437x-vpfe.c| 2778 
 drivers/media/platform/am437x/am437x-vpfe.h|  283 ++
 drivers/media/platform/am437x/am437x-vpfe_regs.h   |  140 +
 include/uapi/linux/Kbuild  |1 +
 include/uapi/linux/am437x-vpfe.h   |  122 +
 11 files changed, 3411 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/ti-am437x-vpfe.txt
 create mode 100644 drivers/media/platform/am437x/Kconfig
 create mode 100644 drivers/media/platform/am437x/Makefile
 create mode 100644 drivers/media/platform/am437x/am437x-vpfe.c
 create mode 100644 drivers/media/platform/am437x/am437x-vpfe.h
 create mode 100644 drivers/media/platform/am437x/am437x-vpfe_regs.h
 create mode 100644 include/uapi/linux/am437x-vpfe.h

diff --git a/Documentation/devicetree/bindings/media/ti-am437x-vpfe.txt 
b/Documentation/devicetree/bindings/media/ti-am437x-vpfe.txt
new file mode 100644
index 000..3932e76
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/ti-am437x-vpfe.txt
@@ -0,0 +1,61 @@
+Texas Instruments AM437x CAMERA (VPFE)
+--
+
+The Video Processing Front End (VPFE) is a key component for image capture
+applications. The capture module provides the system interface and the
+processing capability to connect RAW image-sensor modules and video decoders
+to the AM437x device.
+
+Required properties:
+- compatible: must be "ti,am437x-vpfe"
+- reg: physical base address and length of the registers set for the device;
+- interrupts: should contain IRQ line for the VPFE;
+- ti,am437x-vpfe-interface: can be one of the following,
+   0 - Raw Bayer Interface.
+   1 - 8 Bit BT656 Interface.
+   2 - 10 Bit BT656 Interface.
+   3 - YCbCr 8 Bit Interface.
+   4 - YCbCr 16 Bit Interface.
+
+VPFE supports a single port node with parallel bus. It should contain one
+'port' child node with child 'endpoint' node. Please refer to the bindings
+defined in Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+   vpfe: vpfe@f0034000 {
+   compatible = "ti,am437x-vpfe";
+   reg = <0x48328000 0x2000>;
+   interrupts = ;
+
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <&vpfe_pins_default>;
+   pinctrl-1 = <&vpfe_pins_sleep>;
+
+   port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   vpfe0_ep: endpoint {
+   remote-endpoint = <&ov2659_1>;
+   ti,am437x-vpfe-interface = <0>;
+   bus-width = <8>;
+   hsync-active = <0>;
+   vsync-active = <0>;
+   };
+   };
+   };
+
+   i2c1: i2c@4802a000 {
+
+   ov2659@30 {
+   compatible = "ti,ov2659";
+   reg = <0x30>;
+
+   port {
+   ov2659_1: endpoint {
+   remote-endpoint = <&vpfe0_ep>;
+   bus-width = <8>;
+   mclk-frequency = <1200>;
+   };
+   };
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 9c49eb6..5b1cb1a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8543,6 +8543,15 @@ S:   Maintained
 F: drivers/media/platform/davinci/
 F: include/media/davinci/
 
+TI AM437X VPFE DRIVER
+M: Lad, Prabhakar 
+L: linux-media@vger.kernel.org
+W: http://linuxtv.org/
+Q: http://patchwork.linuxtv.org/project/linux-media/list/
+T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git
+S: Maintained
+F: drivers/media/platform/am437x/
+
 SIS 190 ETHERNET DRIVER
 M: Francois Romieu 
 L: net...@vger.kernel.org
diff --git a/drivers/media/platform/Kconfig b

Re: [PATCH 1/3] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors

2014-12-06 Thread Benjamin Larsson

On 12/06/2014 01:46 PM, Antti Palosaari wrote:

Moikka!
I am very surprised about that patch, especially because it 
*increases* polling interval from 400ms to 200ms. For me it has been 
always worked rather well, but now I suspect it could be due to I 
disable always remote controller... I have to test that.


regards
Antti


I noticed that I got more retry errors when I removed the poll. So when 
I tried lowering the interval time the errors totally disappeared for 
me. Exactly how it works is unclear to me but I guess that the rc poll 
triggers something in the chip to mitigate some overflow in the i2c 
transmit buffer. This workaround also suggest that the i2c bus actually 
is ok and not the cause for the errors. Anyway please test and if this 
is an acceptable solution then there might also be some check that this 
poll is active and set to 200 at all times for this card. At least when 
the card is set in dvb mode, for sdr mode this might not be an issue.


MvH
Benjamin Larsson
--
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: Terratec H7 with yet another usb ID

2014-12-06 Thread Olli Salonen
Hi Eddi,

As far as I know, the new version of Terratec H7 is another version of
DVBSky T680CI or TechnoTrend CT2-4650 CI. Just try to change the USB
IDs in the dvbsky.c driver and compile the driver and test. I'd do
this for you, but am travelling at the moment and have very limited
time.

Cheers,
-olli

On 5 December 2014 at 23:27, Eddi De Pieri  wrote:
> Hi Rik,
>
>
> I've download Terratec H7 rev 4 should be a
> TechnoTrend_TT-TVStick_CT2-44xx clone so you could try to patch
> dvbsky.c driver.
>
> Strings inside the windows driver:
> T E R R A T E C   S 7   D i g i t a l   T u n e r   ( D V B - S / S 2 )
> T T - c o n n e c t   C T 2 _ 4 6 5 0   D V B - T / T 2   T u n e r
> T E R R A T E C   H 7   D i g i t a l   T u n e r   ( D V B - T / T 2 )
> T T - c o n n e c t   C T 2 _ 4 6 5 0   D V B - C   T u n e r
> T E R R A T E C   H 7   D i g i t a l   T u n e r   ( D V B - C )
>
> Regards...
> Eddi
>
> On Fri, Dec 5, 2014 at 4:11 PM, Antti Palosaari  wrote:
>> Moikka
>> Take USB sniffs and generate driver C-code from that sniff. Then copy&paste
>> that code to driver until is starts working. After that, you could remove
>> all the code until you find minimum set of needed changes (error and trial).
>>
>> regards
>> Antti
>>
>>
>> On 12/05/2014 04:51 PM, Eddi De Pieri wrote:
>>>
>>> Hi,
>>>
>>> I got a sample usb tuner with similar issue with following
>>> vendor/product 13d3:0ccd.
>>>
>>> Onboard it have: CY7C68013A-56PVXC and a SI2168-40. The tuner isn't
>>> visible since is covered by a shield.
>>>
>>> I've tried to patch the az6007 to make it working.
>>>
>>> si2168 4-0064: Silicon Labs Si2168 successfully attached
>>> si2157 5-0060: unknown chip version Si2147-A30
>>>
>>> after applying latest patch from patchwork:
>>>
>>> si2157 5-0060: Silicon Labs Si2157/Si2158 successfully attached
>>>
>>> Now tuner seems to be connected but a w_scan don't detect any channel...
>>>
>>> Can you give me some some hint on troubleshooting this issue?
>>>
>>> Actually I'm brutally changed the initialization with copy and paste
>>> of silab attach from cxusb.c and em28xx-dvb.c by removing the drxk
>>> init..
>>>
>>> Since the chinese producer recicled old vid/pid.but what is the
>>> correct way to probe for multiple frontend and choose the right one?
>>>
>>> Eddi
>>>
>>>
>>> On Mon, Feb 3, 2014 at 11:33 PM, Antti Palosaari  wrote:

 Hei Rik


 On 03.02.2014 22:21, Rik van Mierlo wrote:
>
>
> Hi,
>
> I've recently purchased a Terratec H7, based on the fact that is was
> supported for a while now. Unfortunately, it turns out that my device
> uses a different product id, and maybe is not quite the same device
> inside either.
>
> ProductID for the Terratec H7 revisions in the module is either 10b4 or
> 10a3, the one I purchased is 10a5. Following this patch:
>
> https://patchwork.linuxtv.org/patch/9691
>
> I modified drivers/media/usb/dvb-usb-v2/az6007.c to include an
> additional device:
>
> static struct usb_device_id az6007_usb_table[] = {
>   {DVB_USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_6007,
>   &az6007_props, "Azurewave 6007", RC_MAP_EMPTY)},
>   {DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7,
>   &az6007_props, "Terratec H7",
> RC_MAP_NEC_TERRATEC_CINERGY_XS)},
>   {DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7_2,
>   &az6007_props, "Terratec H7",
> RC_MAP_NEC_TERRATEC_CINERGY_XS)},
>   {DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7_3,
>   &az6007_props, "Terratec H7",
> RC_MAP_NEC_TERRATEC_CINERGY_XS)},
>   {DVB_USB_DEVICE(USB_VID_TECHNISAT,
> USB_PID_TECHNISAT_USB2_CABLESTAR_HDCI,
>   &az6007_cablestar_hdci_props, "Technisat CableStar
> Combo HD CI", RC_MAP_EMPTY)},
>   {0},
> };
>
> and added the following to drivers/media/dvb-core/dvb-usb-ids.h
>
> #define USB_PID_TERRATEC_H7_3   0x10a5
>
> and recompiled/installed the kernel and modules. The module seems to
> have changed somewhat in 3.12.6 from the version that the patch was
> meant for, so I hope I this was all I had to change.
>
> Rebooting and plugging in the device now at least leads to a recognized
> device, but scanning for channels with w_scan does not work, and from
> the dmesg output below, it seems something is not working after loading
> the drxk firmware. Does anybody know what I could try next to get this
> device working? Could it be that the drxk firmware is not suitable for
> this revision of the device?
>
> [  700.112072] usb 4-2: new high-speed USB device number 2 using
> ehci-pci
> [  700.245092] usb 4-2: New USB device found, idVendor=0ccd,
> idProduct=10a5
> [  700.245105] usb 4-2: New USB device strings: Mfr=1, Product=2

Re: [PATCH 2/3] mn88472: make sure the private data struct is nulled after free

2014-12-06 Thread Antti Palosaari

But that is not needed anymore ?

regards
Antti

On 12/06/2014 02:25 AM, Benjamin Larsson wrote:

Using this driver with the attach dvb model might trigger a use
after free when unloading the driver. With this change the driver
will always fail on unload instead of randomly crash depending
on if the memory has been reused or not.

Signed-off-by: Benjamin Larsson 
---
  drivers/staging/media/mn88472/mn88472.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index 36ef39b..a9d5f0a 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -489,6 +489,7 @@ static int mn88472_remove(struct i2c_client *client)

regmap_exit(dev->regmap[0]);

+   memset(dev, 0, sizeof(*dev));
kfree(dev);

return 0;



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


Re: [PATCH 3/3] mn88472: add ts mode and ts clock to driver

2014-12-06 Thread Antti Palosaari

On 12/06/2014 02:25 AM, Benjamin Larsson wrote:

Signed-off-by: Benjamin Larsson 


Reviewed-by: Antti Palosaari 

Antti

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


DVBSky T980C: Si2168 fw load failed

2014-12-06 Thread Jurgen Kramer
On my new DVBSky T980C the tuner firmware failes to load:
[   51.326525] si2168 2-0064: found a 'Silicon Labs Si2168' in cold state
[   51.356233] si2168 2-0064: downloading firmware from file
'dvb-demod-si2168-a30-01.fw'
[   51.408166] si2168 2-0064: firmware download failed=-110
[   51.415457] si2157 4-0060: found a 'Silicon Labs Si2146/2147/2148/2157/2158'
in cold state
[   51.521714] si2157 4-0060: downloading firmware from file
'dvb-tuner-si2158-a20-01.fw'
[   52.330605] si2168 2-0064: found a 'Silicon Labs Si2168' in cold state
[   52.330784] si2168 2-0064: downloading firmware from file
'dvb-demod-si2168-a30-01.fw'
[   52.382145] si2168 2-0064: firmware download failed=-110

110 seems to mean connection timeout. Any pointers how to debug this further?

This is with the latest media_build from linuxtv.org on 3.17.4.

Jurgen

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


Fwd: USB capture card regression

2014-12-06 Thread Juan Xavier
I've noticed my Easycap DC60+ stopped capturing audio after a kernel
upgrade on my distribution (Arch Linux x86_64); going from linux
3.17.2 to 3.17.3.

I started a thread on the Arch Linux forums

https://bbs.archlinux.org/viewtopic.php?pid=1482059

and was adviced to report it to this mailing list.

Attached to this message are the related dmesg logs.

Thanks in advance


easycap-dmesg-3.17.2
Description: Binary data


easycap-dmesg-3.17.4
Description: Binary data


Re: [PATCH 2/3] mn88472: make sure the private data struct is nulled after free

2014-12-06 Thread Benjamin Larsson

On 12/06/2014 05:29 PM, Antti Palosaari wrote:

But that is not needed anymore ?

regards
Antti


Chances are that more devices with the mn8847x chips appear. Someone 
somewhere might try to use this demod with the old dvb attach model 
during development. Adding this memset will make the unload issue appear 
all the time instead of randomly. But this patch doesn't really matter 
so feel free to NACK it. I just wanted to post it for completeness.


I do think it is good practice to set pointers to null generally as that 
would have saved me several days of work of whentracking down this bug. 
The current dvb framework contain several other cases where pointers are 
feed'd but not nulled.


MvH
Benjamin Larsson
--
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: DVBSky T980C: Si2168 fw load failed

2014-12-06 Thread Antti Palosaari

On 12/06/2014 06:48 PM, Jurgen Kramer wrote:

On my new DVBSky T980C the tuner firmware failes to load:
[   51.326525] si2168 2-0064: found a 'Silicon Labs Si2168' in cold state
[   51.356233] si2168 2-0064: downloading firmware from file
'dvb-demod-si2168-a30-01.fw'
[   51.408166] si2168 2-0064: firmware download failed=-110
[   51.415457] si2157 4-0060: found a 'Silicon Labs Si2146/2147/2148/2157/2158'
in cold state
[   51.521714] si2157 4-0060: downloading firmware from file
'dvb-tuner-si2158-a20-01.fw'
[   52.330605] si2168 2-0064: found a 'Silicon Labs Si2168' in cold state
[   52.330784] si2168 2-0064: downloading firmware from file
'dvb-demod-si2168-a30-01.fw'
[   52.382145] si2168 2-0064: firmware download failed=-110

110 seems to mean connection timeout. Any pointers how to debug this further?

This is with the latest media_build from linuxtv.org on 3.17.4.


Looks like si2168 firmware failed to download, but si2157 succeeded. 
Could you add some more time for driver timeout? Current timeout is 
selected by trial and error, lets say it takes always max 43ms for my 
device I coded it 50ms.



drivers/media/dvb-frontends/si2168.c
/* wait cmd execution terminate */
#define TIMEOUT 50

change it to
#define TIMEOUT 500

Also, if it does not work, could you enable debugs to see what happens?
rmmod si2168
modprobe si2168
echo -n 'module si2168 =pft' > /sys/kernel/debug/dynamic_debug/control

regards
Antti

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


Re: [PATCH 2/3] mn88472: make sure the private data struct is nulled after free

2014-12-06 Thread Antti Palosaari

On 12/06/2014 08:08 PM, Benjamin Larsson wrote:

On 12/06/2014 05:29 PM, Antti Palosaari wrote:

But that is not needed anymore ?

regards
Antti


Chances are that more devices with the mn8847x chips appear. Someone
somewhere might try to use this demod with the old dvb attach model
during development. Adding this memset will make the unload issue appear
all the time instead of randomly. But this patch doesn't really matter
so feel free to NACK it. I just wanted to post it for completeness.

I do think it is good practice to set pointers to null generally as that
would have saved me several days of work of whentracking down this bug.
The current dvb framework contain several other cases where pointers are
feed'd but not nulled.


There is kzfree() for that, but still I am very unsure should we start 
zeroing memory upon release driver has allocated, or just relase it 
using kfree.


regards
Antti

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


Re: [BUG] Hauppage HVR-2250 - No Free Sequences

2014-12-06 Thread Kyle Sanderson
[1627538.860627] s5h1411_readreg: readreg error (ret == -5)
[1627538.860633] saa7164_cmd_send() No free sequences
[1627538.860636] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627538.860639] s5h1411_readreg: readreg error (ret == -5)
[1627538.860647] saa7164_cmd_send() No free sequences
[1627538.860649] saa7164_api_i2c_write() error, ret(1) = 0xc
[1627538.860652] s5h1411_writereg: writereg error 0x19 0xf7 0x, ret == -5)
[1627538.860656] saa7164_cmd_send() No free sequences
[1627538.860658] saa7164_api_i2c_write() error, ret(1) = 0xc
[1627538.860661] s5h1411_writereg: writereg error 0x19 0xf7 0x0001, ret == -5)
[1627538.860665] saa7164_cmd_send() No free sequences
[1627538.860666] saa7164_api_i2c_write() error, ret(1) = 0xc
[1627538.860669] s5h1411_writereg: writereg error 0x19 0xf5 0x0001, ret == -5)
[1627538.860675] saa7164_cmd_send() No free sequences
[1627538.860676] saa7164_api_i2c_write() error, ret(1) = 0xc
[1627538.860681] __tda18271_write_regs: [2-0060|M] ERROR: idx = 0x5,
len = 1, i2
 c_transfer returned:
-5
[1627538.860685] tda18271_init: [2-0060|M] error -5 on line 832
[1627538.860688] tda18271_tune: [2-0060|M] error -5 on line 910
[1627538.860691] tda18271_set_params: [2-0060|M] error -5 on line 985
[1627538.860695] saa7164_cmd_send() No free sequences
[1627538.860696] saa7164_api_i2c_write() error, ret(1) = 0xc
[1627538.860699] s5h1411_writereg: writereg error 0x19 0xf5 0x, ret == -5)
[1627538.860703] saa7164_cmd_send() No free sequences
[1627538.860704] saa7164_api_i2c_write() error, ret(1) = 0xc
[1627538.860707] s5h1411_writereg: writereg error 0x19 0xf7 0x, ret == -5)
[1627538.860710] saa7164_cmd_send() No free sequences
[1627538.860712] saa7164_api_i2c_write() error, ret(1) = 0xc
[1627538.860714] s5h1411_writereg: writereg error 0x19 0xf7 0x0001, ret == -5)
[1627538.878939] saa7164_cmd_send() No free sequences
[1627538.878942] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627538.878944] s5h1411_readreg: readreg error (ret == -5)
[1627538.878947] saa7164_cmd_send() No free sequences
[1627538.878949] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627538.878951] s5h1411_readreg: readreg error (ret == -5)
[1627538.929029] saa7164_cmd_send() No free sequences
[1627538.929031] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627538.929033] s5h1411_readreg: readreg error (ret == -5)
[1627538.929037] saa7164_cmd_send() No free sequences
[1627538.929038] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627538.929040] s5h1411_readreg: readreg error (ret == -5)
[1627538.979118] saa7164_cmd_send() No free sequences
[1627538.979120] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627538.979123] s5h1411_readreg: readreg error (ret == -5)
[1627538.979126] saa7164_cmd_send() No free sequences
[1627538.979128] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627538.979129] s5h1411_readreg: readreg error (ret == -5)
[1627539.029207] saa7164_cmd_send() No free sequences
[1627539.029210] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627539.029212] s5h1411_readreg: readreg error (ret == -5)
[1627539.029215] saa7164_cmd_send() No free sequences
[1627539.029217] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627539.029219] s5h1411_readreg: readreg error (ret == -5)
[1627539.079296] saa7164_cmd_send() No free sequences
[1627539.079298] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627539.079300] s5h1411_readreg: readreg error (ret == -5)
[1627539.079304] saa7164_cmd_send() No free sequences
[1627539.079306] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627539.079307] s5h1411_readreg: readreg error (ret == -5)
[1627539.129385] saa7164_cmd_send() No free sequences
[1627539.129387] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627539.129389] s5h1411_readreg: readreg error (ret == -5)
[1627539.129392] saa7164_cmd_send() No free sequences
[1627539.129394] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627539.129396] s5h1411_readreg: readreg error (ret == -5)
[1627539.179501] saa7164_cmd_send() No free sequences
[1627539.179505] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627539.179508] s5h1411_readreg: readreg error (ret == -5)
[1627539.179512] saa7164_cmd_send() No free sequences
[1627539.179514] saa7164_api_i2c_read() error, ret(1) = 0xc
[1627539.179515] s5h1411_readreg: readreg error (ret == -5)

On Sun, Nov 2, 2014 at 1:45 AM, Kyle Sanderson  wrote:
> [9.327707] saa7164 driver loaded
> [9.328739] ACPI: PCI Interrupt Link [LN4A] enabled at IRQ 19
> [9.329585] CORE saa7164[0]: subsystem: 0070:8851, board: Hauppauge
> WinTV-HVR2250 [card=7,autodetected]
> [9.329592] saa7164[0]/0: found at :05:00.0, rev: 129, irq: 19,
> latency: 0, mmio: 0xfe80
> [9.460023] saa7164_downloadfirmware() no first image
> [9.460034] saa7164_downloadfirmware() Waiting for firmware upload
> (NXP7164-2010-03-10.1.fw)
> [9.684071] saa7164_downloadfirmware() firmware read 4019072 bytes.
> [9.684076] saa7164_downloadfirmware() firmware loaded.
> [9.684077] Firmware fi

INTERNATIONAl JOB OPPORTUNITIES

2014-12-06 Thread 5423
MARRIOTT HOTEL SINGAPORE HAS EMPLOYMENT OPPORTUNITIES FOR AN EXOTIC
CANDIDATES IN DIFFERENT SKILLS,SEND YOUR CURRENT CV/RESUME AND
APPLICATION LETTER IN MICRO SOFT TO THIS E-MAIL ID:
marriothotelrecruitmentserv...@hotmail.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


Re: [PATCH 2/3] mn88472: make sure the private data struct is nulled after free

2014-12-06 Thread Benjamin Larsson

On 12/06/2014 07:37 PM, Antti Palosaari wrote:


I do think it is good practice to set pointers to null generally as that
would have saved me several days of work of whentracking down this bug.
The current dvb framework contain several other cases where pointers are
feed'd but not nulled.


There is kzfree() for that, but still I am very unsure should we start 
zeroing memory upon release driver has allocated, or just relase it 
using kfree.


regards
Antti 


Well I guess I am biased as I have spent lots of time finding a bug that 
probably wouldn't exist if the policy was that drivers always should set 
their memory to zero before it is free'd. Maybe we should have a compile 
time override so that all free calls zeroes the memory before the actual 
free? Maybe there already is this kind of feature?


MvH
Benjamin Larsson
--
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 14/22] si2157: rename device state variable from 's' to 'dev'

2014-12-06 Thread Antti Palosaari
'dev' is likely most common name in kernel for structure containing
device state instance, so rename it in order to keep things
consistent.

Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/si2157.c  | 118 ++---
 drivers/media/tuners/si2157_priv.h |   2 +-
 2 files changed, 59 insertions(+), 61 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 2180de9..14d2f73 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -19,16 +19,16 @@
 static const struct dvb_tuner_ops si2157_ops;
 
 /* execute firmware command */
-static int si2157_cmd_execute(struct si2157 *s, struct si2157_cmd *cmd)
+static int si2157_cmd_execute(struct si2157_dev *dev, struct si2157_cmd *cmd)
 {
int ret;
unsigned long timeout;
 
-   mutex_lock(&s->i2c_mutex);
+   mutex_lock(&dev->i2c_mutex);
 
if (cmd->wlen) {
/* write cmd and args for firmware */
-   ret = i2c_master_send(s->client, cmd->args, cmd->wlen);
+   ret = i2c_master_send(dev->client, cmd->args, cmd->wlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->wlen) {
@@ -42,7 +42,7 @@ static int si2157_cmd_execute(struct si2157 *s, struct 
si2157_cmd *cmd)
#define TIMEOUT 80
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
while (!time_after(jiffies, timeout)) {
-   ret = i2c_master_recv(s->client, cmd->args, cmd->rlen);
+   ret = i2c_master_recv(dev->client, cmd->args, 
cmd->rlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->rlen) {
@@ -55,7 +55,7 @@ static int si2157_cmd_execute(struct si2157 *s, struct 
si2157_cmd *cmd)
break;
}
 
-   dev_dbg(&s->client->dev, "cmd execution took %d ms\n",
+   dev_dbg(&dev->client->dev, "cmd execution took %d ms\n",
jiffies_to_msecs(jiffies) -
(jiffies_to_msecs(timeout) - TIMEOUT));
 
@@ -68,32 +68,32 @@ static int si2157_cmd_execute(struct si2157 *s, struct 
si2157_cmd *cmd)
ret = 0;
 
 err_mutex_unlock:
-   mutex_unlock(&s->i2c_mutex);
+   mutex_unlock(&dev->i2c_mutex);
if (ret)
goto err;
 
return 0;
 err:
-   dev_dbg(&s->client->dev, "failed=%d\n", ret);
+   dev_dbg(&dev->client->dev, "failed=%d\n", ret);
return ret;
 }
 
 static int si2157_init(struct dvb_frontend *fe)
 {
-   struct si2157 *s = fe->tuner_priv;
+   struct si2157_dev *dev = fe->tuner_priv;
int ret, len, remaining;
struct si2157_cmd cmd;
const struct firmware *fw = NULL;
u8 *fw_file;
unsigned int chip_id;
 
-   dev_dbg(&s->client->dev, "\n");
+   dev_dbg(&dev->client->dev, "\n");
 
-   if (s->fw_loaded)
+   if (dev->fw_loaded)
goto warm;
 
/* power up */
-   if (s->chiptype == SI2157_CHIPTYPE_SI2146) {
+   if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
cmd.wlen = 9;
} else {
@@ -101,7 +101,7 @@ static int si2157_init(struct dvb_frontend *fe)
cmd.wlen = 15;
}
cmd.rlen = 1;
-   ret = si2157_cmd_execute(s, &cmd);
+   ret = si2157_cmd_execute(dev, &cmd);
if (ret)
goto err;
 
@@ -109,7 +109,7 @@ static int si2157_init(struct dvb_frontend *fe)
memcpy(cmd.args, "\x02", 1);
cmd.wlen = 1;
cmd.rlen = 13;
-   ret = si2157_cmd_execute(s, &cmd);
+   ret = si2157_cmd_execute(dev, &cmd);
if (ret)
goto err;
 
@@ -132,7 +132,7 @@ static int si2157_init(struct dvb_frontend *fe)
case SI2146_A10:
goto skip_fw_download;
default:
-   dev_err(&s->client->dev,
+   dev_err(&dev->client->dev,
"unknown chip version Si21%d-%c%c%c\n",
cmd.args[2], cmd.args[1],
cmd.args[3], cmd.args[4]);
@@ -141,26 +141,26 @@ static int si2157_init(struct dvb_frontend *fe)
}
 
/* cold state - try to download firmware */
-   dev_info(&s->client->dev, "found a '%s' in cold state\n",
+   dev_info(&dev->client->dev, "found a '%s' in cold state\n",
si2157_ops.info.name);
 
/* request the firmware, this will block and timeout */
-   ret = request_firmware(&fw, fw_file, &s->client->dev);
+   ret = request_firmware(&fw, fw_file, &dev->client->dev);
if (ret) {
-   dev_err(&s->client->dev, "firmware file '%s' not found\n",
+   dev_err(&dev->client->dev, "

[PATCH 15/22] si2157: simplify si2157_cmd_execute() error path

2014-12-06 Thread Antti Palosaari
Remove if () from firmware command error path as there should not be
any error prone conditional logic there. Use goto labels instead.

Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/si2157.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 14d2f73..f7c3867 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -65,15 +65,11 @@ static int si2157_cmd_execute(struct si2157_dev *dev, 
struct si2157_cmd *cmd)
}
}
 
-   ret = 0;
+   mutex_unlock(&dev->i2c_mutex);
+   return 0;
 
 err_mutex_unlock:
mutex_unlock(&dev->i2c_mutex);
-   if (ret)
-   goto err;
-
-   return 0;
-err:
dev_dbg(&dev->client->dev, "failed=%d\n", ret);
return ret;
 }
-- 
http://palosaari.fi/

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


[PATCH 06/22] si2168: rename few things

2014-12-06 Thread Antti Palosaari
Rename some goto labels and more. No functionality changes.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c | 38 
 drivers/media/dvb-frontends/si2168.h |  6 ++
 2 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 2df3a27..a9486ef 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -115,17 +115,6 @@ static int si2168_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
if (ret)
goto err;
 
-   /*
-* Possible values seen, in order from strong signal to weak:
-* 16 0001 0110 full lock
-* 1e 0001 1110 partial lock
-* 1a 0001 1010 partial lock
-* 18 0001 1000 no lock
-*
-* [b3:b1] lock bits
-* [b4] statistics ready? Set in a few secs after lock is gained.
-*/
-
switch ((cmd.args[2] >> 1) & 0x03) {
case 0x01:
*status = FE_HAS_SIGNAL | FE_HAS_CARRIER;
@@ -291,7 +280,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
/* set DVB-C symbol rate */
if (c->delivery_system == SYS_DVBC_ANNEX_A) {
memcpy(cmd.args, "\x14\x00\x02\x11", 4);
-   cmd.args[4] = (c->symbol_rate / 1000) & 0xff;
+   cmd.args[4] = ((c->symbol_rate / 1000) >> 0) & 0xff;
cmd.args[5] = ((c->symbol_rate / 1000) >> 8) & 0xff;
cmd.wlen = 6;
cmd.rlen = 4;
@@ -455,7 +444,7 @@ static int si2168_init(struct dvb_frontend *fe)
dev_err(&client->dev,
"firmware file '%s' not found\n",
fw_file);
-   goto error_fw_release;
+   goto err_release_firmware;
}
}
 
@@ -474,7 +463,7 @@ static int si2168_init(struct dvb_frontend *fe)
dev_err(&client->dev,
"firmware download failed=%d\n",
ret);
-   goto error_fw_release;
+   goto err_release_firmware;
}
}
} else {
@@ -492,7 +481,7 @@ static int si2168_init(struct dvb_frontend *fe)
dev_err(&client->dev,
"firmware download failed=%d\n",
ret);
-   goto error_fw_release;
+   goto err_release_firmware;
}
}
}
@@ -535,8 +524,7 @@ warm:
dev->active = true;
 
return 0;
-
-error_fw_release:
+err_release_firmware:
release_firmware(fw);
 err:
dev_dbg(&client->dev, "failed=%d\n", ret);
@@ -684,7 +672,7 @@ static int si2168_probe(struct i2c_client *client,
if (!dev) {
ret = -ENOMEM;
dev_err(&client->dev, "kzalloc() failed\n");
-   goto err;
+   goto err_kfree;
}
 
mutex_init(&dev->i2c_mutex);
@@ -694,13 +682,12 @@ static int si2168_probe(struct i2c_client *client,
client, 0, 0, 0, si2168_select, si2168_deselect);
if (dev->adapter == NULL) {
ret = -ENODEV;
-   goto err;
+   goto err_kfree;
}
 
/* create dvb_frontend */
memcpy(&dev->fe.ops, &si2168_ops, sizeof(struct dvb_frontend_ops));
dev->fe.demodulator_priv = client;
-
*config->i2c_adapter = dev->adapter;
*config->fe = &dev->fe;
dev->ts_mode = config->ts_mode;
@@ -709,10 +696,9 @@ static int si2168_probe(struct i2c_client *client,
 
i2c_set_clientdata(client, dev);
 
-   dev_info(&client->dev,
-   "Silicon Labs Si2168 successfully attached\n");
+   dev_info(&client->dev, "Silicon Labs Si2168 successfully attached\n");
return 0;
-err:
+err_kfree:
kfree(dev);
dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
@@ -734,11 +720,11 @@ static int si2168_remove(struct i2c_client *client)
return 0;
 }
 
-static const struct i2c_device_id si2168_id[] = {
+static const struct i2c_device_id si2168_id_table[] = {
{"si2168", 0},
{}
 };
-MODULE_DEVICE_TABLE(i2c, si2168_id);
+MODULE_DEVICE_TABLE(i2c, si2168_id_table);
 
 static struct i2c_driver si2168_driver = {
.driver = {
@@ -747,7 +733,7 @@ static struct i2c_driver si2168_driver = {
},
.probe  = si2168_probe,
.remove = si2168_remove,
-   .id_table   = si2168_id,
+   .id_table   = si2168_id_table,
 };
 
 module_i2c_driver(si2168_driver);
diff --git a/drivers/media/dvb-frontends/si2168.h

[PATCH 05/22] si2168: simplify si2168_cmd_execute() error path

2014-12-06 Thread Antti Palosaari
Remove if () from firmware command error path as there should not be
any error prone conditional logic there. Use goto labels instead.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index db06bb7..2df3a27 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -66,15 +66,11 @@ static int si2168_cmd_execute(struct i2c_client *client, 
struct si2168_cmd *cmd)
}
}
 
-   ret = 0;
+   mutex_unlock(&dev->i2c_mutex);
+   return 0;
 
 err_mutex_unlock:
mutex_unlock(&dev->i2c_mutex);
-   if (ret)
-   goto err;
-
-   return 0;
-err:
dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
 }
-- 
http://palosaari.fi/

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


[PATCH 09/22] si2168: add own goto label for kzalloc failure

2014-12-06 Thread Antti Palosaari
Use own label for kzalloc failure in which does not call kfree().
kfree() could be called with NULL, but it is still better to have
own label which skips unnecessary kfree().

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

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index b4a6096..1fab088 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -672,7 +672,7 @@ static int si2168_probe(struct i2c_client *client,
if (!dev) {
ret = -ENOMEM;
dev_err(&client->dev, "kzalloc() failed\n");
-   goto err_kfree;
+   goto err;
}
 
mutex_init(&dev->i2c_mutex);
@@ -700,6 +700,7 @@ static int si2168_probe(struct i2c_client *client,
return 0;
 err_kfree:
kfree(dev);
+err:
dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
 }
-- 
http://palosaari.fi/

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


[PATCH 10/22] si2168: enhance firmware download routine

2014-12-06 Thread Antti Palosaari
All known old firmware firmware formats are downloaded using 8 byte
chunks. Reject firmware if it could not be divided to 8 byte chunks
and because of that we could simplify some calculations. Now both
supported firmware download routines are rather similar.

Cc: Olli Salonen 
Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c | 34 +++---
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 1fab088..e8e715f 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -348,7 +348,6 @@ static int si2168_init(struct dvb_frontend *fe)
int ret, len, remaining;
const struct firmware *fw = NULL;
u8 *fw_file;
-   const unsigned int i2c_wr_max = 8;
struct si2168_cmd cmd;
unsigned int chip_id;
 
@@ -459,31 +458,28 @@ static int si2168_init(struct dvb_frontend *fe)
cmd.wlen = len;
cmd.rlen = 1;
ret = si2168_cmd_execute(client, &cmd);
-   if (ret) {
-   dev_err(&client->dev,
-   "firmware download failed=%d\n",
-   ret);
-   goto err_release_firmware;
-   }
+   if (ret)
+   break;
}
-   } else {
+   } else if (fw->size % 8 == 0) {
/* firmware is in the old format */
-   for (remaining = fw->size; remaining > 0; remaining -= 
i2c_wr_max) {
-   len = remaining;
-   if (len > i2c_wr_max)
-   len = i2c_wr_max;
-
+   for (remaining = fw->size; remaining > 0; remaining -= 8) {
+   len = 8;
memcpy(cmd.args, &fw->data[fw->size - remaining], len);
cmd.wlen = len;
cmd.rlen = 1;
ret = si2168_cmd_execute(client, &cmd);
-   if (ret) {
-   dev_err(&client->dev,
-   "firmware download failed=%d\n",
-   ret);
-   goto err_release_firmware;
-   }
+   if (ret)
+   break;
}
+   } else {
+   /* bad or unknown firmware format */
+   ret = -EINVAL;
+   }
+
+   if (ret) {
+   dev_err(&client->dev, "firmware download failed %d\n", ret);
+   goto err_release_firmware;
}
 
release_firmware(fw);
-- 
http://palosaari.fi/

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


[PATCH 01/22] si2168: define symbol rate limits

2014-12-06 Thread Antti Palosaari
w_scan complains about missing symbol rate limits:
This dvb driver is *buggy*: the symbol rate limits are undefined - please 
report to linuxtv.org

Chip supports 1 to 7.2 MSymbol/s on DVB-C.

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

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index ce9ab44..acf0fc3 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -635,6 +635,8 @@ static const struct dvb_frontend_ops si2168_ops = {
.delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A},
.info = {
.name = "Silicon Labs Si2168",
+   .symbol_rate_min = 100,
+   .symbol_rate_max = 720,
.caps = FE_CAN_FEC_1_2 |
FE_CAN_FEC_2_3 |
FE_CAN_FEC_3_4 |
-- 
http://palosaari.fi/

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


[PATCH 08/22] si2168: change stream id debug log formatter

2014-12-06 Thread Antti Palosaari
Change formatter from signed to unsigned as stream_id is 32bit
unsigned variable.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index e51676c..b4a6096 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -155,10 +155,10 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
u8 bandwidth, delivery_system;
 
dev_dbg(&client->dev,
-   "delivery_system=%u modulation=%u frequency=%u 
bandwidth_hz=%u symbol_rate=%u inversion=%u, stream_id=%d\n",
-   c->delivery_system, c->modulation,
-   c->frequency, c->bandwidth_hz, c->symbol_rate,
-   c->inversion, c->stream_id);
+   "delivery_system=%u modulation=%u frequency=%u 
bandwidth_hz=%u symbol_rate=%u inversion=%u stream_id=%u\n",
+   c->delivery_system, c->modulation, c->frequency,
+   c->bandwidth_hz, c->symbol_rate, c->inversion,
+   c->stream_id);
 
if (!dev->active) {
ret = -EAGAIN;
-- 
http://palosaari.fi/

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


[PATCH 22/22] si2157: change firmware variable name and type

2014-12-06 Thread Antti Palosaari
Rename firmware variable from fw_file to fw_name and change its
type from u8 to const char as request_firmware() input is.

Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/si2157.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 27b488b..fcf139d 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -82,7 +82,7 @@ static int si2157_init(struct dvb_frontend *fe)
int ret, len, remaining;
struct si2157_cmd cmd;
const struct firmware *fw;
-   u8 *fw_file;
+   const char *fw_name;
unsigned int chip_id;
 
dev_dbg(&client->dev, "\n");
@@ -123,12 +123,12 @@ static int si2157_init(struct dvb_frontend *fe)
switch (chip_id) {
case SI2158_A20:
case SI2148_A20:
-   fw_file = SI2158_A20_FIRMWARE;
+   fw_name = SI2158_A20_FIRMWARE;
break;
case SI2157_A30:
case SI2147_A30:
case SI2146_A10:
-   fw_file = NULL;
+   fw_name = NULL;
break;
default:
dev_err(&client->dev, "unknown chip version Si21%d-%c%c%c\n",
@@ -141,27 +141,27 @@ static int si2157_init(struct dvb_frontend *fe)
dev_info(&client->dev, "found a 'Silicon Labs Si21%d-%c%c%c'\n",
cmd.args[2], cmd.args[1], cmd.args[3], cmd.args[4]);
 
-   if (fw_file == NULL)
+   if (fw_name == NULL)
goto skip_fw_download;
 
/* request the firmware, this will block and timeout */
-   ret = request_firmware(&fw, fw_file, &client->dev);
+   ret = request_firmware(&fw, fw_name, &client->dev);
if (ret) {
dev_err(&client->dev, "firmware file '%s' not found\n",
-   fw_file);
+   fw_name);
goto err;
}
 
/* firmware should be n chunks of 17 bytes */
if (fw->size % 17 != 0) {
dev_err(&client->dev, "firmware file '%s' is invalid\n",
-   fw_file);
+   fw_name);
ret = -EINVAL;
goto err_release_firmware;
}
 
dev_info(&client->dev, "downloading firmware from file '%s'\n",
-   fw_file);
+   fw_name);
 
for (remaining = fw->size; remaining > 0; remaining -= 17) {
len = fw->data[fw->size - remaining];
-- 
http://palosaari.fi/

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


[PATCH 04/22] si2168: get rid of own struct i2c_client pointer

2014-12-06 Thread Antti Palosaari
We don't need that anymore as same pointer is passed to each
routine via struct dvb_frontend private field.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c  | 61 +++
 drivers/media/dvb-frontends/si2168_priv.h |  1 -
 2 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 50674d4..db06bb7 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -29,7 +29,7 @@ static int si2168_cmd_execute(struct i2c_client *client, 
struct si2168_cmd *cmd)
 
if (cmd->wlen) {
/* write cmd and args for firmware */
-   ret = i2c_master_send(dev->client, cmd->args, cmd->wlen);
+   ret = i2c_master_send(client, cmd->args, cmd->wlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->wlen) {
@@ -43,7 +43,7 @@ static int si2168_cmd_execute(struct i2c_client *client, 
struct si2168_cmd *cmd)
#define TIMEOUT 50
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
while (!time_after(jiffies, timeout)) {
-   ret = i2c_master_recv(dev->client, cmd->args, 
cmd->rlen);
+   ret = i2c_master_recv(client, cmd->args, cmd->rlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->rlen) {
@@ -56,7 +56,7 @@ static int si2168_cmd_execute(struct i2c_client *client, 
struct si2168_cmd *cmd)
break;
}
 
-   dev_dbg(&dev->client->dev, "cmd execution took %d ms\n",
+   dev_dbg(&client->dev, "cmd execution took %d ms\n",
jiffies_to_msecs(jiffies) -
(jiffies_to_msecs(timeout) - TIMEOUT));
 
@@ -75,7 +75,7 @@ err_mutex_unlock:
 
return 0;
 err:
-   dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+   dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
 }
 
@@ -151,12 +151,12 @@ static int si2168_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
 
-   dev_dbg(&dev->client->dev, "status=%02x args=%*ph\n",
+   dev_dbg(&client->dev, "status=%02x args=%*ph\n",
*status, cmd.rlen, cmd.args);
 
return 0;
 err:
-   dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+   dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
 }
 
@@ -169,7 +169,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
struct si2168_cmd cmd;
u8 bandwidth, delivery_system;
 
-   dev_dbg(&dev->client->dev,
+   dev_dbg(&client->dev,
"delivery_system=%u modulation=%u frequency=%u 
bandwidth_hz=%u symbol_rate=%u inversion=%u, stream_id=%d\n",
c->delivery_system, c->modulation,
c->frequency, c->bandwidth_hz, c->symbol_rate,
@@ -352,7 +352,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
 
return 0;
 err:
-   dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+   dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
 }
 
@@ -367,7 +367,7 @@ static int si2168_init(struct dvb_frontend *fe)
struct si2168_cmd cmd;
unsigned int chip_id;
 
-   dev_dbg(&dev->client->dev, "\n");
+   dev_dbg(&client->dev, "\n");
 
/* initialize */
memcpy(cmd.args, 
"\xc0\x12\x00\x0c\x00\x0d\x16\x00\x00\x00\x00\x00\x00", 13);
@@ -430,7 +430,7 @@ static int si2168_init(struct dvb_frontend *fe)
fw_file = SI2168_B40_FIRMWARE;
break;
default:
-   dev_err(&dev->client->dev,
+   dev_err(&client->dev,
"unknown chip version Si21%d-%c%c%c\n",
cmd.args[2], cmd.args[1],
cmd.args[3], cmd.args[4]);
@@ -439,31 +439,31 @@ static int si2168_init(struct dvb_frontend *fe)
}
 
/* cold state - try to download firmware */
-   dev_info(&dev->client->dev, "found a '%s' in cold state\n",
+   dev_info(&client->dev, "found a '%s' in cold state\n",
si2168_ops.info.name);
 
/* request the firmware, this will block and timeout */
-   ret = request_firmware(&fw, fw_file, &dev->client->dev);
+   ret = request_firmware(&fw, fw_file, &client->dev);
if (ret) {
/* fallback mechanism to handle old name for Si2168 B40 fw */
if (chip_id == SI2168_B40) {
fw_file = SI2168_B40_FIRMWARE_FALLBACK;
-   ret = request_firmware(&fw, fw_file, &dev->client->dev);
+   ret = request_firmware(&fw, fw_file, &client->

[PATCH 07/22] si2168: change firmware version print from debug to info

2014-12-06 Thread Antti Palosaari
Even firmware version is not needed to know, it is still interesting
and useful to know some cases. Due to that increase its printing to
info log level.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index a9486ef..e51676c 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -504,7 +504,7 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
-   dev_dbg(&client->dev, "firmware version: %c.%c.%d\n",
+   dev_info(&client->dev, "firmware version: %c.%c.%d\n",
cmd.args[6], cmd.args[7], cmd.args[8]);
 
/* set ts mode */
-- 
http://palosaari.fi/

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


[PATCH 02/22] si2168: rename device state variable from 's' to 'dev'

2014-12-06 Thread Antti Palosaari
'dev' is most common name in kernel for structure containing device
state instance, so rename it.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c  | 202 +++---
 drivers/media/dvb-frontends/si2168_priv.h |   2 +-
 2 files changed, 102 insertions(+), 102 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index acf0fc3..e989bd4 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -19,16 +19,16 @@
 static const struct dvb_frontend_ops si2168_ops;
 
 /* execute firmware command */
-static int si2168_cmd_execute(struct si2168 *s, struct si2168_cmd *cmd)
+static int si2168_cmd_execute(struct si2168_dev *dev, struct si2168_cmd *cmd)
 {
int ret;
unsigned long timeout;
 
-   mutex_lock(&s->i2c_mutex);
+   mutex_lock(&dev->i2c_mutex);
 
if (cmd->wlen) {
/* write cmd and args for firmware */
-   ret = i2c_master_send(s->client, cmd->args, cmd->wlen);
+   ret = i2c_master_send(dev->client, cmd->args, cmd->wlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->wlen) {
@@ -42,7 +42,7 @@ static int si2168_cmd_execute(struct si2168 *s, struct 
si2168_cmd *cmd)
#define TIMEOUT 50
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
while (!time_after(jiffies, timeout)) {
-   ret = i2c_master_recv(s->client, cmd->args, cmd->rlen);
+   ret = i2c_master_recv(dev->client, cmd->args, 
cmd->rlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->rlen) {
@@ -55,7 +55,7 @@ static int si2168_cmd_execute(struct si2168 *s, struct 
si2168_cmd *cmd)
break;
}
 
-   dev_dbg(&s->client->dev, "cmd execution took %d ms\n",
+   dev_dbg(&dev->client->dev, "cmd execution took %d ms\n",
jiffies_to_msecs(jiffies) -
(jiffies_to_msecs(timeout) - TIMEOUT));
 
@@ -68,26 +68,26 @@ static int si2168_cmd_execute(struct si2168 *s, struct 
si2168_cmd *cmd)
ret = 0;
 
 err_mutex_unlock:
-   mutex_unlock(&s->i2c_mutex);
+   mutex_unlock(&dev->i2c_mutex);
if (ret)
goto err;
 
return 0;
 err:
-   dev_dbg(&s->client->dev, "failed=%d\n", ret);
+   dev_dbg(&dev->client->dev, "failed=%d\n", ret);
return ret;
 }
 
 static int si2168_read_status(struct dvb_frontend *fe, fe_status_t *status)
 {
-   struct si2168 *s = fe->demodulator_priv;
+   struct si2168_dev *dev = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret;
struct si2168_cmd cmd;
 
*status = 0;
 
-   if (!s->active) {
+   if (!dev->active) {
ret = -EAGAIN;
goto err;
}
@@ -113,7 +113,7 @@ static int si2168_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
goto err;
}
 
-   ret = si2168_cmd_execute(s, &cmd);
+   ret = si2168_cmd_execute(dev, &cmd);
if (ret)
goto err;
 
@@ -138,7 +138,7 @@ static int si2168_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
break;
}
 
-   s->fe_status = *status;
+   dev->fe_status = *status;
 
if (*status & FE_HAS_LOCK) {
c->cnr.len = 1;
@@ -149,30 +149,30 @@ static int si2168_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
 
-   dev_dbg(&s->client->dev, "status=%02x args=%*ph\n",
+   dev_dbg(&dev->client->dev, "status=%02x args=%*ph\n",
*status, cmd.rlen, cmd.args);
 
return 0;
 err:
-   dev_dbg(&s->client->dev, "failed=%d\n", ret);
+   dev_dbg(&dev->client->dev, "failed=%d\n", ret);
return ret;
 }
 
 static int si2168_set_frontend(struct dvb_frontend *fe)
 {
-   struct si2168 *s = fe->demodulator_priv;
+   struct si2168_dev *dev = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret;
struct si2168_cmd cmd;
u8 bandwidth, delivery_system;
 
-   dev_dbg(&s->client->dev,
+   dev_dbg(&dev->client->dev,
"delivery_system=%u modulation=%u frequency=%u 
bandwidth_hz=%u symbol_rate=%u inversion=%u, stream_id=%d\n",
c->delivery_system, c->modulation,
c->frequency, c->bandwidth_hz, c->symbol_rate,
c->inversion, c->stream_id);
 
-   if (!s->active) {
+   if (!dev->active) {
ret = -EAGAIN;
goto err;
}
@@ -217,7 +217,7 

[PATCH 03/22] si2168: carry pointer to client instead of state

2014-12-06 Thread Antti Palosaari
Carry struct i2c_client pointer inside struct dvb_frontend private
pointer. This driver is I2C driver, which is represented as a
struct i2c_client, so better to carry this top level structure for
each routine in order to unify things. This allows further
simplification.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c | 83 +++-
 1 file changed, 45 insertions(+), 38 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index e989bd4..50674d4 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -19,8 +19,9 @@
 static const struct dvb_frontend_ops si2168_ops;
 
 /* execute firmware command */
-static int si2168_cmd_execute(struct si2168_dev *dev, struct si2168_cmd *cmd)
+static int si2168_cmd_execute(struct i2c_client *client, struct si2168_cmd 
*cmd)
 {
+   struct si2168_dev *dev = i2c_get_clientdata(client);
int ret;
unsigned long timeout;
 
@@ -80,7 +81,8 @@ err:
 
 static int si2168_read_status(struct dvb_frontend *fe, fe_status_t *status)
 {
-   struct si2168_dev *dev = fe->demodulator_priv;
+   struct i2c_client *client = fe->demodulator_priv;
+   struct si2168_dev *dev = i2c_get_clientdata(client);
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret;
struct si2168_cmd cmd;
@@ -113,7 +115,7 @@ static int si2168_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
goto err;
}
 
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
@@ -160,7 +162,8 @@ err:
 
 static int si2168_set_frontend(struct dvb_frontend *fe)
 {
-   struct si2168_dev *dev = fe->demodulator_priv;
+   struct i2c_client *client = fe->demodulator_priv;
+   struct si2168_dev *dev = i2c_get_clientdata(client);
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret;
struct si2168_cmd cmd;
@@ -217,7 +220,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
memcpy(cmd.args, "\x88\x02\x02\x02\x02", 5);
cmd.wlen = 5;
cmd.rlen = 5;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
@@ -230,7 +233,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
memcpy(cmd.args, "\x89\x21\x06\x11\x89\x20", 6);
cmd.wlen = 6;
cmd.rlen = 3;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
@@ -241,7 +244,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
cmd.args[2] = c->stream_id == NO_STREAM_ID_FILTER ? 0 : 1;
cmd.wlen = 3;
cmd.rlen = 1;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
}
@@ -249,35 +252,35 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
memcpy(cmd.args, "\x51\x03", 2);
cmd.wlen = 2;
cmd.rlen = 12;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
memcpy(cmd.args, "\x12\x08\x04", 3);
cmd.wlen = 3;
cmd.rlen = 3;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
memcpy(cmd.args, "\x14\x00\x0c\x10\x12\x00", 6);
cmd.wlen = 6;
cmd.rlen = 4;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
memcpy(cmd.args, "\x14\x00\x06\x10\x24\x00", 6);
cmd.wlen = 6;
cmd.rlen = 4;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
memcpy(cmd.args, "\x14\x00\x07\x10\x00\x24", 6);
cmd.wlen = 6;
cmd.rlen = 4;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
@@ -285,7 +288,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
cmd.args[4] = delivery_system | bandwidth;
cmd.wlen = 6;
cmd.rlen = 4;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
goto err;
 
@@ -296,7 +299,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
cmd.args[5] = ((c->symbol_rate / 1000) >> 8) & 0xff;
cmd.wlen = 6;
cmd.rlen = 4;
-   ret = si2168_cmd_execute(dev, &cmd);
+   ret = si2168_cmd_execute(client, &cmd);
if (ret)
   

[PATCH 21/22] si2157: print chip version

2014-12-06 Thread Antti Palosaari
Print chip version once using log level into when init() is called.
Remove cold/warm state printing as those are not very useful.

Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/si2157.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 6ae7620..27b488b 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -128,7 +128,8 @@ static int si2157_init(struct dvb_frontend *fe)
case SI2157_A30:
case SI2147_A30:
case SI2146_A10:
-   goto skip_fw_download;
+   fw_file = NULL;
+   break;
default:
dev_err(&client->dev, "unknown chip version Si21%d-%c%c%c\n",
cmd.args[2], cmd.args[1],
@@ -137,9 +138,11 @@ static int si2157_init(struct dvb_frontend *fe)
goto err;
}
 
-   /* cold state - try to download firmware */
-   dev_info(&client->dev, "found a '%s' in cold state\n",
-   si2157_ops.info.name);
+   dev_info(&client->dev, "found a 'Silicon Labs Si21%d-%c%c%c'\n",
+   cmd.args[2], cmd.args[1], cmd.args[3], cmd.args[4]);
+
+   if (fw_file == NULL)
+   goto skip_fw_download;
 
/* request the firmware, this will block and timeout */
ret = request_firmware(&fw, fw_file, &client->dev);
-- 
http://palosaari.fi/

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


[PATCH 20/22] si2157: print firmware version

2014-12-06 Thread Antti Palosaari
Firmware version could be printed similarly than si2168 driver does.

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

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 3f9aa7a..6ae7620 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -184,6 +184,17 @@ skip_fw_download:
if (ret)
goto err;
 
+   /* query firmware version */
+   memcpy(cmd.args, "\x11", 1);
+   cmd.wlen = 1;
+   cmd.rlen = 10;
+   ret = si2157_cmd_execute(client, &cmd);
+   if (ret)
+   goto err;
+
+   dev_info(&client->dev, "firmware version: %c.%c.%d\n",
+   cmd.args[6], cmd.args[7], cmd.args[8]);
+
dev->fw_loaded = true;
 
 warm:
-- 
http://palosaari.fi/

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


[PATCH 13/22] si2168: change firmware variable name and type

2014-12-06 Thread Antti Palosaari
Rename firmware variable from fw_file to fw_name and change its type
from u8 to const char as request_firmware() input defines.

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

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 46a919b..7f966f3 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -347,7 +347,7 @@ static int si2168_init(struct dvb_frontend *fe)
struct si2168_dev *dev = i2c_get_clientdata(client);
int ret, len, remaining;
const struct firmware *fw;
-   u8 *fw_file;
+   const char *fw_name;
struct si2168_cmd cmd;
unsigned int chip_id;
 
@@ -405,13 +405,13 @@ static int si2168_init(struct dvb_frontend *fe)
 
switch (chip_id) {
case SI2168_A20:
-   fw_file = SI2168_A20_FIRMWARE;
+   fw_name = SI2168_A20_FIRMWARE;
break;
case SI2168_A30:
-   fw_file = SI2168_A30_FIRMWARE;
+   fw_name = SI2168_A30_FIRMWARE;
break;
case SI2168_B40:
-   fw_file = SI2168_B40_FIRMWARE;
+   fw_name = SI2168_B40_FIRMWARE;
break;
default:
dev_err(&client->dev, "unknown chip version Si21%d-%c%c%c\n",
@@ -425,12 +425,12 @@ static int si2168_init(struct dvb_frontend *fe)
cmd.args[2], cmd.args[1], cmd.args[3], cmd.args[4]);
 
/* request the firmware, this will block and timeout */
-   ret = request_firmware(&fw, fw_file, &client->dev);
+   ret = request_firmware(&fw, fw_name, &client->dev);
if (ret) {
/* fallback mechanism to handle old name for Si2168 B40 fw */
if (chip_id == SI2168_B40) {
-   fw_file = SI2168_B40_FIRMWARE_FALLBACK;
-   ret = request_firmware(&fw, fw_file, &client->dev);
+   fw_name = SI2168_B40_FIRMWARE_FALLBACK;
+   ret = request_firmware(&fw, fw_name, &client->dev);
}
 
if (ret == 0) {
@@ -440,13 +440,13 @@ static int si2168_init(struct dvb_frontend *fe)
} else {
dev_err(&client->dev,
"firmware file '%s' not found\n",
-   fw_file);
+   fw_name);
goto err_release_firmware;
}
}
 
dev_info(&client->dev, "downloading firmware from file '%s'\n",
-   fw_file);
+   fw_name);
 
if ((fw->size % 17 == 0) && (fw->data[0] > 5)) {
/* firmware is in the new format */
-- 
http://palosaari.fi/

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


[PATCH 12/22] si2168: print chip version

2014-12-06 Thread Antti Palosaari
Print chip version once using log level into when init() is called.
Remove cold/warm state printing as those are not very useful.

old printing:
si2168 6-0064: found a 'Silicon Labs Si2168' in cold state
si2168 6-0064: downloading firmware from file 'dvb-demod-si2168-b40-01.fw'
si2168 6-0064: firmware version: 4.0.11
si2168 6-0064: found a 'Silicon Labs Si2168' in warm state

new printing:
si2168 6-0064: found a 'Silicon Labs Si2168-B40'
si2168 6-0064: downloading firmware from file 'dvb-demod-si2168-b40-01.fw'
si2168 6-0064: firmware version: 4.0.11

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

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 7f20fd0..46a919b 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -414,17 +414,15 @@ static int si2168_init(struct dvb_frontend *fe)
fw_file = SI2168_B40_FIRMWARE;
break;
default:
-   dev_err(&client->dev,
-   "unknown chip version Si21%d-%c%c%c\n",
+   dev_err(&client->dev, "unknown chip version Si21%d-%c%c%c\n",
cmd.args[2], cmd.args[1],
cmd.args[3], cmd.args[4]);
ret = -EINVAL;
goto err;
}
 
-   /* cold state - try to download firmware */
-   dev_info(&client->dev, "found a '%s' in cold state\n",
-   si2168_ops.info.name);
+   dev_info(&client->dev, "found a 'Silicon Labs Si21%d-%c%c%c'\n",
+   cmd.args[2], cmd.args[1], cmd.args[3], cmd.args[4]);
 
/* request the firmware, this will block and timeout */
ret = request_firmware(&fw, fw_file, &client->dev);
@@ -512,13 +510,11 @@ static int si2168_init(struct dvb_frontend *fe)
goto err;
 
dev->fw_loaded = true;
-
-   dev_info(&client->dev, "found a '%s' in warm state\n",
-   si2168_ops.info.name);
 warm:
dev->active = true;
 
return 0;
+
 err_release_firmware:
release_firmware(fw);
 err:
-- 
http://palosaari.fi/

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


[PATCH 17/22] si2157: change firmware download error handling

2014-12-06 Thread Antti Palosaari
Rename firmare download error path goto label. Remove firmware NULL
set as NULL value is not needed anymore, due to recent change which
started using goto labels for firmware error handling.

Cc: Olli Salonen 
Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/si2157.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 88afb2a..6174c8e 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -81,7 +81,7 @@ static int si2157_init(struct dvb_frontend *fe)
struct si2157_dev *dev = i2c_get_clientdata(client);
int ret, len, remaining;
struct si2157_cmd cmd;
-   const struct firmware *fw = NULL;
+   const struct firmware *fw;
u8 *fw_file;
unsigned int chip_id;
 
@@ -154,7 +154,7 @@ static int si2157_init(struct dvb_frontend *fe)
dev_err(&client->dev, "firmware file '%s' is invalid\n",
fw_file);
ret = -EINVAL;
-   goto fw_release_exit;
+   goto err_release_firmware;
}
 
dev_info(&client->dev, "downloading firmware from file '%s'\n",
@@ -169,12 +169,11 @@ static int si2157_init(struct dvb_frontend *fe)
if (ret) {
dev_err(&client->dev, "firmware download failed %d\n",
ret);
-   goto fw_release_exit;
+   goto err_release_firmware;
}
}
 
release_firmware(fw);
-   fw = NULL;
 
 skip_fw_download:
/* reboot the tuner with new firmware? */
@@ -191,7 +190,7 @@ warm:
dev->active = true;
return 0;
 
-fw_release_exit:
+err_release_firmware:
release_firmware(fw);
 err:
dev_dbg(&client->dev, "failed=%d\n", ret);
-- 
http://palosaari.fi/

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


[PATCH 16/22] si2157: carry pointer to client instead of state in tuner_priv

2014-12-06 Thread Antti Palosaari
Carry struct i2c_client pointer in tuner_priv. This driver is I2C driver,
which is represented as a struct i2c_client, so better to carry this top
level structure for each routine in order to unify things.

Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/si2157.c  | 78 +++---
 drivers/media/tuners/si2157_priv.h |  1 -
 2 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index f7c3867..88afb2a 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -19,8 +19,9 @@
 static const struct dvb_tuner_ops si2157_ops;
 
 /* execute firmware command */
-static int si2157_cmd_execute(struct si2157_dev *dev, struct si2157_cmd *cmd)
+static int si2157_cmd_execute(struct i2c_client *client, struct si2157_cmd 
*cmd)
 {
+   struct si2157_dev *dev = i2c_get_clientdata(client);
int ret;
unsigned long timeout;
 
@@ -28,7 +29,7 @@ static int si2157_cmd_execute(struct si2157_dev *dev, struct 
si2157_cmd *cmd)
 
if (cmd->wlen) {
/* write cmd and args for firmware */
-   ret = i2c_master_send(dev->client, cmd->args, cmd->wlen);
+   ret = i2c_master_send(client, cmd->args, cmd->wlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->wlen) {
@@ -42,7 +43,7 @@ static int si2157_cmd_execute(struct si2157_dev *dev, struct 
si2157_cmd *cmd)
#define TIMEOUT 80
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
while (!time_after(jiffies, timeout)) {
-   ret = i2c_master_recv(dev->client, cmd->args, 
cmd->rlen);
+   ret = i2c_master_recv(client, cmd->args, cmd->rlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->rlen) {
@@ -55,7 +56,7 @@ static int si2157_cmd_execute(struct si2157_dev *dev, struct 
si2157_cmd *cmd)
break;
}
 
-   dev_dbg(&dev->client->dev, "cmd execution took %d ms\n",
+   dev_dbg(&client->dev, "cmd execution took %d ms\n",
jiffies_to_msecs(jiffies) -
(jiffies_to_msecs(timeout) - TIMEOUT));
 
@@ -70,20 +71,21 @@ static int si2157_cmd_execute(struct si2157_dev *dev, 
struct si2157_cmd *cmd)
 
 err_mutex_unlock:
mutex_unlock(&dev->i2c_mutex);
-   dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+   dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
 }
 
 static int si2157_init(struct dvb_frontend *fe)
 {
-   struct si2157_dev *dev = fe->tuner_priv;
+   struct i2c_client *client = fe->tuner_priv;
+   struct si2157_dev *dev = i2c_get_clientdata(client);
int ret, len, remaining;
struct si2157_cmd cmd;
const struct firmware *fw = NULL;
u8 *fw_file;
unsigned int chip_id;
 
-   dev_dbg(&dev->client->dev, "\n");
+   dev_dbg(&client->dev, "\n");
 
if (dev->fw_loaded)
goto warm;
@@ -97,7 +99,7 @@ static int si2157_init(struct dvb_frontend *fe)
cmd.wlen = 15;
}
cmd.rlen = 1;
-   ret = si2157_cmd_execute(dev, &cmd);
+   ret = si2157_cmd_execute(client, &cmd);
if (ret)
goto err;
 
@@ -105,7 +107,7 @@ static int si2157_init(struct dvb_frontend *fe)
memcpy(cmd.args, "\x02", 1);
cmd.wlen = 1;
cmd.rlen = 13;
-   ret = si2157_cmd_execute(dev, &cmd);
+   ret = si2157_cmd_execute(client, &cmd);
if (ret)
goto err;
 
@@ -128,8 +130,7 @@ static int si2157_init(struct dvb_frontend *fe)
case SI2146_A10:
goto skip_fw_download;
default:
-   dev_err(&dev->client->dev,
-   "unknown chip version Si21%d-%c%c%c\n",
+   dev_err(&client->dev, "unknown chip version Si21%d-%c%c%c\n",
cmd.args[2], cmd.args[1],
cmd.args[3], cmd.args[4]);
ret = -EINVAL;
@@ -137,26 +138,26 @@ static int si2157_init(struct dvb_frontend *fe)
}
 
/* cold state - try to download firmware */
-   dev_info(&dev->client->dev, "found a '%s' in cold state\n",
+   dev_info(&client->dev, "found a '%s' in cold state\n",
si2157_ops.info.name);
 
/* request the firmware, this will block and timeout */
-   ret = request_firmware(&fw, fw_file, &dev->client->dev);
+   ret = request_firmware(&fw, fw_file, &client->dev);
if (ret) {
-   dev_err(&dev->client->dev, "firmware file '%s' not found\n",
+   dev_err(&client->dev, "firmware file '%s' not found\n",
fw_file);
goto err;
   

[PATCH 19/22] si2157: add own goto label for kfree() on probe error

2014-12-06 Thread Antti Palosaari
Use own goto label for error case mem free is needed, even kfree could
be called with NULL. I think it is better to have it, even not required.

Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/si2157.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 211d500..3f9aa7a 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -353,7 +353,7 @@ static int si2157_probe(struct i2c_client *client,
cmd.rlen = 1;
ret = si2157_cmd_execute(client, &cmd);
if (ret)
-   goto err;
+   goto err_kfree;
 
memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops));
fe->tuner_priv = client;
@@ -363,9 +363,11 @@ static int si2157_probe(struct i2c_client *client,
"Si2146" : "Si2147/2148/2157/2158");
 
return 0;
+
+err_kfree:
+   kfree(dev);
 err:
dev_dbg(&client->dev, "failed=%d\n", ret);
-   kfree(dev);
return ret;
 }
 
-- 
http://palosaari.fi/

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


[PATCH 11/22] si2168: remove unneeded fw variable initialization

2014-12-06 Thread Antti Palosaari
commit 034e1ec0ce299b9e90056793dcb3187e7add6b62
si2168: One function call less in si2168_init() after error detection

That commit added goto label for error path to release firmware,
but forgets to remove variable NULL set. Remove those now.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb-frontends/si2168.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index e8e715f..7f20fd0 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -346,7 +346,7 @@ static int si2168_init(struct dvb_frontend *fe)
struct i2c_client *client = fe->demodulator_priv;
struct si2168_dev *dev = i2c_get_clientdata(client);
int ret, len, remaining;
-   const struct firmware *fw = NULL;
+   const struct firmware *fw;
u8 *fw_file;
struct si2168_cmd cmd;
unsigned int chip_id;
@@ -483,7 +483,6 @@ static int si2168_init(struct dvb_frontend *fe)
}
 
release_firmware(fw);
-   fw = NULL;
 
memcpy(cmd.args, "\x01\x01", 2);
cmd.wlen = 2;
-- 
http://palosaari.fi/

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


[PATCH 18/22] si2157: trivial ID table changes

2014-12-06 Thread Antti Palosaari
- Rename ID table.
- Remove magic numbers from ID table driver data field.

Signed-off-by: Antti Palosaari 
---
 drivers/media/tuners/si2157.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 6174c8e..211d500 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -383,12 +383,12 @@ static int si2157_remove(struct i2c_client *client)
return 0;
 }
 
-static const struct i2c_device_id si2157_id[] = {
-   {"si2157", 0},
-   {"si2146", 1},
+static const struct i2c_device_id si2157_id_table[] = {
+   {"si2157", SI2157_CHIPTYPE_SI2157},
+   {"si2146", SI2157_CHIPTYPE_SI2146},
{}
 };
-MODULE_DEVICE_TABLE(i2c, si2157_id);
+MODULE_DEVICE_TABLE(i2c, si2157_id_table);
 
 static struct i2c_driver si2157_driver = {
.driver = {
@@ -397,7 +397,7 @@ static struct i2c_driver si2157_driver = {
},
.probe  = si2157_probe,
.remove = si2157_remove,
-   .id_table   = si2157_id,
+   .id_table   = si2157_id_table,
 };
 
 module_i2c_driver(si2157_driver);
-- 
http://palosaari.fi/

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


[PATCH] mn88472: add 5MHz dvb-t2 bandwitdh support

2014-12-06 Thread Benjamin Larsson
Signed-off-by: Benjamin Larsson 
---
 drivers/staging/media/mn88472/mn88472.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index c6895ee..be8a6d5 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -61,7 +61,10 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
switch (c->delivery_system) {
case SYS_DVBT:
case SYS_DVBT2:
-   if (c->bandwidth_hz <= 600) {
+   if (c->bandwidth_hz <= 500) {
+   memcpy(bw_val, "\xe5\x99\x9a\x1b\xa9\x1b\xa9", 7);
+   bw_val2 = 0x03;
+   } else if (c->bandwidth_hz <= 600) {
/* IF 357 Hz, BW 600 Hz */
memcpy(bw_val, "\xbf\x55\x55\x15\x6b\x15\x6b", 7);
bw_val2 = 0x02;
-- 
1.9.1

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


Re: [PATCH] mn88472: add 5MHz dvb-t2 bandwitdh support

2014-12-06 Thread Antti Palosaari


On 12/06/2014 11:57 PM, Benjamin Larsson wrote:

Signed-off-by: Benjamin Larsson 


Reviewed-by: Antti Palosaari 

Antti


---
  drivers/staging/media/mn88472/mn88472.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/mn88472/mn88472.c 
b/drivers/staging/media/mn88472/mn88472.c
index c6895ee..be8a6d5 100644
--- a/drivers/staging/media/mn88472/mn88472.c
+++ b/drivers/staging/media/mn88472/mn88472.c
@@ -61,7 +61,10 @@ static int mn88472_set_frontend(struct dvb_frontend *fe)
switch (c->delivery_system) {
case SYS_DVBT:
case SYS_DVBT2:
-   if (c->bandwidth_hz <= 600) {
+   if (c->bandwidth_hz <= 500) {
+   memcpy(bw_val, "\xe5\x99\x9a\x1b\xa9\x1b\xa9", 7);
+   bw_val2 = 0x03;
+   } else if (c->bandwidth_hz <= 600) {
/* IF 357 Hz, BW 600 Hz */
memcpy(bw_val, "\xbf\x55\x55\x15\x6b\x15\x6b", 7);
bw_val2 = 0x02;



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


Re: [PATCH for v3.19 0/4] v4l2-mediabus.h & documentation updates

2014-12-06 Thread Sakari Ailus
On Fri, Dec 05, 2014 at 03:19:20PM +0100, Hans Verkuil wrote:
> These patches change the type of the two new fields in struct 
> v4l2_mbus_framefmt
> from __u32 to __u16, as per Sakari's suggestion. We don't need 4 bytes per 
> field
> for this, and this way we save one __u32.
> 
> It also updates docbook with the new fields (I somehow missed that) and
> documents the new vivid controls in vivid.txt.

For the set:

Acked-by: Sakari Ailus 

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


Re: [REVIEW PATCH 1/2] v4l: Add data_offset to struct v4l2_buffer

2014-12-06 Thread Sakari Ailus
Hi Hans,

On Sat, Dec 06, 2014 at 01:05:16PM +0100, Hans Verkuil wrote:
> On 12/06/2014 12:48 PM, Sakari Ailus wrote:
> > Hi Hans,
> > 
> > On Fri, Dec 05, 2014 at 04:10:05PM +0100, Hans Verkuil wrote:
> >> On 12/03/2014 12:14 PM, Sakari Ailus wrote:
> >>> From: Sakari Ailus 
> 
> 
> 
> >> I think we need to add new helper functions that give back the real plane 
> >> size
> >> (i.e. bytesused - data_offset) and the actual plane start position (plane 
> >> start
> >> + data_offset). It will be a bit tricky though to check existing drivers.
> > 
> > I think this mostly applies to OUTPUT buffers.
> > 
> > I find the definition for multi-plane buffers a little bit odd --- why not
> > allow setting this for CAPTURE buffers as well, on hardware that supports
> > it? This makes sense, in order to use the buffers on other interfaces
> > without memory copies this may be even mandatory.
> 
> It's meant for drivers that have a header before the actual image (e.g. sensor
> metadata passed on before the image). Userspace has no control over that, so
> that's why it is set by the driver at capture time.

This depends on hardware actually. Some devices can choose the offset the
data is written to in a buffer, meaning the beginning of the buffer would
not be written to by the hardware.

The "header" is very probably metadata that should be passed to the user
space, but this is out of scope of this discussion.

> > 
> > I wonder if we should change the spec regarding this, even if no driver
> > support was added yet.
> 
> I don't think so. There is a good and clear reason for this.
> 
> > 
> >> AFAICT vivid is one driver that uses vb2_plane_size() to check if enough 
> >> space
> >> is available for the image, but that doesn't take the data_offset into 
> >> account.
> >>
> >> I suspect that similar problems occur for output drivers. And what isn't 
> >> properly
> >> defined at the moment is what should happen if an output driver doesn't 
> >> support
> >> a particular data_offset value.
> >>
> >> I think the only thing you can do in that case is to return an error when 
> >> QBUF
> >> is called.
> > 
> > I'd think so. Same for PREPARE_BUF.
> > 
> > I suppose very few drivers support this at the moment, and the ones that
> > don't would return -EINVAL on QBUF. This could reveal broken user space
> > applications. An alternative would be to silently assign a valid value to
> > the field, but I'm not sure if that's any better.
> 
> I wouldn't do that. In my opinion it is a clear error.

I agree. Anyway some people are quite pedantic about it, however broken this
user space application would be.

-- 
Kind regards,

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


cron job: media_tree daily build: OK

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

Results of the daily build of media_tree:

date:   Sun Dec  7 04:00:16 CET 2014
git branch: test
git hash:   71947828caef0c83d4245f7d1eaddc799b4ff1d1
gcc version:i686-linux-gcc (GCC) 4.9.1
sparse version: v0.5.0-35-gc1c3f96
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:3.17-3.slh.2-amd64

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

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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