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

2015-07-30 Thread Michael Ira Krufky
On Thu, Jul 30, 2015 at 7:14 AM, Michael Ira Krufky mkru...@linuxtv.org wrote:
 On Thu, Jul 30, 2015 at 6:08 AM, Joe Perches j...@perches.com wrote:
 On Thu, 2015-07-30 at 10:47 +0100, Peter Griffin wrote:
 Hi Mauro / Joe,

 On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:

  Em Wed, 24 Jun 2015 18:17:37 -0700
  Joe Perches j...@perches.com escreveu:
 
   On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
This is used in conjunction with the STV0367 demodulator on
the STV0367-NIM-V1.0 NIM card which can be used with the STi
STB SoC's.
  
   Barely associated to this specific patch, but for
   dvb-pll.c, another thing that seems possible is to
   convert the struct dvb_pll_desc uses to const and
   change the entries fixed array size from 12 to []
  
   It'd save a couple KB overall and remove ~5KB of data.
  
   $ size drivers/media/dvb-frontends/dvb-pll.o*
  text  data bss dec hex filename
  8520  15522120   121922fa0 
   drivers/media/dvb-frontends/dvb-pll.o.new
  5624  63632120   14107371b 
   drivers/media/dvb-frontends/dvb-pll.o.old
 
  Peter,
 
  Please add this patch on the next patch series you submit.

 Ok will do, I've added this patch with a slightly updated commit message
 to my series.

 Joe - Can I add your signed-off-by?

 Signed-off-by: Joe Perches j...@perches.com

 Reviewed-by: Michael Ira Krufky m.kru...@samsung.com

 Joe, nice optimization - thanks for that.

 With regards to Peter's patch, is this a digital-only tuner, or is it
 a hybrid tuner?

 The 5th byte that you send to the THOMSON DTT7546X seems to resemble
 the 'auxiliary byte' that gets set in tuner-simple.c

 I'm not sure that dvb-pll is the right place for this tuner
 definition, if this is the case.  Maybe this definition belongs in
 tuner-simple instead, if the pattern matches better there.

 Mauro, can we hold off on merging Peter's patch until we resolve this?

This code block, specifically, I would rather not see added into dvb-pll:

+static int dvb_pll_get_num_regs(struct dvb_pll_priv *priv)
+{
+   int num_regs = 4;
+
+   if (strncmp(priv-pll_desc-name, Thomson dtt7546x, 16) == 0)
+   num_regs = 5;
+
+   return num_regs;
+}
+

tuner-simple provides an infrastructure that allows this tuner to be
added in a more elegant way without the need to add special cases to
otherwise generic code, as done in the above.

I'm sorry, Peter.  Can you take a look at tuner-simple and consider
sending a new patch?

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


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

2015-07-30 Thread Peter Griffin
Hi Michael,

On Thu, 30 Jul 2015, Michael Ira Krufky wrote:

 On Thu, Jul 30, 2015 at 7:14 AM, Michael Ira Krufky mkru...@linuxtv.org 
 wrote:
  On Thu, Jul 30, 2015 at 6:08 AM, Joe Perches j...@perches.com wrote:
  On Thu, 2015-07-30 at 10:47 +0100, Peter Griffin wrote:
  Hi Mauro / Joe,
 
  On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:
 
   Em Wed, 24 Jun 2015 18:17:37 -0700
   Joe Perches j...@perches.com escreveu:
  
On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
 This is used in conjunction with the STV0367 demodulator on
 the STV0367-NIM-V1.0 NIM card which can be used with the STi
 STB SoC's.
   
Barely associated to this specific patch, but for
dvb-pll.c, another thing that seems possible is to
convert the struct dvb_pll_desc uses to const and
change the entries fixed array size from 12 to []
   
It'd save a couple KB overall and remove ~5KB of data.
   
$ size drivers/media/dvb-frontends/dvb-pll.o*
   text  data bss dec hex filename
   8520  15522120   121922fa0 
drivers/media/dvb-frontends/dvb-pll.o.new
   5624  63632120   14107371b 
drivers/media/dvb-frontends/dvb-pll.o.old
  
   Peter,
  
   Please add this patch on the next patch series you submit.
 
  Ok will do, I've added this patch with a slightly updated commit message
  to my series.
 
  Joe - Can I add your signed-off-by?
 
  Signed-off-by: Joe Perches j...@perches.com
 
  Reviewed-by: Michael Ira Krufky m.kru...@samsung.com
 
  Joe, nice optimization - thanks for that.
 
  With regards to Peter's patch, is this a digital-only tuner, or is it
  a hybrid tuner?
 
  The 5th byte that you send to the THOMSON DTT7546X seems to resemble
  the 'auxiliary byte' that gets set in tuner-simple.c
 
  I'm not sure that dvb-pll is the right place for this tuner
  definition, if this is the case.  Maybe this definition belongs in
  tuner-simple instead, if the pattern matches better there.
 
  Mauro, can we hold off on merging Peter's patch until we resolve this?
 
 This code block, specifically, I would rather not see added into dvb-pll:
 
 +static int dvb_pll_get_num_regs(struct dvb_pll_priv *priv)
 +{
 +   int num_regs = 4;
 +
 +   if (strncmp(priv-pll_desc-name, Thomson dtt7546x, 16) == 0)
 +   num_regs = 5;
 +
 +   return num_regs;
 +}
 +
 
 tuner-simple provides an infrastructure that allows this tuner to be
 added in a more elegant way without the need to add special cases to
 otherwise generic code, as done in the above.
 
 I'm sorry, Peter.  Can you take a look at tuner-simple and consider
 sending a new patch?

Yes sure. I wasn't actually aware that tuner-simple existed. From what I
can see briefly looking at it, it does look a more suitable way of adding
support for this tuner.

The dtt7546x is a dual tuner in that it supports dvb-t and dvb-c, however
I have only tested it with DVB-T as that is the only feed I have to my home 
office.

As I have a V2 incorporating all of Mauro's changes ready to send, and I'm 
on holiday for 3 weeks from Friday, I will temporarily drop support for this
tuner and NIM card in V2, and migrate over to the new driver when I return end
of August.

regards,

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


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

2015-07-30 Thread Peter Griffin
Hi Michael,

On Thu, 30 Jul 2015, Michael Ira Krufky wrote:

 On Thu, Jul 30, 2015 at 7:14 AM, Michael Ira Krufky mkru...@linuxtv.org 
 wrote:
  On Thu, Jul 30, 2015 at 6:08 AM, Joe Perches j...@perches.com wrote:
  On Thu, 2015-07-30 at 10:47 +0100, Peter Griffin wrote:
  Hi Mauro / Joe,
 
  On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:
 
   Em Wed, 24 Jun 2015 18:17:37 -0700
   Joe Perches j...@perches.com escreveu:
  
On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
 This is used in conjunction with the STV0367 demodulator on
 the STV0367-NIM-V1.0 NIM card which can be used with the STi
 STB SoC's.
   
Barely associated to this specific patch, but for
dvb-pll.c, another thing that seems possible is to
convert the struct dvb_pll_desc uses to const and
change the entries fixed array size from 12 to []
   
It'd save a couple KB overall and remove ~5KB of data.
   
$ size drivers/media/dvb-frontends/dvb-pll.o*
   text  data bss dec hex filename
   8520  15522120   121922fa0 
drivers/media/dvb-frontends/dvb-pll.o.new
   5624  63632120   14107371b 
drivers/media/dvb-frontends/dvb-pll.o.old
  
   Peter,
  
   Please add this patch on the next patch series you submit.
 
  Ok will do, I've added this patch with a slightly updated commit message
  to my series.
 
  Joe - Can I add your signed-off-by?
 
  Signed-off-by: Joe Perches j...@perches.com
 
  Reviewed-by: Michael Ira Krufky m.kru...@samsung.com
 
  Joe, nice optimization - thanks for that.
 
  With regards to Peter's patch, is this a digital-only tuner, or is it
  a hybrid tuner?
 
  The 5th byte that you send to the THOMSON DTT7546X seems to resemble
  the 'auxiliary byte' that gets set in tuner-simple.c
 
  I'm not sure that dvb-pll is the right place for this tuner
  definition, if this is the case.  Maybe this definition belongs in
  tuner-simple instead, if the pattern matches better there.
 
  Mauro, can we hold off on merging Peter's patch until we resolve this?
 
  -Michael Ira Krufky
 
 eek!  I mispelled my own email address.
 
 
 With regards to Joe's patch - I'd like to see that merged.  ...and
 here is my correctly spelled email address:
 
 
 Reviewed-by: Michael Ira Krufky m.kru...@samsung.com

Ok I will add your reviewed-by and include it in my v2.
--
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] uvcvideo: Disable hardware timestamps by default

2015-07-30 Thread Paul Fertser
Hello Laurent,

I was experimenting with a web-camera integrated in my laptop and was
extremely confused by non-monotonic timestamps coming from the uvc
driver. In fact, the very first timestamp was bigger then the second
every time I tried. This patch helped.

More details:

1. I'm testing with

avconv -f video4linux2 -i /dev/video0 -codec copy test.mkv

2. Prior to applying the patch I was always getting Non-monotonous
DTS in output stream 0:0 errors

3. I'm using kernel version 3.6.8 (yes, that's old, I'm ready to
upgrade if you really need that for debugging)

4. The camera is 5986:0100 Acer, Inc Orbicam

Anything else I can do to help you with this issue? My real usecase is
having a single-board computer capturing a steady stream from a UVC
webcam (h264 pixel format) while keeping timestamps reasonably
accurate (within 0.1s) for the future processing and spending as
little CPU time as possible.

Thank you in advance.
-- 
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:fercer...@gmail.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: [RFC PATCH] lib: scatterlist: add sg splitting function

2015-07-30 Thread Russell King - ARM Linux
On Thu, Jul 30, 2015 at 09:02:15PM +0200, Robert Jarzmik wrote:
 Sometimes a scatter-gather has to be split into several chunks, or sub scatter
 lists. This happens for example if a scatter list will be handled by multiple
 DMA channels, each one filling a part of it.
 
 A concrete example comes with the media V4L2 API, where the scatter list is
 allocated from userspace to hold an image, regardless of the knowledge of how
 many DMAs will fill it :
  - in a simple RGB565 case, one DMA will pump data from the camera ISP to 
 memory
  - in the trickier YUV422 case, 3 DMAs will pump data from the camera ISP 
 pipes,
one for pipe Y, one for pipe U and one for pipe V
 
 For these cases, it is necessary to split the original scatter list into
 multiple scatter lists, which is the purpose of this patch.
 
 The guarantees that are required for this patch are :
  - the intersection of spans of any couple of resulting scatter lists is empty
  - the union of spans of all resulting scatter lists is a subrange of the span
of the original scatter list
  - if streaming DMA API operations (mapping, unmapping) should not happen both
on both the resulting and the original scatter list. It's either the first 
 or
the later ones.

Hmm.

What happens if...

n = dma_map_sg(dev, sg, nents, dir);

where n  nents (which can happen if you have an IOMMU and it coalesces
the entries)?

This also means that sg_dma_len(sg) may not be equal to sg-length, nor
may sg_dma_address(sg) correspond with sg_phys() etc.

 + for_each_sg(in, sg, sg_nents(in), i) {
 + if (skip  sg_dma_len(sg)) {
 + skip -= sg_dma_len(sg);

sg_dma_len() is undefined before the scatterlist is mapped.  Above, you
say that dma map should not happen on both the initial or the subsequently
split scatterlists, but this requires the original to be DMA-mapped.

Also, as I mention above, the number of scatterlist entries to process
is given by 'n' above, not 'nents'.  I'm not sure that there's any
requirement for dma_map_sg() to mark the new end of the scatterlist as
that'd result in information loss when subsequently unmapping.

 + for (i = 0, split = splitters; i  nb_splits; i++, split++) {
 + in_sg = split-in_sg0;
 + out_sg = split-out_sg;
 + out[i] = out_sg;
 + for (j = 0; j  split-nents; j++, out_sg++) {
 + *out_sg = *in_sg;
 + if (!j) {
 + out_sg-offset = split-skip_sg0;
 + sg_dma_len(out_sg) -= split-skip_sg0;
 + } else {
 + out_sg-offset = 0;
 + }
 + in_sg = sg_next(in_sg);
 + }
 + sg_dma_len(--out_sg) = split-len_last_sg;

Hmm, I'm not sure this is good enough.  If we're talking about a mapped
scatterlist, this won't touch the value returned by sg_dma_address() at
all, which will end up being incorrect.

If this is the state of the code in the media subsystem, then it's very
buggy, and in need of fixing.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH] lib: scatterlist: add sg splitting function

2015-07-30 Thread Robert Jarzmik
Russell King - ARM Linux li...@arm.linux.org.uk writes:

 On Thu, Jul 30, 2015 at 09:02:15PM +0200, Robert Jarzmik wrote:
 Hmm.

 What happens if...

   n = dma_map_sg(dev, sg, nents, dir);

 where n  nents (which can happen if you have an IOMMU and it coalesces
 the entries)?
That's something I have not thought of.

My first guess is that if the input scatter list is mapped and entries are
coallesced, then :
 - there are sg entries where the sg_dma_length(sg) is the result of
   coallescing, ie. the sum of sg-length, sg_next(sg)-length, ...
 - the entries sg_next(sg)-length and next coallesced have sg_dma_length() of
   0, or are transformed to sg_chain entries, I don't really know.

I must check how this code resists to these cases, and cross-check in
drivers/iommu if my understanding of coallescing is correct.

 This also means that sg_dma_len(sg) may not be equal to sg-length, nor
 may sg_dma_address(sg) correspond with sg_phys() etc.
Yes, I understand that I think, the length being a consequence of coallescing,
the address being a consequence of a dma bus master offsetting physical 
addresses.

 +for_each_sg(in, sg, sg_nents(in), i) {
 +if (skip  sg_dma_len(sg)) {
 +skip -= sg_dma_len(sg);

 sg_dma_len() is undefined before the scatterlist is mapped.  Above, you
 say that dma map should not happen on both the initial or the subsequently
 split scatterlists, but this requires the original to be DMA-mapped.
Ah that means that the mapping has to be done on the original list the way the
current code is designed. That's actually how this code is exercised in the next
version of pxa_camera.c I'm working on.

It's a bit a pity, I thought I had managed a generic splitter to both mapped and
unmapped scatterlists ... I was obviously wrong.

 Also, as I mention above, the number of scatterlist entries to process
 is given by 'n' above, not 'nents'.
Ah yes. So if I add the requirement that the input scatterlist is mapped, I must
also add a parameter to sg_split() with the number of entries.

 I'm not sure that there's any requirement for dma_map_sg() to mark the new end
 of the scatterlist as that'd result in information loss when subsequently
 unmapping.
If it appears that the only viable way is having the input scatterlist mapped,
this sentence is not applicable, right ?

 +for (i = 0, split = splitters; i  nb_splits; i++, split++) {
 +in_sg = split-in_sg0;
 +out_sg = split-out_sg;
 +out[i] = out_sg;
 +for (j = 0; j  split-nents; j++, out_sg++) {
 +*out_sg = *in_sg;
 +if (!j) {
 +out_sg-offset = split-skip_sg0;
 +sg_dma_len(out_sg) -= split-skip_sg0;
 +} else {
 +out_sg-offset = 0;
 +}
 +in_sg = sg_next(in_sg);
 +}
 +sg_dma_len(--out_sg) = split-len_last_sg;

 Hmm, I'm not sure this is good enough.  If we're talking about a mapped
 scatterlist, this won't touch the value returned by sg_dma_address() at
 all, which will end up being incorrect.
Indeed. That means that in all of my tests, I had probably skip_sg0 == 0,
because otherwise the result would be incorrect.

 If this is the state of the code in the media subsystem, then it's very
 buggy, and in need of fixing.

This is the state of the code I submitted to a single media driver,
pxa_camera. It's a consequence of the pxa shift to dmaengine. And I thought it
would be worth exposing it to more users ... or not, that will depend on this
RFC.

And in the specific case of this pxa driver, it kinda works by luck so far. I
felt it when submitting it here.

Thanks for the review Russell, I have enough to think of and good inputs to
submit an RFCv2 in a couple of days. Even if this patch is dropped in the end,
because it's either too restrictive to force to map the input scatterlist, or
because it won't be that usefull, I will have a cleaner code in pxa_camera :)

Cheers.

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


[PATCHv3 01/13] v4l2: rename V4L2_TUNER_ADC to V4L2_TUNER_SDR

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

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

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

[PATCHv3 09/13] hackrf: switch to single function which configures everything

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

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

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

[PATCHv3 03/13] DocBook: document tuner RF gain control

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

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

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index f56faf5..eb091c7 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2600,6 +2600,10 @@ and v4l2-mbus-framefmt;.
 constantV4L2_TUNER_ADC/constant is deprecated now.
  /para
/listitem
+   listitem
+ paraAdded constantV4L2_CID_RF_TUNER_RF_GAIN/constant
+RF Tuner control./para
+   /listitem
   /orderedlist
 /section
 
diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 6e1667b..7cae933 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -5418,6 +5418,18 @@ set. Unit is in Hz. The range and step are 
driver-specific./entry
   entry spanname=descrEnables/disables IF automatic gain 
control (AGC)/entry
 /row
 row
+  entry 
spanname=idconstantV4L2_CID_RF_TUNER_RF_GAIN/constantnbsp;/entry
+  entryinteger/entry
+/row
+row
+  entry spanname=descrThe RF amplifier is the very first
+amplifier on the receiver signal path, just right after the antenna input.
+The difference between the LNA gain and the RF gain in this document is that
+the LNA gain is integrated in the tuner chip while the RF gain is a separate
+chip. There may be both RF and LNA gain controls in the same device.
+The range and step are driver-specific./entry
+/row
+row
   entry 
spanname=idconstantV4L2_CID_RF_TUNER_LNA_GAIN/constantnbsp;/entry
   entryinteger/entry
 /row
@@ -5425,6 +5437,8 @@ set. Unit is in Hz. The range and step are 
driver-specific./entry
   entry spanname=descrLNA (low noise amplifier) gain is first
 gain stage on the RF tuner signal path. It is located very close to tuner
 antenna input. Used when constantV4L2_CID_RF_TUNER_LNA_GAIN_AUTO/constant 
is not set.
+See constantV4L2_CID_RF_TUNER_RF_GAIN/constant to understand how RF gain
+and LNA gain differs from the each others.
 The range and step are driver-specific./entry
 /row
 row
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml 
b/Documentation/DocBook/media/v4l/v4l2.xml
index c9eedc1..ab9fca4 100644
--- a/Documentation/DocBook/media/v4l/v4l2.xml
+++ b/Documentation/DocBook/media/v4l/v4l2.xml
@@ -156,6 +156,7 @@ applications. --
date2015-05-26/date
authorinitialsap/authorinitials
revremarkRenamed V4L2_TUNER_ADC to V4L2_TUNER_SDR.
+Added V4L2_CID_RF_TUNER_RF_GAIN control.
/revremark
   /revision
 
-- 
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


[PATCHv3 10/13] hackrf: add support for transmitter

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

Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/usb/hackrf/hackrf.c | 894 ++
 1 file changed, 627 insertions(+), 267 deletions(-)

diff --git a/drivers/media/usb/hackrf/hackrf.c 
b/drivers/media/usb/hackrf/hackrf.c
index 5bd291b..f4b5606 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -34,6 +34,7 @@ enum {
CMD_AMP_ENABLE = 0x11,
CMD_SET_LNA_GAIN   = 0x13,
CMD_SET_VGA_GAIN   = 0x14,
+   CMD_SET_TXVGA_GAIN = 0x15,
 };
 
 /*
@@ -44,10 +45,10 @@ enum {
 #define MAX_BULK_BUFS(6)
 #define BULK_BUFFER_SIZE (128 * 512)
 
-static const struct v4l2_frequency_band bands_adc[] = {
+static const struct v4l2_frequency_band bands_adc_dac[] = {
{
.tuner = 0,
-   .type = V4L2_TUNER_ADC,
+   .type = V4L2_TUNER_SDR,
.index = 0,
.capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
.rangelow   =   20,
@@ -55,7 +56,7 @@ static const struct v4l2_frequency_band bands_adc[] = {
},
 };
 
-static const struct v4l2_frequency_band bands_rf[] = {
+static const struct v4l2_frequency_band bands_rx_tx[] = {
{
.tuner = 1,
.type = V4L2_TUNER_RF,
@@ -85,34 +86,44 @@ static struct hackrf_format formats[] = {
 static const unsigned int NUM_FORMATS = ARRAY_SIZE(formats);
 
 /* intermediate buffers with raw data from the USB device */
-struct hackrf_frame_buf {
-   struct vb2_buffer vb;   /* common v4l buffer stuff -- must be first */
+struct hackrf_buffer {
+   struct vb2_buffer vb;
struct list_head list;
 };
 
 struct hackrf_dev {
-#define POWER_ON 1
-#define USB_STATE_URB_BUF2 /* XXX: set manually */
-#define SAMPLE_RATE_SET 10
-#define RX_BANDWIDTH11
-#define RX_RF_FREQUENCY 12
-#define RX_RF_GAIN  13
-#define RX_LNA_GAIN 14
-#define RX_IF_GAIN  15
+#define USB_STATE_URB_BUF1 /* XXX: set manually */
+#define RX_ON4
+#define TX_ON5
+#define RX_ADC_FREQUENCY11
+#define TX_DAC_FREQUENCY12
+#define RX_BANDWIDTH13
+#define TX_BANDWIDTH14
+#define RX_RF_FREQUENCY 15
+#define TX_RF_FREQUENCY 16
+#define RX_RF_GAIN  17
+#define TX_RF_GAIN  18
+#define RX_IF_GAIN  19
+#define RX_LNA_GAIN 20
+#define TX_LNA_GAIN 21
unsigned long flags;
 
struct usb_interface *intf;
struct device *dev;
struct usb_device *udev;
-   struct video_device vdev;
+   struct video_device rx_vdev;
+   struct video_device tx_vdev;
struct v4l2_device v4l2_dev;
 
/* videobuf2 queue and queued buffers list */
-   struct vb2_queue vb_queue;
-   struct list_head queued_bufs;
-   spinlock_t queued_bufs_lock; /* Protects queued_bufs */
+   struct vb2_queue rx_vb2_queue;
+   struct vb2_queue tx_vb2_queue;
+   struct list_head rx_buffer_list;
+   struct list_head tx_buffer_list;
+   spinlock_t buffer_list_lock; /* Protects buffer_list */
unsigned sequence;   /* Buffer sequence counter */
unsigned int vb_full;/* vb is full and packets dropped */
+   unsigned int vb_empty;   /* vb is empty and packets dropped */
 
/* Note if taking both locks v4l2_lock must always be locked first! */
struct mutex v4l2_lock;  /* Protects everything else */
@@ -132,17 +143,24 @@ struct hackrf_dev {
 
/* Current configuration */
unsigned int f_adc;
-   unsigned int f_rf;
+   unsigned int f_dac;
+   unsigned int f_rx;
+   unsigned int f_tx;
u32 pixelformat;
u32 buffersize;
 
/* Controls */
-   struct v4l2_ctrl_handler hdl;
-   struct v4l2_ctrl *bandwidth_auto;
-   struct v4l2_ctrl *bandwidth;
-   struct v4l2_ctrl *rf_gain;
-   struct v4l2_ctrl *lna_gain;
-   struct v4l2_ctrl *if_gain;
+   struct v4l2_ctrl_handler rx_ctrl_handler;
+   struct v4l2_ctrl *rx_bandwidth_auto;
+   struct v4l2_ctrl *rx_bandwidth;
+   struct v4l2_ctrl *rx_rf_gain;
+   struct v4l2_ctrl *rx_lna_gain;
+   struct v4l2_ctrl *rx_if_gain;
+   struct v4l2_ctrl_handler tx_ctrl_handler;
+   struct v4l2_ctrl 

[PATCHv3 12/13] DocBook: fix S_FREQUENCY = G_FREQUENCY

2015-07-30 Thread Antti Palosaari
It is VIDIOC_G_FREQUENCY which does not use type to identify tuner,
not VIDIOC_S_FREQUENCY. VIDIOC_S_FREQUENCY uses both tuner and type
fields. One of these V4L API weirdness...

Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 Documentation/DocBook/media/v4l/common.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/common.xml 
b/Documentation/DocBook/media/v4l/common.xml
index 8b5e014..f7008ea 100644
--- a/Documentation/DocBook/media/v4l/common.xml
+++ b/Documentation/DocBook/media/v4l/common.xml
@@ -428,7 +428,7 @@ zero, no video outputs./para
 modulator. Two separate device nodes will have to be used for such
 hardware, one that supports the tuner functionality and one that supports
 the modulator functionality. The reason is a limitation with the
-VIDIOC-S-FREQUENCY; ioctl where you cannot specify whether the frequency
+VIDIOC-G-FREQUENCY; ioctl where you cannot specify whether the frequency
 is for a tuner or a modulator./para
 
   paraTo query and change modulator properties applications use
-- 
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


[PATCHv3 13/13] DocBook: add tuner types SDR and RF for G_TUNER / S_TUNER

2015-07-30 Thread Antti Palosaari
Add V4L2_TUNER_SDR and V4L2_TUNER_RF to supported tuner types to
table.

Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 Documentation/DocBook/media/v4l/vidioc-g-tuner.xml | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
index b0d8659..10737a1 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml
@@ -261,6 +261,16 @@ applications must set the array to zero./entry
entry2/entry
entry/entry
  /row
+ row
+   entryconstantV4L2_TUNER_SDR/constant/entry
+   entry4/entry
+   entry/entry
+ /row
+ row
+   entryconstantV4L2_TUNER_RF/constant/entry
+   entry5/entry
+   entry/entry
+ /row
/tbody
   /tgroup
 /table
-- 
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


[PATCHv3 04/13] v4l2: add support for SDR transmitter

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

New vb2 buffertype:
V4L2_BUF_TYPE_SDR_OUTPUT

New v4l2 capability:
V4L2_CAP_SDR_OUTPUT

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

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

[PATCHv3 05/13] DocBook: document SDR transmitter

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

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

diff --git a/Documentation/DocBook/media/v4l/compat.xml 
b/Documentation/DocBook/media/v4l/compat.xml
index eb091c7..f534fc5 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2604,6 +2604,10 @@ and v4l2-mbus-framefmt;.
  paraAdded constantV4L2_CID_RF_TUNER_RF_GAIN/constant
 RF Tuner control./para
/listitem
+   listitem
+ paraAdded transmitter support for Software Defined Radio (SDR)
+Interface./para
+   /listitem
   /orderedlist
 /section
 
diff --git a/Documentation/DocBook/media/v4l/dev-sdr.xml 
b/Documentation/DocBook/media/v4l/dev-sdr.xml
index 3344921..a659771 100644
--- a/Documentation/DocBook/media/v4l/dev-sdr.xml
+++ b/Documentation/DocBook/media/v4l/dev-sdr.xml
@@ -28,6 +28,16 @@ Devices supporting the SDR receiver interface set the
 structfieldcapabilities/structfield field of v4l2-capability;
 returned by the VIDIOC-QUERYCAP; ioctl. That flag means the device has an
 Analog to Digital Converter (ADC), which is a mandatory element for the SDR 
receiver.
+/para
+para
+Devices supporting the SDR transmitter interface set the
+constantV4L2_CAP_SDR_OUTPUT/constant and
+constantV4L2_CAP_MODULATOR/constant flag in the
+structfieldcapabilities/structfield field of v4l2-capability;
+returned by the VIDIOC-QUERYCAP; ioctl. That flag means the device has an
+Digital to Analog Converter (DAC), which is a mandatory element for the SDR 
transmitter.
+/para
+para
 At least one of the read/write, streaming or asynchronous I/O methods must
 be supported.
 /para
@@ -39,14 +49,15 @@ be supported.
 para
 SDR devices can support link linkend=controlcontrols/link, and must
 support the link linkend=tunertuner/link ioctls. Tuner ioctls are used
-for setting the ADC sampling rate (sampling frequency) and the possible RF 
tuner
-frequency.
+for setting the ADC/DAC sampling rate (sampling frequency) and the possible
+radio frequency (RF).
 /para
 
 para
-The constantV4L2_TUNER_SDR/constant tuner type is used for SDR tuners, and
-the constantV4L2_TUNER_RF/constant tuner type is used for RF tuners. The
-tuner index of the RF tuner (if any) must always follow the SDR tuner index.
+The constantV4L2_TUNER_SDR/constant tuner type is used for setting SDR
+device ADC/DAC frequency, and the constantV4L2_TUNER_RF/constant
+tuner type is used for setting radio frequency.
+The tuner index of the RF tuner (if any) must always follow the SDR tuner 
index.
 Normally the SDR tuner is #0 and the RF tuner is #1.
 /para
 
@@ -59,9 +70,9 @@ The VIDIOC-S-HW-FREQ-SEEK; ioctl is not supported.
 titleData Format Negotiation/title
 
 para
-The SDR capture device uses the link linkend=formatformat/link ioctls to
-select the capture format. Both the sampling resolution and the data streaming
-format are bound to that selectable format. In addition to the basic
+The SDR device uses the link linkend=formatformat/link ioctls to
+select the capture and output format. Both the sampling resolution and the data
+streaming format are bound to that selectable format. In addition to the basic
 link linkend=formatformat/link ioctls, the VIDIOC-ENUM-FMT; ioctl
 must be supported as well.
 /para
@@ -69,7 +80,8 @@ must be supported as well.
 para
 To use the link linkend=formatformat/link ioctls applications set the
 structfieldtype/structfield field of a v4l2-format; to
-constantV4L2_BUF_TYPE_SDR_CAPTURE/constant and use the v4l2-sdr-format;
+constantV4L2_BUF_TYPE_SDR_CAPTURE/constant or
+constantV4L2_BUF_TYPE_SDR_OUTPUT/constant and use the v4l2-sdr-format;
 structfieldsdr/structfield member of the structfieldfmt/structfield
 union as needed per the desired operation.
 Currently there is two fields, structfieldpixelformat/structfield and
diff --git a/Documentation/DocBook/media/v4l/io.xml 
b/Documentation/DocBook/media/v4l/io.xml
index 7bbc2a4..da65403 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -1006,8 +1006,14 @@ must set this to 0./entry
  row
entryconstantV4L2_BUF_TYPE_SDR_CAPTURE/constant/entry
entry11/entry
-   entryBuffer for Software Defined Radio (SDR), see xref
-   linkend=sdr /./entry
+   entryBuffer for Software Defined Radio (SDR) capture 

[PATCHv3 06/13] v4l: add type field to v4l2_modulator struct

2015-07-30 Thread Antti Palosaari
Add type field to that struct like it counterpart v4l2_tuner
already has. We need type field to distinguish different tuner
types from each others for transmitter too.

Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 18 +-
 include/uapi/linux/videodev2.h   |  3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 21e9598..85f80cb 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1646,15 +1646,31 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops,
 static int v4l_g_modulator(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
 {
+   struct video_device *vfd = video_devdata(file);
struct v4l2_modulator *p = arg;
int err;
 
+   if (vfd-vfl_type == VFL_TYPE_RADIO)
+   p-type = V4L2_TUNER_RADIO;
+
err = ops-vidioc_g_modulator(file, fh, p);
if (!err)
p-capability |= V4L2_TUNER_CAP_FREQ_BANDS;
return err;
 }
 
+static int v4l_s_modulator(const struct v4l2_ioctl_ops *ops,
+   struct file *file, void *fh, void *arg)
+{
+   struct video_device *vfd = video_devdata(file);
+   struct v4l2_modulator *p = arg;
+
+   if (vfd-vfl_type == VFL_TYPE_RADIO)
+   p-type = V4L2_TUNER_RADIO;
+
+   return ops-vidioc_s_modulator(file, fh, p);
+}
+
 static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
 {
@@ -2441,7 +2457,7 @@ static struct v4l2_ioctl_info v4l2_ioctls[] = {
IOCTL_INFO_STD(VIDIOC_G_AUDOUT, vidioc_g_audout, v4l_print_audioout, 0),
IOCTL_INFO_STD(VIDIOC_S_AUDOUT, vidioc_s_audout, v4l_print_audioout, 
INFO_FL_PRIO),
IOCTL_INFO_FNC(VIDIOC_G_MODULATOR, v4l_g_modulator, 
v4l_print_modulator, INFO_FL_CLEAR(v4l2_modulator, index)),
-   IOCTL_INFO_STD(VIDIOC_S_MODULATOR, vidioc_s_modulator, 
v4l_print_modulator, INFO_FL_PRIO),
+   IOCTL_INFO_FNC(VIDIOC_S_MODULATOR, v4l_s_modulator, 
v4l_print_modulator, INFO_FL_PRIO),
IOCTL_INFO_FNC(VIDIOC_G_FREQUENCY, v4l_g_frequency, 
v4l_print_frequency, INFO_FL_CLEAR(v4l2_frequency, tuner)),
IOCTL_INFO_FNC(VIDIOC_S_FREQUENCY, v4l_s_frequency, 
v4l_print_frequency, INFO_FL_PRIO),
IOCTL_INFO_FNC(VIDIOC_CROPCAP, v4l_cropcap, v4l_print_cropcap, 
INFO_FL_CLEAR(v4l2_cropcap, type)),
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 70f06c9..3a8eb8e 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -1584,7 +1584,8 @@ struct v4l2_modulator {
__u32   rangelow;
__u32   rangehigh;
__u32   txsubchans;
-   __u32   reserved[4];
+   __u32   type;   /* enum v4l2_tuner_type */
+   __u32   reserved[3];
 };
 
 /*  Flags for the 'capability' field */
-- 
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


[PATCHv3 11/13] hackrf: do not set human readable name for formats

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

Signed-off-by: Antti Palosaari cr...@iki.fi
Acked-by: Hans Verkuil hans.verk...@cisco.com
---
 drivers/media/usb/hackrf/hackrf.c | 3 ---
 1 file changed, 3 deletions(-)

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

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


[PATCHv3 07/13] DocBook: add modulator type field

2015-07-30 Thread Antti Palosaari
Add new modulator type field to documentation.

Cc: Hans Verkuil hverk...@xs4all.nl
Signed-off-by: Antti Palosaari cr...@iki.fi
---
 Documentation/DocBook/media/v4l/vidioc-g-modulator.xml | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml 
b/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
index 7068b59..fe4230c 100644
--- a/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-g-modulator.xml
@@ -140,7 +140,13 @@ indicator, for example a stereo pilot tone./entry
  /row
  row
entry__u32/entry
-   entrystructfieldreserved/structfield[4]/entry
+   entrystructfieldtype/structfield/entry
+   entry spanname=hspanType of the tuner, see xref
+   linkend=v4l2-tuner-type /./entry
+ /row
+ row
+   entry__u32/entry
+   entrystructfieldreserved/structfield[3]/entry
entryReserved for future extensions. Drivers and
 applications must set the array to zero./entry
  /row
-- 
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


[PATCHv3 08/13] hackrf: add control for RF amplifier

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

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

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

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


[PATCHv3 02/13] v4l2: add RF gain control

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

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

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

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


[PATCHv3 00/13] SDR transmitter API

2015-07-30 Thread Antti Palosaari
v3:
* some documentation addons

* added type field to v4l2 modulator struct

* hackrf: fix querycap capabilities

* hackrf: remove another v4l2_device struct

* hackrf: fix / moved RX/TX busy check to start streaming

* hackrf: some other minor changes

Those fixes were the ones Hans pointed out, thanks. Some documentation is still 
TODO.

Passes v4l2-compliance otherwise than new modulator type field.

Output ioctls:
fail: v4l2-test-input-output.cpp(576): non-zero reserved fields
fail: v4l2-test-input-output.cpp(640): invalid modulator 0
test VIDIOC_G/S_MODULATOR: FAIL
fail: v4l2-test-input-output.cpp(729): could get frequency for invalid 
modulator 0
test VIDIOC_G/S_FREQUENCY: FAIL


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

* Removed V4L2_CID_RF_TUNER_RF_GAIN_AUTO control as it was not used.

* Changed RF gain documentation.


Antti Palosaari (13):
  v4l2: rename V4L2_TUNER_ADC to V4L2_TUNER_SDR
  v4l2: add RF gain control
  DocBook: document tuner RF gain control
  v4l2: add support for SDR transmitter
  DocBook: document SDR transmitter
  v4l: add type field to v4l2_modulator struct
  DocBook: add modulator type field
  hackrf: add control for RF amplifier
  hackrf: switch to single function which configures everything
  hackrf: add support for transmitter
  hackrf: do not set human readable name for formats
  DocBook: fix S_FREQUENCY = G_FREQUENCY
  DocBook: add tuner types SDR and RF for G_TUNER / S_TUNER

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

-- 
http://palosaari.fi/

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


cron job: media_tree daily build: OK

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

Results of the daily build of media_tree:

date:   Fri Jul 31 04:00:17 CEST 2015
git branch: test
git hash:   4dc102b2f53d63207fa12a6ad49c7b6448bc3301
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0-51-ga53cea2
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:4.0.0-3.slh.1-amd64

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

Detailed results are available here:

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

Full logs are available here:

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

The Media Infrastructure API from this daily build is here:

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


Re: [PATCH 1/2] media: atmel-isi: setup the ISI_CFG2 register directly

2015-07-30 Thread Josh Wu

Hi, list

Ping..., any feedback for this series?

Best Regards,
Josh Wu

On 6/17/2015 6:39 PM, Josh Wu wrote:

In the function configure_geometry(), we will setup the ISI CFG2
according to the sensor output format.

It make no sense to just read back the CFG2 register and just set part
of it.

So just set up this register directly makes things simpler.
Currently only support YUV format from camera sensor.

Signed-off-by: Josh Wu josh...@atmel.com
---

  drivers/media/platform/soc_camera/atmel-isi.c | 20 +++-
  1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/soc_camera/atmel-isi.c 
b/drivers/media/platform/soc_camera/atmel-isi.c
index 9070172..8bc40ca 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -105,24 +105,25 @@ static u32 isi_readl(struct atmel_isi *isi, u32 reg)
  static int configure_geometry(struct atmel_isi *isi, u32 width,
u32 height, u32 code)
  {
-   u32 cfg2, cr;
+   u32 cfg2;
  
+	/* According to sensor's output format to set cfg2 */

switch (code) {
/* YUV, including grey */
case MEDIA_BUS_FMT_Y8_1X8:
-   cr = ISI_CFG2_GRAYSCALE;
+   cfg2 = ISI_CFG2_GRAYSCALE;
break;
case MEDIA_BUS_FMT_VYUY8_2X8:
-   cr = ISI_CFG2_YCC_SWAP_MODE_3;
+   cfg2 = ISI_CFG2_YCC_SWAP_MODE_3;
break;
case MEDIA_BUS_FMT_UYVY8_2X8:
-   cr = ISI_CFG2_YCC_SWAP_MODE_2;
+   cfg2 = ISI_CFG2_YCC_SWAP_MODE_2;
break;
case MEDIA_BUS_FMT_YVYU8_2X8:
-   cr = ISI_CFG2_YCC_SWAP_MODE_1;
+   cfg2 = ISI_CFG2_YCC_SWAP_MODE_1;
break;
case MEDIA_BUS_FMT_YUYV8_2X8:
-   cr = ISI_CFG2_YCC_SWAP_DEFAULT;
+   cfg2 = ISI_CFG2_YCC_SWAP_DEFAULT;
break;
/* RGB, TODO */
default:
@@ -130,17 +131,10 @@ static int configure_geometry(struct atmel_isi *isi, u32 
width,
}
  
  	isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);

-
-   cfg2 = isi_readl(isi, ISI_CFG2);
-   /* Set YCC swap mode */
-   cfg2 = ~ISI_CFG2_YCC_SWAP_MODE_MASK;
-   cfg2 |= cr;
/* Set width */
-   cfg2 = ~(ISI_CFG2_IM_HSIZE_MASK);
cfg2 |= ((width - 1)  ISI_CFG2_IM_HSIZE_OFFSET) 
ISI_CFG2_IM_HSIZE_MASK;
/* Set height */
-   cfg2 = ~(ISI_CFG2_IM_VSIZE_MASK);
cfg2 |= ((height - 1)  ISI_CFG2_IM_VSIZE_OFFSET)
 ISI_CFG2_IM_VSIZE_MASK;
isi_writel(isi, ISI_CFG2, cfg2);


--
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 00/27] Export I2C and OF module aliases in missing drivers

2015-07-30 Thread Dmitry Torokhov
On Thu, Jul 30, 2015 at 09:35:17AM -0700, Dmitry Torokhov wrote:
 Hi Javier,
 
 On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
  Hello,
  
  Short version:
  
  This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
  to export that information so modules have the correct aliases built-in
  and autoloading works correctly.
  
  Longer version:
  
  Currently it's mandatory for I2C drivers to have an I2C device ID table
  regardless if the device was registered using platform data or OF. This
  is because the I2C core needs an I2C device ID table for two reasons:
  
  1) Match the I2C client with a I2C device ID so a struct i2c_device_id
 is passed to the I2C driver probe() function.
  
  2) Export the module aliases from the I2C device ID table so userspace
 can auto-load the correct module. This is because i2c_device_uevent
 always reports a MODALIAS of the form i2c:client-name.
 
 Why are we not fixing this? We emit specially carved uevent for
 ACPI-based devices, why not the same for OF? Platform bus does this...

Ah, now I see the 27/27 patch. I think it is exactly what we need. And
probably for SPI bus as well.

Thanks.

-- 
Dmitry
--
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 24/27] [media] smiapp: Export OF module alias information

2015-07-30 Thread Javier Martinez Canillas
The I2C core always reports the MODALIAS uevent as i2c:client name
regardless if the driver was matched using the I2C id_table or the
of_match_table. So technically there's no need for a driver to export
the OF table since currently it's not used.

In fact, the I2C device ID table is mandatory for I2C drivers since
a i2c_device_id is passed to the driver's probe function even if the
I2C core used the OF table to match the driver.

And since the I2C core uses different tables, OF-only drivers needs to
have duplicated data that has to be kept in sync and also the dev node
compatible manufacturer prefix is stripped when reporting the MODALIAS.

To avoid the above, the I2C core behavior may be changed in the future
to not require an I2C device table for OF-only drivers and report the
OF module alias. So, it's better to also export the OF table to prevent
breaking module autoloading if that happens.

Signed-off-by: Javier Martinez Canillas jav...@osg.samsung.com

---

 drivers/media/i2c/smiapp/smiapp-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 636ebd6fe5dc..fb39dfd55e75 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -3131,6 +3131,7 @@ static const struct of_device_id smiapp_of_table[] = {
{ .compatible = nokia,smia },
{ },
 };
+MODULE_DEVICE_TABLE(of, smiapp_of_table);
 
 static const struct i2c_device_id smiapp_id_table[] = {
{ SMIAPP_NAME, 0 },
-- 
2.4.3

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


[PATCH v2 01/11] [media] stv0367: Refine i2c error trace to include i2c address

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

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

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

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

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

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


Re: [PATCH 00/27] Export I2C and OF module aliases in missing drivers

2015-07-30 Thread Javier Martinez Canillas
Hello Dmitry,

Thanks a lot for your feedback.

On 07/30/2015 06:37 PM, Dmitry Torokhov wrote:
 On Thu, Jul 30, 2015 at 09:35:17AM -0700, Dmitry Torokhov wrote:
 Hi Javier,

 On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
 Hello,

 Short version:

 This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
 to export that information so modules have the correct aliases built-in
 and autoloading works correctly.

 Longer version:

 Currently it's mandatory for I2C drivers to have an I2C device ID table
 regardless if the device was registered using platform data or OF. This
 is because the I2C core needs an I2C device ID table for two reasons:

 1) Match the I2C client with a I2C device ID so a struct i2c_device_id
is passed to the I2C driver probe() function.

 2) Export the module aliases from the I2C device ID table so userspace
can auto-load the correct module. This is because i2c_device_uevent
always reports a MODALIAS of the form i2c:client-name.

 Why are we not fixing this? We emit specially carved uevent for
 ACPI-based devices, why not the same for OF? Platform bus does this...
 
 Ah, now I see the 27/27 patch. I think it is exactly what we need. And

Yes, patch 27/27 is needed but the problem is as I explained before that
there are drivers relying on the current behavior. The item c) in the list
of issues that I mentioned. So those drivers need to be fixed before that
patch is merged...

 probably for SPI bus as well.


Yes, I didn't mention SPI because the cover letter became too long
already but it does indeed have the same issue and I discussed this
with  Mark already some time ago [0].

Once I2C uevent report is fixed, I plan to do the same for SPI.

 Thanks.
 

[0]: https://lkml.org/lkml/2014/9/11/458

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 03/11] dvb-pll: Convert struct dvb_pll_desc uses to const.

2015-07-30 Thread Peter Griffin
From: Joe Perches j...@perches.com

Convert the struct dvb_pll_desc uses to const and
change the entries fixed array size from 12 to []

It saves a couple KB overall and remove ~5KB of data.

$ size drivers/media/dvb-frontends/dvb-pll.o*
   textdata bss dec hex filename
   852015522120   121922fa0 
drivers/media/dvb-frontends/dvb-pll.o.new
   562463632120   14107371b 
drivers/media/dvb-frontends/dvb-pll.o.old

[PG] Patch taken from https://lkml.org/lkml/2015/6/24/721 with
commit message updated.

Signed-off-by: Joe Perches j...@perches.com
Signed-off-by: Peter Griffin peter.grif...@linaro.org
Reviewed-by: Michael Ira Krufky m.kru...@samsung.com
---
 drivers/media/dvb-frontends/dvb-pll.c | 50 +--
 1 file changed, 25 insertions(+), 25 deletions(-)

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

[PATCH v2 00/11] Add c8sectpfe LinuxDVB demux driver

2015-07-30 Thread Peter Griffin
Hi Maruro and linux-media folks,

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

One big advantage of having a upstream demux driver for ST
SoC's is that it will be easier to maintain support for the ST demodulators
and tuners which are already upstream (and also add support for newer demods
such as the stv6120 and stv910). As this driver allows ST NIM reference boards
(which typically have a tuner/demod combination on)
to be used easily with a upstream kernel on ST STB reference designs.

Up until now it is not easy to test stv0367, stv6110 stv90x.c demod and tuner
drivers which are supported upstream with ST STB reference hardware,
and as such makes helping support these devices difficult.

It also furthers the aim of having a completely open source A/V pipeline for STi
chipsets. A upstream DRM driver is already merged for STi SoC's. ALSA SoC is
current under review, and when this driver is accepted we would have a totaly
open source frontend support (tuner-demod-demux) :-)

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

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

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

This patchset also includes some small changes to stv0367.c to get
the upstream driver working correctly with the ST NIM reference board. Also Joe
Perches dvb-pll patch is included with this series.

regards,

Peter.

Changes since v1:
- Rebase patches on v4.2-rc3 (Peter)
- Rework firmware loading mechanism to be async (Peter)
- Rework ELF firmware loading code (Peter)
- Add support for 8192 special PID (Peter)
- Fixup Kconfig depedencies for c8sectpfe (Peter)
- Fix typo in Makefile rule for c8sectpfe-debugfs (Paul)

- Include Joe Perches dvb-pll patch as requested by (Mauro)
- Remove BUG_ON from various places (Mauro)
- Drop THOMSON DTT7546X tuner support (rework based on tuner-simple later) 
(Mike)
- Move driver to drivers/media/platform/sti/c8sectpfe/
- usleep_range instead of msleep (Mauro)

Joe Perches (1):
  dvb-pll: Convert struct dvb_pll_desc uses to const.

Peter Griffin (10):
  [media] stv0367: Refine i2c error trace to include i2c address
  [media] stv0367: Add support for 16Mhz reference clock
  [media] c8sectpfe: Add DT bindings documentation for c8sectpfe driver.
  ARM: DT: STi: STiH407: Add c8sectpfe LinuxDVB DT node.
  [media] c8sectpfe: STiH407/10 Linux DVB demux support
  [media] c8sectpfe: Add LDVB helper functions.
  [media] c8sectpfe: Add support for various ST NIM cards.
  [media] c8sectpfe: Add c8sectpfe debugfs support.
  [media] c8sectpfe: Add Kconfig and Makefile for the driver.
  MAINTAINERS: Add c8sectpfe driver directory to STi section

 .../bindings/media/stih407-c8sectpfe.txt   |   89 ++
 MAINTAINERS|1 +
 arch/arm/boot/dts/stihxxx-b2120.dtsi   |   38 +
 drivers/media/dvb-frontends/dvb-pll.c  |   50 +-
 drivers/media/dvb-frontends/stv0367.c  |   17 +-
 drivers/media/platform/Kconfig |4 +-
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/sti/c8sectpfe/Kconfig   |   28 +
 drivers/media/platform/sti/c8sectpfe/Makefile  |9 +
 .../platform/sti/c8sectpfe/c8sectpfe-common.c  |  265 +
 .../platform/sti/c8sectpfe/c8sectpfe-common.h  |   64 +
 .../media/platform/sti/c8sectpfe/c8sectpfe-core.c  | 1235 
 .../media/platform/sti/c8sectpfe/c8sectpfe-core.h  |  288 +
 .../platform/sti/c8sectpfe/c8sectpfe-debugfs.c |  271 +
 .../platform/sti/c8sectpfe/c8sectpfe-debugfs.h |   26 +
 .../media/platform/sti/c8sectpfe/c8sectpfe-dvb.c   |  244 
 .../media/platform/sti/c8sectpfe/c8sectpfe-dvb.h   |   20 +
 include/dt-bindings/media/c8sectpfe.h  |   12 +
 18 files changed, 2632 insertions(+), 30 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
 create mode 100644 drivers/media/platform/sti/c8sectpfe/Kconfig
 create mode 100644 drivers/media/platform/sti/c8sectpfe/Makefile
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.h
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h
 create mode 100644 

[PATCH v2 02/11] [media] stv0367: Add support for 16Mhz reference clock

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

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

diff --git a/drivers/media/dvb-frontends/stv0367.c 
b/drivers/media/dvb-frontends/stv0367.c
index 9a49db1..44cb73f 100644
--- a/drivers/media/dvb-frontends/stv0367.c
+++ b/drivers/media/dvb-frontends/stv0367.c
@@ -1554,6 +1554,11 @@ static int stv0367ter_init(struct dvb_frontend *fe)
 
switch (state-config-xtal) {
/*set internal freq to 53.125MHz */
+   case 1600:
+   stv0367_writereg(state, R367TER_PLLMDIV, 0x2);
+   stv0367_writereg(state, R367TER_PLLNDIV, 0x1b);
+   stv0367_writereg(state, R367TER_PLLSETUP, 0x18);
+   break;
case 2500:
stv0367_writereg(state, R367TER_PLLMDIV, 0xa);
stv0367_writereg(state, R367TER_PLLNDIV, 0x55);
-- 
1.9.1

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


[PATCH 27/27] i2c: (RFC, don't apply) report OF style modalias when probing using DT

2015-07-30 Thread Javier Martinez Canillas
An I2C driver that supports both OF and legacy platforms, will have
both a OF and I2C ID table. This means that when built as a module,
the aliases will be filled from both tables but currently always an
alias of the form i2c:deviceId is reported, e.g:

$ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
i2c:maxtouch

So if a device is probed by matching its compatible string, udev can
get a MODALIAS uevent env var that doesn't match with one of the valid
aliases so the module won't be auto-loaded.

This patch changes the I2C core to report a OF related MODALIAS uevent
(of:N*T*C) env var instead so the module can be auto-loaded and also
report the correct alias using sysfs:

$ cat /sys/class/i2c-adapter/i2c-8/8-004b/modalias
of:NtrackpadTNULLCatmel,maxtouch

Signed-off-by: Javier Martinez Canillas jav...@osg.samsung.com



---

 drivers/i2c/i2c-core.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 92dddfeb3f39..c0668c2ed9da 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -489,6 +489,10 @@ static int i2c_device_uevent(struct device *dev, struct 
kobj_uevent_env *env)
struct i2c_client   *client = to_i2c_client(dev);
int rc;
 
+   rc = of_device_uevent_modalias(dev, env);
+   if (rc != -ENODEV)
+   return rc;
+
rc = acpi_device_uevent_modalias(dev, env);
if (rc != -ENODEV)
return rc;
@@ -726,6 +730,10 @@ show_modalias(struct device *dev, struct device_attribute 
*attr, char *buf)
struct i2c_client *client = to_i2c_client(dev);
int len;
 
+   len = of_device_get_modalias(dev, buf, PAGE_SIZE - 1);
+   if (len != -ENODEV)
+   return len;
+
len = acpi_device_modalias(dev, buf, PAGE_SIZE -1);
if (len != -ENODEV)
return len;
-- 
2.4.3

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


[PATCH v2 08/11] [media] c8sectpfe: Add support for various ST NIM cards.

2015-07-30 Thread Peter Griffin
This patch adds support for the following 2 NIM cards: -
1) B2100A (2x stv0367 demods  2x NXP tda18212 tuners)
2) STV0903-6110NIM (stv0903 demod + 6110 tuner, lnb24)

A NIM card is a cold plugable expansion card which usually
features a demodulator / tuner combination.

Signed-off-by: Peter Griffin peter.grif...@linaro.org
---
 .../media/platform/sti/c8sectpfe/c8sectpfe-dvb.c   | 244 +
 .../media/platform/sti/c8sectpfe/c8sectpfe-dvb.h   |  20 ++
 2 files changed, 264 insertions(+)
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.h

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c 
b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
new file mode 100644
index 000..69d7fe4
--- /dev/null
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
@@ -0,0 +1,244 @@
+/*
+ *  c8sectpfe-dvb.c - C8SECTPFE STi DVB driver
+ *
+ * Copyright (c) STMicroelectronics 2015
+ *
+ *  Author Peter Griffin peter.grif...@linaro.org
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ *  GNU General Public License for more details.
+ */
+#include linux/completion.h
+#include linux/delay.h
+#include linux/i2c.h
+#include linux/interrupt.h
+#include linux/version.h
+
+#include dt-bindings/media/c8sectpfe.h
+
+#include c8sectpfe-common.h
+#include c8sectpfe-core.h
+#include c8sectpfe-dvb.h
+
+#include dvb-pll.h
+#include lnbh24.h
+#include stv0367.h
+#include stv0367_priv.h
+#include stv6110x.h
+#include stv090x.h
+#include tda18212.h
+
+static inline const char *dvb_card_str(unsigned int c)
+{
+   switch (c) {
+   case STV0367_TDA18212_NIMA_1:   return STV0367_TDA18212_NIMA_1;
+   case STV0367_TDA18212_NIMA_2:   return STV0367_TDA18212_NIMA_2;
+   case STV0367_TDA18212_NIMB_1:   return STV0367_TDA18212_NIMB_1;
+   case STV0367_TDA18212_NIMB_2:   return STV0367_TDA18212_NIMB_2;
+   case STV0903_6110_LNB24_NIMA:   return STV0903_6110_LNB24_NIMA;
+   case STV0903_6110_LNB24_NIMB:   return STV0903_6110_LNB24_NIMB;
+   default:return unknown dvb frontend card;
+   }
+}
+
+static struct stv090x_config stv090x_config = {
+   .device = STV0903,
+   .demod_mode = STV090x_SINGLE,
+   .clk_mode   = STV090x_CLK_EXT,
+   .xtal   = 1600,
+   .address= 0x69,
+
+   .ts1_mode   = STV090x_TSMODE_SERIAL_CONTINUOUS,
+   .ts2_mode   = STV090x_TSMODE_SERIAL_CONTINUOUS,
+
+   .repeater_level = STV090x_RPTLEVEL_64,
+
+   .tuner_init = NULL,
+   .tuner_set_mode = NULL,
+   .tuner_set_frequency= NULL,
+   .tuner_get_frequency= NULL,
+   .tuner_set_bandwidth= NULL,
+   .tuner_get_bandwidth= NULL,
+   .tuner_set_bbgain   = NULL,
+   .tuner_get_bbgain   = NULL,
+   .tuner_set_refclk   = NULL,
+   .tuner_get_status   = NULL,
+};
+
+static struct stv6110x_config stv6110x_config = {
+   .addr   = 0x60,
+   .refclk = 1600,
+};
+
+#define NIMA 0
+#define NIMB 1
+
+static struct stv0367_config stv0367_tda18212_config[] = {
+   {
+   .demod_address = 0x1c,
+   .xtal = 1600,
+   .if_khz = 4500,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   }, {
+   .demod_address = 0x1d,
+   .xtal = 1600,
+   .if_khz = 4500,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   }, {
+   .demod_address = 0x1e,
+   .xtal = 1600,
+   .if_khz = 4500,
+   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
+   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
+   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
+   },
+};
+
+static struct tda18212_config tda18212_conf = {
+   .if_dvbt_6 = 4150,
+   .if_dvbt_7 = 4150,
+   .if_dvbt_8 = 4500,
+   .if_dvbc = 5000,
+};
+
+int c8sectpfe_frontend_attach(struct dvb_frontend **fe,
+   struct c8sectpfe *c8sectpfe,
+   struct channel_info *tsin, int chan_num)
+{
+   struct tda18212_config *tda18212;
+   struct stv6110x_devctl *fe2;
+   

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

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

Signed-off-by: Peter Griffin peter.grif...@linaro.org
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

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

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


[PATCH v2 07/11] [media] c8sectpfe: Add LDVB helper functions.

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

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

Signed-off-by: Peter Griffin peter.grif...@linaro.org
---
 .../platform/sti/c8sectpfe/c8sectpfe-common.c  | 265 +
 .../platform/sti/c8sectpfe/c8sectpfe-common.h  |  64 +
 2 files changed, 329 insertions(+)
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.c
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-common.h

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

[PATCH v2 05/11] ARM: DT: STi: STiH407: Add c8sectpfe LinuxDVB DT node.

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

Signed-off-by: Peter Griffin peter.grif...@linaro.org
---
 arch/arm/boot/dts/stihxxx-b2120.dtsi | 38 
 1 file changed, 38 insertions(+)

diff --git a/arch/arm/boot/dts/stihxxx-b2120.dtsi 
b/arch/arm/boot/dts/stihxxx-b2120.dtsi
index 62994ae..1bc018e 100644
--- a/arch/arm/boot/dts/stihxxx-b2120.dtsi
+++ b/arch/arm/boot/dts/stihxxx-b2120.dtsi
@@ -6,6 +6,10 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+
+#include dt-bindings/clock/stih407-clks.h
+#include dt-bindings/media/c8sectpfe.h
+
 / {
soc {
sbc_serial0: serial@953 {
@@ -85,5 +89,39 @@
status = okay;
};
 
+   c8sectpfe@08a2 {
+   compatible = st,stih407-c8sectpfe;
+   status = okay;
+   reg = 0x08a2 0x1, 0x08a0 0x4000;
+   reg-names = c8sectpfe, c8sectpfe-ram;
+
+   interrupts = 0 34 0, 0 35 0;
+   interrupt-names = c8sectpfe-error-irq,
+ c8sectpfe-idle-irq;
+
+   pinctrl-names   = tsin0-serial, tsin0-parallel,
+ tsin3-serial, tsin4-serial,
+ tsin5-serial;
+
+   pinctrl-0   = pinctrl_tsin0_serial;
+   pinctrl-1   = pinctrl_tsin0_parallel;
+   pinctrl-2   = pinctrl_tsin3_serial;
+   pinctrl-3   = pinctrl_tsin4_serial_alt3;
+   pinctrl-4   = pinctrl_tsin5_serial_alt1;
+
+   clocks = clk_s_c0_flexgen CLK_PROC_STFE;
+   clock-names = c8sectpfe;
+
+   /* tsin0 is TSA on NIMA */
+   tsin0: port@0 {
+
+   tsin-num = 0;
+   serial-not-parallel;
+   i2c-bus = ssc2;
+   rst-gpio = pio15 4 0;
+
+   dvb-card = STV0367_TDA18212_NIMA_1;
+   };
+   };
};
 };
-- 
1.9.1

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


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

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

Signed-off-by: Peter Griffin peter.grif...@linaro.org
---
 drivers/media/platform/Kconfig|  4 +++-
 drivers/media/platform/Makefile   |  1 +
 drivers/media/platform/sti/c8sectpfe/Kconfig  | 28 +++
 drivers/media/platform/sti/c8sectpfe/Makefile |  9 +
 4 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/sti/c8sectpfe/Kconfig
 create mode 100644 drivers/media/platform/sti/c8sectpfe/Makefile

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f6bed19..68d7ed1 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -1,6 +1,6 @@
 #
 # Platform drivers
-#  All drivers here are currently for webcam support
+#  Most drivers here are currently for webcam support
 
 menuconfig V4L_PLATFORM_DRIVERS
bool V4L platform devices
@@ -280,3 +280,5 @@ config VIDEO_VIM2M
  This is a virtual test device for the memory-to-memory driver
  framework.
 endif #V4L_TEST_DRIVERS
+
+source drivers/media/platform/sti/c8sectpfe/Kconfig
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 114f9ab..301bc1d 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D)   += s5p-g2d/
 obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/
 
 obj-$(CONFIG_VIDEO_STI_BDISP)  += sti/bdisp/
+obj-$(CONFIG_DVB_C8SECTPFE)+= sti/c8sectpfe/
 
 obj-$(CONFIG_BLACKFIN)  += blackfin/
 
diff --git a/drivers/media/platform/sti/c8sectpfe/Kconfig 
b/drivers/media/platform/sti/c8sectpfe/Kconfig
new file mode 100644
index 000..d1bfd4c
--- /dev/null
+++ b/drivers/media/platform/sti/c8sectpfe/Kconfig
@@ -0,0 +1,28 @@
+config DVB_C8SECTPFE
+   tristate STMicroelectronics C8SECTPFE DVB support
+   depends on DVB_CORE  I2C  (ARCH_STI || ARCH_MULTIPLATFORM)
+   select LIBELF_32
+   select FW_LOADER
+   select FW_LOADER_USER_HELPER_FALLBACK
+   select DEBUG_FS
+   select DVB_LNBP21 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV090x if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STB6100 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV6110 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV0900 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
+
+   ---help---
+ This adds support for DVB front-end cards connected
+ to TS inputs of STiH407/410 SoC.
+
+ The driver currently supports C8SECTPFE's TS input block,
+ memdma engine, and HW PID filtering.
+
+ Supported DVB front-end cards are:
+ - STMicroelectronics DVB-T B2100A (STV0367 + TDA18212)
+ - STMicroelectronics DVB-S/S2 STV0903 + STV6110 + LNBP24 board
+
+ To compile this driver as a module, choose M here: the
+ module will be called c8sectpfe.
diff --git a/drivers/media/platform/sti/c8sectpfe/Makefile 
b/drivers/media/platform/sti/c8sectpfe/Makefile
new file mode 100644
index 000..b578c7c
--- /dev/null
+++ b/drivers/media/platform/sti/c8sectpfe/Makefile
@@ -0,0 +1,9 @@
+c8sectpfe-y += c8sectpfe-core.o c8sectpfe-common.o c8sectpfe-dvb.o \
+   c8sectpfe-debugfs.o
+
+obj-$(CONFIG_DVB_C8SECTPFE) += c8sectpfe.o
+
+ccflags-y += -Idrivers/media/i2c
+ccflags-y += -Idrivers/media/common
+ccflags-y += -Idrivers/media/dvb-core/ -Idrivers/media/dvb-frontends/ \
+   -Idrivers/media/tuners/
-- 
1.9.1

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


[PATCH v2 06/11] [media] c8sectpfe: STiH407/10 Linux DVB demux support

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

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

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

Signed-off-by: Peter Griffin peter.grif...@linaro.org
---
 .../media/platform/sti/c8sectpfe/c8sectpfe-core.c  | 1235 
 .../media/platform/sti/c8sectpfe/c8sectpfe-core.h  |  288 +
 2 files changed, 1523 insertions(+)
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.h

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c 
b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
new file mode 100644
index 000..3a91093
--- /dev/null
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c
@@ -0,0 +1,1235 @@
+/*
+ * c8sectpfe-core.c - C8SECTPFE STi DVB driver
+ *
+ * Copyright (c) STMicroelectronics 2015
+ *
+ *   Author:Peter Bennett peter.benn...@st.com
+ * Peter Griffin peter.grif...@linaro.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+#include linux/atomic.h
+#include linux/clk.h
+#include linux/completion.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/dma-mapping.h
+#include linux/dvb/dmx.h
+#include linux/dvb/frontend.h
+#include linux/errno.h
+#include linux/firmware.h
+#include linux/init.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/module.h
+#include linux/of_gpio.h
+#include linux/of_platform.h
+#include linux/platform_device.h
+#include linux/usb.h
+#include linux/slab.h
+#include linux/time.h
+#include linux/version.h
+#include linux/wait.h
+
+#include c8sectpfe-core.h
+#include c8sectpfe-common.h
+#include c8sectpfe-debugfs.h
+#include dmxdev.h
+#include dvb_demux.h
+#include dvb_frontend.h
+#include dvb_net.h
+
+#define FIRMWARE_MEMDMA pti_memdma_h407.elf
+MODULE_FIRMWARE(FIRMWARE_MEMDMA);
+
+#define PID_TABLE_SIZE 1024
+#define POLL_MSECS 50
+
+static int load_c8sectpfe_fw_step1(struct c8sectpfei *fei);
+
+#define TS_PKT_SIZE 188
+#define HEADER_SIZE (4)
+#define PACKET_SIZE (TS_PKT_SIZE+HEADER_SIZE)
+
+#define FEI_ALIGNMENT (32)
+/* hw requires minimum of 8*PACKET_SIZE and padded to 8byte boundary */
+#define FEI_BUFFER_SIZE (8*PACKET_SIZE*340)
+
+#define FIFO_LEN 1024
+
+static void c8sectpfe_timer_interrupt(unsigned long ac8sectpfei)
+{
+   struct c8sectpfei *fei = (struct c8sectpfei *)ac8sectpfei;
+   struct channel_info *channel;
+   int chan_num;
+
+   /* iterate through input block channels */
+   for (chan_num = 0; chan_num  fei-tsin_count; chan_num++) {
+   channel = fei-channel_data[chan_num];
+
+   /* is this descriptor initialised and TP enabled */
+   if (channel-irec  readl(channel-irec + DMA_PRDS_TPENABLE))
+   tasklet_schedule(channel-tsklet);
+   }
+
+   fei-timer.expires = jiffies +  msecs_to_jiffies(POLL_MSECS);
+   add_timer(fei-timer);
+}
+
+static void channel_swdemux_tsklet(unsigned long data)
+{
+   struct channel_info *channel = (struct channel_info *)data;
+   struct c8sectpfei *fei = channel-fei;
+   unsigned long wp, rp;
+   int pos, num_packets, n, size;
+   u8 *buf;
+
+   if (unlikely(!channel || !channel-irec))
+   return;
+
+   wp = readl(channel-irec + DMA_PRDS_BUSWP_TP(0));
+   rp = readl(channel-irec + DMA_PRDS_BUSRP_TP(0));
+
+   pos = rp - channel-back_buffer_busaddr;
+
+   /* has it wrapped */
+   if (wp  rp)
+   wp = channel-back_buffer_busaddr + FEI_BUFFER_SIZE;
+
+   size = wp - rp;
+   num_packets = size / PACKET_SIZE;
+
+   /* manage cache so data is visible to CPU */
+   dma_sync_single_for_cpu(fei-dev,
+   rp,
+   size,
+   DMA_FROM_DEVICE);
+
+   buf = (u8 *) channel-back_buffer_aligned;
+
+   dev_dbg(fei-dev,
+   chan=%d channel=%p num_packets = %d, buf = %p, pos = 0x%x\n\t
+   rp=0x%lx, wp=0x%lx\n,
+   channel-tsin_id, channel, num_packets, buf, pos, rp, wp);
+
+   for (n = 0; n  num_packets; n++) {
+   dvb_dmx_swfilter_packets(
+   fei-c8sectpfe[0]-
+   demux[channel-demux_mapping].dvb_demux,
+   buf[pos], 1);
+
+   pos += PACKET_SIZE;
+   }
+
+   /* advance the read pointer */
+   if (wp == 

[PATCH v2 04/11] [media] c8sectpfe: Add DT bindings documentation for c8sectpfe driver.

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

Signed-off-by: Peter Griffin peter.grif...@linaro.org
---
 .../bindings/media/stih407-c8sectpfe.txt   | 89 ++
 include/dt-bindings/media/c8sectpfe.h  | 12 +++
 2 files changed, 101 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
 create mode 100644 include/dt-bindings/media/c8sectpfe.h

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

[PATCH v2 09/11] [media] c8sectpfe: Add c8sectpfe debugfs support.

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

Signed-off-by: Peter Griffin peter.grif...@linaro.org
---
 .../platform/sti/c8sectpfe/c8sectpfe-debugfs.c | 271 +
 .../platform/sti/c8sectpfe/c8sectpfe-debugfs.h |  26 ++
 2 files changed, 297 insertions(+)
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
 create mode 100644 drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.h

diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c 
b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
new file mode 100644
index 000..e9ba13d
--- /dev/null
+++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-debugfs.c
@@ -0,0 +1,271 @@
+/*
+ * c8sectpfe-debugfs.c - C8SECTPFE STi DVB driver
+ *
+ * Copyright (c) STMicroelectronics 2015
+ *
+ * Author: Peter Griffin peter.grif...@linaro.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include linux/debugfs.h
+#include linux/device.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/seq_file.h
+#include linux/slab.h
+#include linux/types.h
+
+#include c8sectpfe-debugfs.h
+
+#define dump_register(nm ...)  \
+{  \
+   .name   = #nm,  \
+   .offset = nm,   \
+}
+
+static const struct debugfs_reg32 fei_sys_regs[] = {
+   dump_register(SYS_INPUT_ERR_STATUS),
+   dump_register(SYS_OTHER_ERR_STATUS),
+   dump_register(SYS_INPUT_ERR_MASK),
+   dump_register(SYS_DMA_ROUTE),
+   dump_register(SYS_INPUT_CLKEN),
+   dump_register(IBENABLE_MASK),
+   dump_register(SYS_OTHER_CLKEN),
+   dump_register(SYS_CFG_NUM_IB),
+   dump_register(SYS_CFG_NUM_MIB),
+   dump_register(SYS_CFG_NUM_SWTS),
+   dump_register(SYS_CFG_NUM_TSOUT),
+   dump_register(SYS_CFG_NUM_CCSC),
+   dump_register(SYS_CFG_NUM_RAM),
+   dump_register(SYS_CFG_NUM_TP),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(0)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(0)),
+   dump_register(C8SECTPFE_IB_PID_SET(0)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(0)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(0)),
+   dump_register(C8SECTPFE_IB_BUFF_END(0)),
+   dump_register(C8SECTPFE_IB_READ_PNT(0)),
+   dump_register(C8SECTPFE_IB_WRT_PNT(0)),
+   dump_register(C8SECTPFE_IB_PRI_THRLD(0)),
+   dump_register(C8SECTPFE_IB_STAT(0)),
+   dump_register(C8SECTPFE_IB_MASK(0)),
+   dump_register(C8SECTPFE_IB_SYS(0)),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(1)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(1)),
+   dump_register(C8SECTPFE_IB_PID_SET(1)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(1)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(1)),
+   dump_register(C8SECTPFE_IB_BUFF_END(1)),
+   dump_register(C8SECTPFE_IB_READ_PNT(1)),
+   dump_register(C8SECTPFE_IB_WRT_PNT(1)),
+   dump_register(C8SECTPFE_IB_PRI_THRLD(1)),
+   dump_register(C8SECTPFE_IB_STAT(1)),
+   dump_register(C8SECTPFE_IB_MASK(1)),
+   dump_register(C8SECTPFE_IB_SYS(1)),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(2)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(2)),
+   dump_register(C8SECTPFE_IB_PID_SET(2)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(2)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(2)),
+   dump_register(C8SECTPFE_IB_BUFF_END(2)),
+   dump_register(C8SECTPFE_IB_READ_PNT(2)),
+   dump_register(C8SECTPFE_IB_WRT_PNT(2)),
+   dump_register(C8SECTPFE_IB_PRI_THRLD(2)),
+   dump_register(C8SECTPFE_IB_STAT(2)),
+   dump_register(C8SECTPFE_IB_MASK(2)),
+   dump_register(C8SECTPFE_IB_SYS(2)),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(3)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(3)),
+   dump_register(C8SECTPFE_IB_PID_SET(3)),
+   dump_register(C8SECTPFE_IB_PKT_LEN(3)),
+   dump_register(C8SECTPFE_IB_BUFF_STRT(3)),
+   dump_register(C8SECTPFE_IB_BUFF_END(3)),
+   dump_register(C8SECTPFE_IB_READ_PNT(3)),
+   dump_register(C8SECTPFE_IB_WRT_PNT(3)),
+   dump_register(C8SECTPFE_IB_PRI_THRLD(3)),
+   dump_register(C8SECTPFE_IB_STAT(3)),
+   dump_register(C8SECTPFE_IB_MASK(3)),
+   dump_register(C8SECTPFE_IB_SYS(3)),
+
+   dump_register(C8SECTPFE_IB_IP_FMT_CFG(4)),
+   dump_register(C8SECTPFE_IB_TAGBYTES_CFG(4)),
+   

[PATCH 11/27] [media] staging: media: lirc: Export I2C module alias information

2015-07-30 Thread Javier Martinez Canillas
The I2C core always reports the MODALIAS uevent as i2c:client name
regardless if the driver was matched using the I2C id_table or the
of_match_table. So the driver needs to export the I2C table and this
be built into the module or udev won't have the necessary information
to auto load the correct module when the device is added.

Signed-off-by: Javier Martinez Canillas jav...@osg.samsung.com

---

 drivers/staging/media/lirc/lirc_zilog.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/lirc/lirc_zilog.c 
b/drivers/staging/media/lirc/lirc_zilog.c
index 261e27d6b054..bebfc3b093bc 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -1364,6 +1364,7 @@ static const struct i2c_device_id ir_transceiver_id[] = {
{ ir_rx_z8f0811_hdpvr, ID_FLAG_HDPVR  },
{ }
 };
+MODULE_DEVICE_TABLE(i2c, ir_transceiver_id);
 
 static struct i2c_driver driver = {
.driver = {
-- 
2.4.3

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


Re: [PATCH 00/27] Export I2C and OF module aliases in missing drivers

2015-07-30 Thread Dmitry Torokhov
Hi Javier,

On Thu, Jul 30, 2015 at 06:18:25PM +0200, Javier Martinez Canillas wrote:
 Hello,
 
 Short version:
 
 This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
 to export that information so modules have the correct aliases built-in
 and autoloading works correctly.
 
 Longer version:
 
 Currently it's mandatory for I2C drivers to have an I2C device ID table
 regardless if the device was registered using platform data or OF. This
 is because the I2C core needs an I2C device ID table for two reasons:
 
 1) Match the I2C client with a I2C device ID so a struct i2c_device_id
is passed to the I2C driver probe() function.
 
 2) Export the module aliases from the I2C device ID table so userspace
can auto-load the correct module. This is because i2c_device_uevent
always reports a MODALIAS of the form i2c:client-name.

Why are we not fixing this? We emit specially carved uevent for
ACPI-based devices, why not the same for OF? Platform bus does this...

Thanks.

-- 
Dmitry
--
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/27] [media] Export I2C module alias information in missing drivers

2015-07-30 Thread Javier Martinez Canillas
The I2C core always reports the MODALIAS uevent as i2c:client name
regardless if the driver was matched using the I2C id_table or the
of_match_table. So the driver needs to export the I2C table and this
be built into the module or udev won't have the necessary information
to auto load the correct module when the device is added.

Signed-off-by: Javier Martinez Canillas jav...@osg.samsung.com

---

 drivers/media/i2c/ir-kbd-i2c.c | 1 +
 drivers/media/i2c/s5k6a3.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 175a76114953..728d2cc8a3e7 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -478,6 +478,7 @@ static const struct i2c_device_id ir_kbd_id[] = {
{ ir_rx_z8f0811_hdpvr, 0 },
{ }
 };
+MODULE_DEVICE_TABLE(i2c, ir_kbd_id);
 
 static struct i2c_driver ir_kbd_driver = {
.driver = {
diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index bc389d5e42ae..b1b1574dfb95 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -363,6 +363,7 @@ static int s5k6a3_remove(struct i2c_client *client)
 static const struct i2c_device_id s5k6a3_ids[] = {
{ }
 };
+MODULE_DEVICE_TABLE(i2c, s5k6a3_ids);
 
 #ifdef CONFIG_OF
 static const struct of_device_id s5k6a3_of_match[] = {
-- 
2.4.3

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


[PATCH 00/27] Export I2C and OF module aliases in missing drivers

2015-07-30 Thread Javier Martinez Canillas
Hello,

Short version:

This series add the missing MODULE_DEVICE_TABLE() for OF and I2C tables
to export that information so modules have the correct aliases built-in
and autoloading works correctly.

Longer version:

Currently it's mandatory for I2C drivers to have an I2C device ID table
regardless if the device was registered using platform data or OF. This
is because the I2C core needs an I2C device ID table for two reasons:

1) Match the I2C client with a I2C device ID so a struct i2c_device_id
   is passed to the I2C driver probe() function.

2) Export the module aliases from the I2C device ID table so userspace
   can auto-load the correct module. This is because i2c_device_uevent
   always reports a MODALIAS of the form i2c:client-name.

Lee Jones posted a patch series [0] to solve 1) by allowing the I2C
drivers to have a probe() function that does not get a i2c_device_id.

The problem is that his series didn't take into account 2) so if that
was merged and the I2C ID table is removed from all the drivers that
don't needed it, module auto-loading will break for those.

But even now there are many I2C drivers were module auto-loading is
not working because of the fact that the I2C core always reports the
MODALIAS as i2c:client-name and many developers didn't expect this.

I've identified I2C drivers with 3 types of different issues:

a) Those that have an i2c_table but are not exported. The match works
   and the correct i2c_device_id is passed on probe but since the ID
   table is not exported, module auto-load won't work.

b) Those that have a of_table but are not exported. This is currently
   not an issue since even when the of_table is used to match the dev
   with the driver, an OF modalias is not reported by the I2C core.
   But if the I2C core is changed to report the MODALIAS of the form
   of:N*T*C as it's made by other subsystems, then module auto-load
   will break for these drivers.

c) Those that don't have a of_table but should since are OF drivers
   with DT bindings doc for them. Since the I2C core does not report
   a OF modalias and since i2c_device_match() fallbacks to match the
   device part of the compatible string with the I2C device ID table,
   many OF drivers don't have an of_table to match. After all having
   a I2C device ID table is mandatory so it works without a of_table.

So, in order to not make mandatory to have a I2C device ID table, at
least a) and b) needs to be addressed, this series does that.

c) should be fixed too since it seems wrong that a driver with a DT
binding document, does not have a OF table and export it to modules.

Also stripping the vendor part from the compatible string to match
with the I2C devices ID table and reporting only the device name to
user-space doesn't seem to be correct. I've identified at least two
drivers that have the same name on their I2C device ID table so the
manufacturer prefix is important. But I've not tried to fix c) yet
since that is not so easy to automate due drivers not having all the
information (i.e: the device name can match a documented compatible
string device part but without the vendor prefix is hard to tell).

I split the changes so the patches in this series are independent and
can be picked individually by subsystem maintainers. Patch #27 changes
the logic of i2c_device_uevent() to report an OF modalias if the device
was registered using OF. But this patch is included in the series only
as an RFC for illustration purposes since changing that without fixing
c) will break module auto-loading for the drivers of devices registered
with OF but that don't have a of_match_table.

Although arguably, those drivers were relying on the assumption that a
MODALIAS=i2c:foo would always be reported even for the OF case which
is not the true on other subsystems.

[0]: https://lkml.org/lkml/2014/8/28/283

Best regards,
Javier


Javier Martinez Canillas (27):
  mfd: stw481x: Export I2C module alias information
  spi: xcomm: Export I2C module alias information
  iio: Export I2C module alias information in missing drivers
  [media] Export I2C module alias information in missing drivers
  macintosh: therm_windtunnel: Export I2C module alias information
  misc: eeprom: Export I2C module alias information in missing drivers
  Input: Export I2C module alias information in missing drivers
  power: Export I2C module alias information in missing drivers
  i2c: core: Export I2C module alias information in dummy driver
  backlight: tosa: Export I2C module alias information
  [media] staging: media: lirc: Export I2C module alias information
  usb: phy: isp1301: Export I2C module alias information
  ALSA: ppc: keywest: Export I2C module alias information
  hwmon: (nct7904) Export I2C module alias information
  regulator: fan53555: Export I2C module alias information
  mfd: Export OF module alias information in missing drivers
  iio: Export OF module alias information in missing drivers
  hwmon: (g762) Export OF module alias information

[RFC PATCH] lib: scatterlist: add sg splitting function

2015-07-30 Thread Robert Jarzmik
Sometimes a scatter-gather has to be split into several chunks, or sub scatter
lists. This happens for example if a scatter list will be handled by multiple
DMA channels, each one filling a part of it.

A concrete example comes with the media V4L2 API, where the scatter list is
allocated from userspace to hold an image, regardless of the knowledge of how
many DMAs will fill it :
 - in a simple RGB565 case, one DMA will pump data from the camera ISP to memory
 - in the trickier YUV422 case, 3 DMAs will pump data from the camera ISP pipes,
   one for pipe Y, one for pipe U and one for pipe V

For these cases, it is necessary to split the original scatter list into
multiple scatter lists, which is the purpose of this patch.

The guarantees that are required for this patch are :
 - the intersection of spans of any couple of resulting scatter lists is empty
 - the union of spans of all resulting scatter lists is a subrange of the span
   of the original scatter list
 - if streaming DMA API operations (mapping, unmapping) should not happen both
   on both the resulting and the original scatter list. It's either the first or
   the later ones.
 - the caller is reponsible to call kfree() on the resulting scatterlists

Signed-off-by: Robert Jarzmik robert.jarz...@free.fr

---
The sg_split() function is an attempt to address the splitting in a generic
way. If it is judged unsuitable, it will remain as a specialized function in the
depths of a media driver.

Memo of people to ask:
To: Russell King - ARM Linux li...@arm.linux.org.uk
To: Jens Axboe ax...@kernel.dk
To: Guennadi Liakhovetski g.liakhovet...@gmx.de
To: Andrew Morton a...@linux-foundation.org
To: Mauro Carvalho Chehab mche...@osg.samsung.com
Cc: linux-media@vger.kernel.org
---
 include/linux/scatterlist.h |   3 ++
 lib/scatterlist.c   | 122 
 2 files changed, 125 insertions(+)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 9b1ef0c820a7..cee8648a6918 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -251,6 +251,9 @@ struct scatterlist *sg_next(struct scatterlist *);
 struct scatterlist *sg_last(struct scatterlist *s, unsigned int);
 void sg_init_table(struct scatterlist *, unsigned int);
 void sg_init_one(struct scatterlist *, const void *, unsigned int);
+int sg_split(struct scatterlist *in, const off_t skip, const int nb_splits,
+const size_t *split_sizes, struct scatterlist **out,
+gfp_t gfp_mask);
 
 typedef struct scatterlist *(sg_alloc_fn)(unsigned int, gfp_t);
 typedef void (sg_free_fn)(struct scatterlist *, unsigned int);
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index d105a9f56878..c4415a2af0ec 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -759,3 +759,125 @@ size_t sg_pcopy_to_buffer(struct scatterlist *sgl, 
unsigned int nents,
return sg_copy_buffer(sgl, nents, buf, buflen, skip, true);
 }
 EXPORT_SYMBOL(sg_pcopy_to_buffer);
+
+struct sg_splitter {
+   struct scatterlist *in_sg0;
+   int nents;
+   off_t skip_sg0;
+   size_t len_last_sg;
+   struct scatterlist *out_sg;
+};
+
+static struct sg_splitter *sg_calculate_split(struct scatterlist *in,
+ off_t skip, const size_t *sizes,
+ int nb_splits, gfp_t gfp_mask)
+{
+   int i;
+   size_t size = sizes[0], len;
+   struct sg_splitter *splitters, *curr;
+   struct scatterlist *sg;
+
+   splitters = kcalloc(nb_splits, sizeof(*splitters), gfp_mask);
+   if (!splitters)
+   return NULL;
+
+   curr = splitters;
+   for_each_sg(in, sg, sg_nents(in), i) {
+   if (skip  sg_dma_len(sg)) {
+   skip -= sg_dma_len(sg);
+   continue;
+   }
+   len = min_t(size_t, size, sg_dma_len(sg) - skip);
+   if (!curr-in_sg0) {
+   curr-in_sg0 = sg;
+   curr-skip_sg0 = sg_dma_len(sg) - len;
+   }
+   size -= len;
+   curr-nents++;
+   if (!size) {
+   curr-len_last_sg = len;
+   size = *(++sizes);
+
+   if (!--nb_splits)
+   break;
+
+   curr++;
+   if (len  sg_dma_len(sg) - skip) {
+   curr-in_sg0 = sg;
+   curr-skip_sg0 = sg_dma_len(sg) - skip - len;
+   curr-nents++;
+   }
+   }
+   }
+
+   return splitters;
+}
+
+/**
+ * sg_split - split a scatterlist into several scatterlists
+ * @in: the input sg list
+ * @skip: the number of bytes to skip in the input sg list
+ * @nb_splits: the number of desired sg outputs
+ * @split_sizes: the respective size of each output sg list in bytes
+ * @out: an 

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

2015-07-30 Thread Peter Griffin
Hi Mauro / Joe,

On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:

 Em Wed, 24 Jun 2015 18:17:37 -0700
 Joe Perches j...@perches.com escreveu:
 
  On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
   This is used in conjunction with the STV0367 demodulator on
   the STV0367-NIM-V1.0 NIM card which can be used with the STi
   STB SoC's.
  
  Barely associated to this specific patch, but for
  dvb-pll.c, another thing that seems possible is to
  convert the struct dvb_pll_desc uses to const and
  change the entries fixed array size from 12 to []
  
  It'd save a couple KB overall and remove ~5KB of data.
  
  $ size drivers/media/dvb-frontends/dvb-pll.o*
 textdata bss dec hex filename
 852015522120   121922fa0 
  drivers/media/dvb-frontends/dvb-pll.o.new
 562463632120   14107371b 
  drivers/media/dvb-frontends/dvb-pll.o.old
 
 Peter,
 
 Please add this patch on the next patch series you submit.

Ok will do, I've added this patch with a slightly updated commit message
to my series.

Joe - Can I add your signed-off-by?

regards,

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


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

2015-07-30 Thread Joe Perches
On Thu, 2015-07-30 at 10:47 +0100, Peter Griffin wrote:
 Hi Mauro / Joe,
 
 On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:
 
  Em Wed, 24 Jun 2015 18:17:37 -0700
  Joe Perches j...@perches.com escreveu:
  
   On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
This is used in conjunction with the STV0367 demodulator on
the STV0367-NIM-V1.0 NIM card which can be used with the STi
STB SoC's.
   
   Barely associated to this specific patch, but for
   dvb-pll.c, another thing that seems possible is to
   convert the struct dvb_pll_desc uses to const and
   change the entries fixed array size from 12 to []
   
   It'd save a couple KB overall and remove ~5KB of data.
   
   $ size drivers/media/dvb-frontends/dvb-pll.o*
  text  data bss dec hex filename
  8520  15522120   121922fa0 
   drivers/media/dvb-frontends/dvb-pll.o.new
  5624  63632120   14107371b 
   drivers/media/dvb-frontends/dvb-pll.o.old
  
  Peter,
  
  Please add this patch on the next patch series you submit.
 
 Ok will do, I've added this patch with a slightly updated commit message
 to my series.
 
 Joe - Can I add your signed-off-by?

Signed-off-by: Joe Perches j...@perches.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 11/12] [media] tsin: c8sectpfe: Add Kconfig and Makefile for the driver.

2015-07-30 Thread Peter Griffin
Hi Mauro,

Thanks for reviewing. Sending my reply again, as it looks like I dropped the
CC list on my first reply, and my second reply bounced on the mailing lists :-(

On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:

 Em Wed, 24 Jun 2015 16:11:09 +0100
 Peter Griffin peter.grif...@linaro.org escreveu:
 
  This patch adds the Kconfig and Makefile for the c8sectpfe driver
  so it will be built. It also selects additional demodulator and tuners
  which are required by the supported NIM cards.
  
  Signed-off-by: Peter Griffin peter.grif...@linaro.org
  ---
   drivers/media/Kconfig |  1 +
   drivers/media/Makefile|  1 +
   drivers/media/tsin/c8sectpfe/Kconfig  | 26 ++
   drivers/media/tsin/c8sectpfe/Makefile | 11 +++
   4 files changed, 39 insertions(+)
   create mode 100644 drivers/media/tsin/c8sectpfe/Kconfig
   create mode 100644 drivers/media/tsin/c8sectpfe/Makefile
  
  diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
  index 1570992..82bc1dc 100644
  --- a/drivers/media/Kconfig
  +++ b/drivers/media/Kconfig
  @@ -170,6 +170,7 @@ source drivers/media/pci/Kconfig
   source drivers/media/platform/Kconfig
   source drivers/media/mmc/Kconfig
   source drivers/media/radio/Kconfig
  +source drivers/media/tsin/c8sectpfe/Kconfig
   
   comment Supported FireWire (IEEE 1394) Adapters
  depends on DVB_CORE  FIREWIRE
  diff --git a/drivers/media/Makefile b/drivers/media/Makefile
  index e608bbc..0a567b8 100644
  --- a/drivers/media/Makefile
  +++ b/drivers/media/Makefile
  @@ -29,5 +29,6 @@ obj-y += rc/
   #
   
   obj-y += common/ platform/ pci/ usb/ mmc/ firewire/
  +obj-$(CONFIG_DVB_C8SECTPFE) += tsin/c8sectpfe/
 
 Hmm... why are you adding it at a new tsin directory? We're putting
 those SoC platform drivers under platform/.

I didn't realise that. I will move this under there in the V2 patchset then?

The rationale behind a new 'tsin' directory was that all the current DVB
drivers seemed to be grouped by the underlying bus on which TS
data enters the system (e.g. pci / usb).

As this didn't fit in with that scheme I created a new tsin directory for SoC's
which have dedicated hardware for Transport Stream INput (tsin) into the SoC.

regards,

Peter.

p.s. Mauro - appologies again for spaming you
--
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 09/12] [media] tsin: c8sectpfe: Add support for various ST NIM cards.

2015-07-30 Thread Peter Griffin
Hi Mauro,

On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:

 Em Wed, 24 Jun 2015 16:11:07 +0100
 Peter Griffin peter.grif...@linaro.org escreveu:
 
  This patch adds support for the following 3 NIM cards: -
  1) STV0367-NIM (stv0367 demod with Thompson PLL)
  2) B2100A (2x stv0367 demods  2x NXP tda18212 tuners)
  3) STV0903-6110NIM (stv0903 demod + 6110 tuner, lnb24)
  
  Signed-off-by: Peter Griffin peter.grif...@linaro.org
  ---
   drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c | 296 
  +++
   drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.h |  20 ++
   2 files changed, 316 insertions(+)
   create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
   create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.h
  
  diff --git a/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c 
  b/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
  new file mode 100644
  index 000..5c4ecb4
  --- /dev/null
  +++ b/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
  @@ -0,0 +1,296 @@
  +/*
  + *  c8sectpfe-dvb.c - C8SECTPFE STi DVB driver
  + *
  + * Copyright (c) STMicroelectronics 2015
  + *
  + *  Author Peter Griffin peter.grif...@linaro.org
  + *
  + *  This program is free software; you can redistribute it and/or modify
  + *  it under the terms of the GNU General Public License as published by
  + *  the Free Software Foundation; either version 2 of the License, or
  + *  (at your option) any later version.
  + *
  + *  This program is distributed in the hope that it will be useful,
  + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  + *
  + *  GNU General Public License for more details.
  + */
  +#include linux/completion.h
  +#include linux/delay.h
  +#include linux/i2c.h
  +#include linux/interrupt.h
  +#include linux/version.h
  +
  +#include dt-bindings/media/c8sectpfe.h
  +
  +#include c8sectpfe-common.h
  +#include c8sectpfe-core.h
  +#include c8sectpfe-dvb.h
  +
  +#include dvb-pll.h
  +#include lnbh24.h
  +#include stv0367.h
  +#include stv0367_priv.h
  +#include stv6110x.h
  +#include stv090x.h
  +#include tda18212.h
  +
  +static inline const char *dvb_card_str(unsigned int c)
  +{
  +   switch (c) {
  +   case STV0367_PLL_BOARD_NIMA:return STV0367_PLL_BOARD_NIMA;
  +   case STV0367_PLL_BOARD_NIMB:return STV0367_PLL_BOARD_NIMB;
  +   case STV0367_TDA18212_NIMA_1:   return STV0367_TDA18212_NIMA_1;
  +   case STV0367_TDA18212_NIMA_2:   return STV0367_TDA18212_NIMA_2;
  +   case STV0367_TDA18212_NIMB_1:   return STV0367_TDA18212_NIMB_1;
  +   case STV0367_TDA18212_NIMB_2:   return STV0367_TDA18212_NIMB_2;
  +   case STV0903_6110_LNB24_NIMA:   return STV0903_6110_LNB24_NIMA;
  +   case STV0903_6110_LNB24_NIMB:   return STV0903_6110_LNB24_NIMB;
  +   default:return unknown dvb frontend card;
  +   }
  +}
  +
  +static struct stv090x_config stv090x_config = {
  +   .device = STV0903,
  +   .demod_mode = STV090x_SINGLE,
  +   .clk_mode   = STV090x_CLK_EXT,
  +   .xtal   = 1600,
  +   .address= 0x69,
  +
  +   .ts1_mode   = STV090x_TSMODE_SERIAL_CONTINUOUS,
  +   .ts2_mode   = STV090x_TSMODE_SERIAL_CONTINUOUS,
  +
  +   .repeater_level = STV090x_RPTLEVEL_64,
  +
  +   .tuner_init = NULL,
  +   .tuner_set_mode = NULL,
  +   .tuner_set_frequency= NULL,
  +   .tuner_get_frequency= NULL,
  +   .tuner_set_bandwidth= NULL,
  +   .tuner_get_bandwidth= NULL,
  +   .tuner_set_bbgain   = NULL,
  +   .tuner_get_bbgain   = NULL,
  +   .tuner_set_refclk   = NULL,
  +   .tuner_get_status   = NULL,
  +};
  +
  +static struct stv6110x_config stv6110x_config = {
  +   .addr   = 0x60,
  +   .refclk = 1600,
  +};
  +
  +#define NIMA 0
  +#define NIMB 1
  +
  +static struct stv0367_config stv0367_pll_config[] = {
  +   {
  +   .demod_address = 0x1c,
  +   .xtal = 2700,
  +   .if_khz = 36166,
  +   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
  +   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
  +   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
  +   }, {
  +   .demod_address = 0x1d,
  +   .xtal = 2700,
  +   .if_khz = 36166,
  +   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
  +   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
  +   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
  +   },
  +};
  +
  +static struct stv0367_config stv0367_tda18212_config[] = {
  +   {
  +   .demod_address = 0x1c,
  +   .xtal = 1600,
  +   .if_khz = 4500,
  +   .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
  +   .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
  +   .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
  +   }, {
  +   .demod_address = 0x1d,
  +   .xtal = 1600,
  +   .if_khz = 4500,
  +

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

2015-07-30 Thread Peter Griffin
Hi Mauro,

On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:

 Em Wed, 24 Jun 2015 16:11:00 +0100
 Peter Griffin peter.grif...@linaro.org escreveu:
 
  This is used in conjunction with the STV0367 demodulator on
  the STV0367-NIM-V1.0 NIM card which can be used with the STi
  STB SoC's.
  
  This tuner has a fifth register, so some changes have been made
  to accommodate this.
  
  Signed-off-by: Peter Griffin peter.grif...@linaro.org
  ---
   drivers/media/dvb-frontends/dvb-pll.c | 74 
  +--
   drivers/media/dvb-frontends/dvb-pll.h |  1 +
   2 files changed, 64 insertions(+), 11 deletions(-)
  
  diff --git a/drivers/media/dvb-frontends/dvb-pll.c 
  b/drivers/media/dvb-frontends/dvb-pll.c
  index 6d8fe88..f7381c7 100644
  --- a/drivers/media/dvb-frontends/dvb-pll.c
  +++ b/drivers/media/dvb-frontends/dvb-pll.c
  @@ -141,6 +141,35 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
  },
   };
   
  +static void thomson_dtt7546x_bw(struct dvb_frontend *fe, u8 *buf)
  +{
  +   /* set CB2 reg - set ATC, XTO */
  +   buf[4] = 0xc3;
  +}
  +
  +static struct dvb_pll_desc dvb_pll_thomson_dtt7546x = {
  +   .name  = Thomson dtt7546x,
  +   .min   = 4425,
  +   .max   = 86325,
  +   .set   = thomson_dtt7546x_bw,
  +   .iffreq= 3617,
 
 Whitespace is missing. Please check the patchs with scripts/checkpatch.pl.

Will fix in V2.

regards,

Peter.
--
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 07/12] [media] tsin: c8sectpfe: STiH407/10 Linux DVB demux support

2015-07-30 Thread Peter Griffin
Hi Mauro,

Thanks for reviewing.

On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:

 Em Wed, 24 Jun 2015 16:11:05 +0100
 Peter Griffin peter.grif...@linaro.org escreveu:
 
  This patch adds support for the c8sectpfe input HW found on
  STiH407/410 SoC's.
  
  It currently supports the TS input block, memdma engine
  and hw PID filtering blocks of the C8SECTPFE subsystem.
  
  The driver creates one LinuxDVB adapter, and a
  demux/dvr/frontend set of devices for each tsin channel
  which is specificed in the DT. It has been tested with
  multiple tsin channels tuned, locked, and grabbing TS
  simultaneously.
  
  Signed-off-by: Peter Griffin peter.grif...@linaro.org
  ---
   drivers/media/tsin/c8sectpfe/c8sectpfe-core.c | 1105 
  +
   drivers/media/tsin/c8sectpfe/c8sectpfe-core.h |  288 +++
   2 files changed, 1393 insertions(+)
   create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
   create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-core.h
  
  diff --git a/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c 
  b/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
  new file mode 100644
  index 000..fbbe323
  --- /dev/null
  +++ b/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
  @@ -0,0 +1,1105 @@
  +/*
  + * c8sectpfe-core.c - C8SECTPFE STi DVB driver
  + *
  + * Copyright (c) STMicroelectronics 2015
  + *
  + *   Author:Peter Bennett peter.benn...@st.com
  + * Peter Griffin peter.grif...@linaro.org
  + *
  + * This program is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU General Public License as
  + * published by the Free Software Foundation; either version 2 of
  + * the License, or (at your option) any later version.
  + */
  +#include linux/clk.h
  +#include linux/completion.h
  +#include linux/delay.h
  +#include linux/device.h
  +#include linux/dma-mapping.h
  +#include linux/dvb/dmx.h
  +#include linux/dvb/frontend.h
  +#include linux/errno.h
  +#include linux/firmware.h
  +#include linux/init.h
  +#include linux/interrupt.h
  +#include linux/io.h
  +#include linux/module.h
  +#include linux/of_gpio.h
  +#include linux/of_platform.h
  +#include linux/platform_device.h
  +#include linux/usb.h
  +#include linux/slab.h
  +#include linux/time.h
  +#include linux/version.h
  +#include linux/wait.h
  +
  +#include c8sectpfe-core.h
  +#include c8sectpfe-common.h
  +#include c8sectpfe-debugfs.h
  +#include dmxdev.h
  +#include dvb_demux.h
  +#include dvb_frontend.h
  +#include dvb_net.h
  +
  +#define FIRMWARE_MEMDMA pti_memdma_h407.elf
  +MODULE_FIRMWARE(FIRMWARE_MEMDMA);
  +
  +#define PID_TABLE_SIZE 1024
  +#define POLL_20_HZ_DIV 20 /* poll at 20 Hz */
  +
  +static int load_slim_core_fw(struct c8sectpfei *fei);
  +
  +#define TS_PKT_SIZE 188
  +#define HEADER_SIZE (4)
  +#define PACKET_SIZE (TS_PKT_SIZE+HEADER_SIZE)
  +
  +#define FEI_ALIGNMENT (32)
  +/* hw requires minimum of 8*PACKET_SIZE and padded to 8byte boundary */
  +#define FEI_BUFFER_SIZE (8*PACKET_SIZE*340)
  +
  +#define FIFO_LEN 1024
  +
  +static void c8sectpfe_timer_interrupt(unsigned long ac8sectpfei)
  +{
  +   struct c8sectpfei *fei = (struct c8sectpfei *)ac8sectpfei;
  +   struct channel_info *channel;
  +   int chan_num;
  +
  +   /* iterate through input block channels */
  +   for (chan_num = 0; chan_num  fei-tsin_count; chan_num++) {
  +   channel = fei-channel_data[chan_num];
  +
  +   /* is this descriptor initialised and TP enabled */
  +   if (channel-irec  readl((void __iomem *)
  +   channel-irec-tp_enable))
  +   tasklet_schedule(channel-tsklet);
  +   }
  +
  +   fei-timer.expires = jiffies + (HZ / POLL_20_HZ_DIV);
 
 Please use the macros for jiffies conversions. In this case, I guess
 you want to use ms_to_jiffies(), right?

Fixed in V2.

 
  +   add_timer(fei-timer);
  +}
  +
  +static void channel_swdemux_tsklet(unsigned long data)
  +{
  +   struct channel_info *channel = (struct channel_info *)data;
  +   struct c8sectpfei *fei = channel-fei;
  +   struct tpentry *ptrblk;
  +   unsigned long wp, rp;
  +   int pos, num_packets, n, size;
  +   u8 *buf;
  +
  +   BUG_ON(!channel);
  +   BUG_ON(!channel-irec);
 
 Please avoid using BUG_ON() except when the machine will be on some
 unstable state. In this case, I guess you could just do:
 
   if (unlikely(!channel || !channel-irec)
   return;

Yes ok, I have removed the BUG_ON's in v2

 
  +
  +   ptrblk = channel-irec-ptr_data[0];
  +
  +   wp = readl((void __iomem *)ptrblk-dma_bus_wp);
  +   rp = readl((void __iomem *)ptrblk-dma_bus_rp);
 
 Why do you need those typecasts? We try to avoid typecasts in the Kernel,
 doing it only where really needed. Same for other usages. You should
 probably declare those DMA buffers as __iomem *, and avoid the casts.

Ok, I've fixed this in V2.

 
  +
  +   pos = rp - channel-back_buffer_busaddr;
  +
  +   /* has it wrapped */
  +   if (wp  rp)
  +  

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

2015-07-30 Thread Michael Ira Krufky
On Thu, Jul 30, 2015 at 6:08 AM, Joe Perches j...@perches.com wrote:
 On Thu, 2015-07-30 at 10:47 +0100, Peter Griffin wrote:
 Hi Mauro / Joe,

 On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:

  Em Wed, 24 Jun 2015 18:17:37 -0700
  Joe Perches j...@perches.com escreveu:
 
   On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
This is used in conjunction with the STV0367 demodulator on
the STV0367-NIM-V1.0 NIM card which can be used with the STi
STB SoC's.
  
   Barely associated to this specific patch, but for
   dvb-pll.c, another thing that seems possible is to
   convert the struct dvb_pll_desc uses to const and
   change the entries fixed array size from 12 to []
  
   It'd save a couple KB overall and remove ~5KB of data.
  
   $ size drivers/media/dvb-frontends/dvb-pll.o*
  text  data bss dec hex filename
  8520  15522120   121922fa0 
   drivers/media/dvb-frontends/dvb-pll.o.new
  5624  63632120   14107371b 
   drivers/media/dvb-frontends/dvb-pll.o.old
 
  Peter,
 
  Please add this patch on the next patch series you submit.

 Ok will do, I've added this patch with a slightly updated commit message
 to my series.

 Joe - Can I add your signed-off-by?

 Signed-off-by: Joe Perches j...@perches.com

Reviewed-by: Michael Ira Krufky mkru...@samsung.com

Joe, nice optimization - thanks for that.

With regards to Peter's patch, is this a digital-only tuner, or is it
a hybrid tuner?

The 5th byte that you send to the THOMSON DTT7546X seems to resemble
the 'auxiliary byte' that gets set in tuner-simple.c

I'm not sure that dvb-pll is the right place for this tuner
definition, if this is the case.  Maybe this definition belongs in
tuner-simple instead, if the pattern matches better there.

Mauro, can we hold off on merging Peter's patch until we resolve this?

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


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

2015-07-30 Thread Michael Ira Krufky
On Thu, Jul 30, 2015 at 7:14 AM, Michael Ira Krufky mkru...@linuxtv.org wrote:
 On Thu, Jul 30, 2015 at 6:08 AM, Joe Perches j...@perches.com wrote:
 On Thu, 2015-07-30 at 10:47 +0100, Peter Griffin wrote:
 Hi Mauro / Joe,

 On Wed, 22 Jul 2015, Mauro Carvalho Chehab wrote:

  Em Wed, 24 Jun 2015 18:17:37 -0700
  Joe Perches j...@perches.com escreveu:
 
   On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
This is used in conjunction with the STV0367 demodulator on
the STV0367-NIM-V1.0 NIM card which can be used with the STi
STB SoC's.
  
   Barely associated to this specific patch, but for
   dvb-pll.c, another thing that seems possible is to
   convert the struct dvb_pll_desc uses to const and
   change the entries fixed array size from 12 to []
  
   It'd save a couple KB overall and remove ~5KB of data.
  
   $ size drivers/media/dvb-frontends/dvb-pll.o*
  text  data bss dec hex filename
  8520  15522120   121922fa0 
   drivers/media/dvb-frontends/dvb-pll.o.new
  5624  63632120   14107371b 
   drivers/media/dvb-frontends/dvb-pll.o.old
 
  Peter,
 
  Please add this patch on the next patch series you submit.

 Ok will do, I've added this patch with a slightly updated commit message
 to my series.

 Joe - Can I add your signed-off-by?

 Signed-off-by: Joe Perches j...@perches.com

 Reviewed-by: Michael Ira Krufky m.kru...@samsung.com

 Joe, nice optimization - thanks for that.

 With regards to Peter's patch, is this a digital-only tuner, or is it
 a hybrid tuner?

 The 5th byte that you send to the THOMSON DTT7546X seems to resemble
 the 'auxiliary byte' that gets set in tuner-simple.c

 I'm not sure that dvb-pll is the right place for this tuner
 definition, if this is the case.  Maybe this definition belongs in
 tuner-simple instead, if the pattern matches better there.

 Mauro, can we hold off on merging Peter's patch until we resolve this?

 -Michael Ira Krufky

eek!  I mispelled my own email address.


With regards to Joe's patch - I'd like to see that merged.  ...and
here is my correctly spelled email address:


Reviewed-by: Michael Ira Krufky m.kru...@samsung.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