Re: DVB-S2 multistream support

2012-01-21 Thread Mauro Carvalho Chehab
Hi Christian,

Em 27-12-2011 08:12, Christian Prähauser escreveu:
>>
>> Yes, I'm meaning something like what it was described there. I think
>> that the code written by Christian were never submitted upstream.
>>
> 
> Hello Mauro,
> 
> Konstantin drew my attention to this discussion. Indeed, some time ago I 
> wrote 
> a base-band demux for LinuxDVB. It was part of a project to integrate support 
> for second-generation IP/DVB encapsulations (GSE). The BB-demux allows to
> register filters for different ISIs and data types (raw, generic stream,
> transport stream).
> 
> I realized that the repo hosted at our University is down. If there is 
> interest,
> I can update my patches to the latest LinuxDVB version and we can put them on 
> a 
> public repo e.g. at linuxdvb.org.

Sorry, I didn't notice your comment on this thread until today. It sounds
interesting. Please post the patches at the ML, when they're available, for
us to review.

Thanks!
Mauro
> 
> Kind regards,
> Christian.
>  
> 
> 
> 
> 
> 
> --
> 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

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


Realtek RTL2831U

2012-01-21 Thread Antti Palosaari

Hello

I picked up again my old RTL2831U tree and upgraded to current level. It 
supports only RTL2831U, not RTL2832U or any other. I think I will 
pull-request it to the master in hope it get development effort. I have 
no time for it. It is working, but does not do anything extra - just 
show DVB-T picture. Only NEC remote. No signal statistics. No other USB 
IDs than Realtek reference and 14aa:0160 has my device. New USB IDs 
(patch or mail) are welcome.


Here it is, PULL request is sent next week.
http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/realtek


For the newer Realtek devices that same USB-bridge could be used, I 
named it dvb_usb_rtl28xxu. I tested it also using RTL2832U and it 
worked. RTL2832 demod driver I was using is stubbed test version and 
thus I will not release it. Feel free to write RTL2832 demod driver :-)


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


Re: [PATCH v2] media i.MX27 camera: properly detect frame loss.

2012-01-21 Thread Guennadi Liakhovetski
Hi Javier

Please, excuse my curiosity and bear with my lack of understanding :-)

On Wed, 11 Jan 2012, Javier Martin wrote:

> As V4L2 specification states, frame_count must also
> regard lost frames so that the user can handle that
> case properly.
> 
> This patch adds a mechanism to increment the frame
> counter even when a video buffer is not available
> and a discard buffer is used.
> 
> ---
> Changes since v1:
>  - Initialize "frame_count" to -1 instead of using
>"firstirq" variable.
> 
> Signed-off-by: Javier Martin 
> ---
>  drivers/media/video/mx2_camera.c |   45 -
>  1 files changed, 24 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/media/video/mx2_camera.c 
> b/drivers/media/video/mx2_camera.c
> index ca76dd2..68038e7 100644
> --- a/drivers/media/video/mx2_camera.c
> +++ b/drivers/media/video/mx2_camera.c
> @@ -369,7 +369,7 @@ static int mx2_camera_add_device(struct soc_camera_device 
> *icd)
>   writel(pcdev->csicr1, pcdev->base_csi + CSICR1);
>  
>   pcdev->icd = icd;
> - pcdev->frame_count = 0;
> + pcdev->frame_count = -1;

I'm adding a comment above this line:

+   /* Discard the first frame, begin valid frames with 0 */

>  
>   dev_info(icd->parent, "Camera driver attached to camera %d\n",
>icd->devnum);
> @@ -572,6 +572,7 @@ static void mx2_videobuf_queue(struct videobuf_queue *vq,
>   struct soc_camera_host *ici =
>   to_soc_camera_host(icd->parent);
>   struct mx2_camera_dev *pcdev = ici->priv;
> + struct mx2_fmt_cfg *prp = pcdev->emma_prp;
>   struct mx2_buffer *buf = container_of(vb, struct mx2_buffer, vb);
>   unsigned long flags;
>  
> @@ -584,6 +585,26 @@ static void mx2_videobuf_queue(struct videobuf_queue *vq,
>   list_add_tail(&vb->queue, &pcdev->capture);
>  
>   if (mx27_camera_emma(pcdev)) {
> + if (prp->cfg.channel == 1) {
> + writel(PRP_CNTL_CH1EN |
> + PRP_CNTL_CSIEN |
> + prp->cfg.in_fmt |
> + prp->cfg.out_fmt |
> + PRP_CNTL_CH1_LEN |
> + PRP_CNTL_CH1BYP |
> + PRP_CNTL_CH1_TSKIP(0) |
> + PRP_CNTL_IN_TSKIP(0),
> + pcdev->base_emma + PRP_CNTL);
> + } else {
> + writel(PRP_CNTL_CH2EN |
> + PRP_CNTL_CSIEN |
> + prp->cfg.in_fmt |
> + prp->cfg.out_fmt |
> + PRP_CNTL_CH2_LEN |
> + PRP_CNTL_CH2_TSKIP(0) |
> + PRP_CNTL_IN_TSKIP(0),
> + pcdev->base_emma + PRP_CNTL);
> + }

Enabling the channel on each QBUF didn't seem like a good idea to me, so,
I looked a bit further. If you really want to be extremely careful to only
capture frames, when so requested by the user, don't you have to disable
channels upom STREAMOFF, i.e., when the last buffer is released by
.buf_release()? I don't think it makes sense to keep counting buffers, 
when not streaming - they are not really lost. So, wouldn't something like 
this not be better:

if (mx27_camera_emma(pcdev)) {
+   if (pcdev->frame_count < 0)
+   mx27_camera_emma_channel_enable(prp);

and then disable in .buf_release() if your queue is empty?

>   goto out;

I think, this goto shall die, and with it the label too.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [RFC] dvb: Add DVBv5 properties for quality parameters

2012-01-21 Thread Mauro Carvalho Chehab
Hi Antti,

This patch is a return of the discussions that started in 2009 with those
patches:
http://patchwork.linuxtv.org/patch/1883/
http://patchwork.linuxtv.org/patch/2262/
http://patchwork.linuxtv.org/patch/2280/


Em 21-01-2012 15:04, Antti Palosaari escreveu:
> On 01/20/2012 02:38 PM, Mauro Carvalho Chehab wrote:
> 
> Basically I would like to ask slow down API changes since it causes all the 
> problems and extra work.

In this specific case, this is an API addition. At least from my side,
I'm not planning for 3.4 to change the existing drivers for it, except 
for the ISDB-T ones, where the current statistics don't work.

So, I'm not expecting such addition to break anything on existing drivers.

> Rather than always doing API changes of our perspective I would like to ask 
> if it is possible to ask applications developers to help? Situation is very 
> weird, 
> almost all applications are using old APIs whilst we have had newer one many 
> years...
> If application makers are attending to API changes then most likely those 
> APIs 
> and new features are taken use sooner.

Application feedback is always very welcome.

One of the reasons I decided to work on a library/userspace app is
due to this gap. DVBv3 is very comfortable for people using DVB-T/S/C and
ATSC, as the current applications work fine, but this is not true for
ISDB-T. 

The emulation mode is far from ideal. For example,  I can't properly
submit  scanning tables for ISDB-T to the applications, as the tables 
are not for DVB-T, but for a DVBv3 unsupported standard. So, ISDB-T
users need to seek at some Portuguese sites, where there are some
pages explaining how to make the existing applications to work with
ISDB-T, and a scanning table for 6MHz freqs is provided.

After working on such library, I think I noticed why the current 
applications weren't ported to DVBv5:

1) Lack of DVBv5 specs. The specs for it were covering
only ISDB-T (and still with errors), until a very recent kernel.
The first kernel where the specs will likely be 100% with regards
to frontend will be Kernel 3.3, after the fixes for ISDB-T and
DVB-S;

2) Lack of a good example on how to do it;

3) Lack of a per-delivery system relation of properties.
I'm seriously considering to move the dvbv5-std.h header I wrote
for the libraries to the DVB frontend.h file. This can be used by
dvb_frontend.c in order to check if userspace is passing the right
properties per delivery system, returning -EINVAL if a delivery
system unsupported is passed via FE_SET_PROPERTY. Userspace apps
can also use it, in order to prepare their commands.

4) Lack of a per-delivery-system validation/documentation
of the acceptable values for each DTV property (one application 
developer from a widely used scanning tool complained about that 
with me);

5) It is currently not possible to use only DVBv5 for talking
with the frontend, as several DTV commands that don't seem to be
properly implemented (like, for example, DTV_DISEQC_SLAVE_REPLY,
and DTV_PILOT [1]).

(1) and (2)  were solved at the beginning of this year. (3) were
solved at library level.

So, IMHO, what we should do is the reverse: fix the issues with the
DVBv5, document it properly and create a DVBv5 library that can be
used by userspace applications.

Of course, we should avoid regressions while doing that.

On my todo list, as time allows me to do it, and if the developers 
themselves don't properly implement DVBv5 earlier, is to write
some patches for the applications I use, porting them to use the
library, and submitting such patches to the application developers
and likely merging them also into Fedora.

There aren't many things missed there. The only things related to
the frontend API that I'm aware of are:

- Quality/Stats API (this RFC);
- CMDB delivery system;
- ATSC/MH delivery system;
- DSS delivery system;
- a flag to indicate that TMCC/TPS carrier is decoded;
- implement the non_implemented commands (or to remove
  them from the API);
- a replacement for FE caps that would carry the new
  delivery systems values and modulation types.

IMHO, we should focus on solving most of those for 3.4 and 3.5,
while discussing with application guys about what else is pending
for their adoption of DVBv5.

Regards,
Mauro.

[1] DTV_VOLTAGE and DTV_TONE are implemented via a DVBv3 internal
call - not sure if they're working or not. I doubt that anyone
had ever tried to implement satellite LNBf/DISEqC set using DVBv5.
Even on my DVBv5 library, I'm using DVBv3 for LNBf/DISEqC.

> 
>> The DVBv3 quality parameters are limited on several ways:
>> - Doesn't provide any way to indicate the used measure;
>> - Userspace need to guess how to calculate the measure;
>> - Only a limited set of stats are supported;
>> - Doesn't provide QoS measure for the OFDM TPS/TMCC
>>   carriers, used to detect th

cron job: media_tree daily build: ERRORS

2012-01-21 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:Sat Jan 21 19:00:19 CET 2012
git hash:9e5e3097a3febbf317abc6d1b07bc6c33b20c279
gcc version:  i686-linux-gcc (GCC) 4.6.2
host hardware:x86_64
host os:  3.1-2.slh.1-amd64

linux-git-arm-eabi-enoxys: WARNINGS
linux-git-arm-eabi-omap: ERRORS
linux-git-armv5-ixp: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: OK
linux-git-mips: WARNINGS
linux-git-powerpc64: OK
linux-git-x86_64: WARNINGS
linux-2.6.31.12-i686: WARNINGS
linux-2.6.32.6-i686: WARNINGS
linux-2.6.33-i686: WARNINGS
linux-2.6.34-i686: WARNINGS
linux-2.6.35.3-i686: WARNINGS
linux-2.6.36-i686: WARNINGS
linux-2.6.37-i686: WARNINGS
linux-2.6.38.2-i686: WARNINGS
linux-2.6.39.1-i686: WARNINGS
linux-3.0-i686: WARNINGS
linux-3.1-i686: WARNINGS
linux-3.2.1-i686: WARNINGS
linux-2.6.31.12-x86_64: WARNINGS
linux-2.6.32.6-x86_64: WARNINGS
linux-2.6.33-x86_64: WARNINGS
linux-2.6.34-x86_64: WARNINGS
linux-2.6.35.3-x86_64: WARNINGS
linux-2.6.36-x86_64: WARNINGS
linux-2.6.37-x86_64: WARNINGS
linux-2.6.38.2-x86_64: WARNINGS
linux-2.6.39.1-x86_64: WARNINGS
linux-3.0-x86_64: WARNINGS
linux-3.1-x86_64: WARNINGS
linux-3.2.1-x86_64: WARNINGS
apps: WARNINGS
spec-git: WARNINGS
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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

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

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


Re: [PATCH] [RFC] dvb: Add DVBv5 properties for quality parameters

2012-01-21 Thread Antti Palosaari

On 01/20/2012 02:38 PM, Mauro Carvalho Chehab wrote:

Basically I would like to ask slow down API changes since it causes all 
the problems and extra work.


Rather than always doing API changes of our perspective I would like to 
ask if it is possible to ask applications developers to help? Situation 
is very weird, almost all applications are using old APIs whilst we have 
had newer one many years... If application makers are attending to API 
changes then most likely those APIs and new features are taken use sooner.



The DVBv3 quality parameters are limited on several ways:
- Doesn't provide any way to indicate the used measure;
- Userspace need to guess how to calculate the measure;
- Only a limited set of stats are supported;
- Doesn't provide QoS measure for the OFDM TPS/TMCC
  carriers, used to detect the network parameters for
  DVB-T/ISDB-T;
- Can't be called in a way to require them to be filled
  all at once (atomic reads from the hardware), with may
  cause troubles on interpreting them on userspace;
- On some OFDM delivery systems, the carriers can be
  independently modulated, having different properties.
  Currently, there's no way to report per-layer stats;

This RFC adds the header definitions meant to solve that issues.
After discussed, I'll write a patch for the DocBook and add support
for it on some demods. Support for dvbv5-zap and dvbv5-scan tools
will also have support for those features.

Signed-off-by: Mauro Carvalho Chehab
---
  include/linux/dvb/frontend.h |   78 +-
  1 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/include/linux/dvb/frontend.h b/include/linux/dvb/frontend.h
index cb4428a..f9cdb7d 100644
--- a/include/linux/dvb/frontend.h
+++ b/include/linux/dvb/frontend.h
@@ -320,7 +320,21 @@ struct dvb_frontend_event {

  #define DTV_ENUM_DELSYS   44

-#define DTV_MAX_COMMANDDTV_ENUM_DELSYS
+/* Quality parameters */
+#define DTV_ENUM_QUALITY   45  /* Enumerates supported QoS parameters 
*/
+#define DTV_QUALITY_SNR46
+#define DTV_QUALITY_CNR47
+#define DTV_QUALITY_EsNo   48
+#define DTV_QUALITY_EbNo   49
+#define DTV_QUALITY_RELATIVE   50


Rather many ways to report signal quality. Is it possible to reduce?
I have feeling having this many different ways to report single subject 
causes app devels to likely skip whole reporting :]



+#define DTV_ERROR_BER  51
+#define DTV_ERROR_PER  52
+#define DTV_ERROR_PARAMS   53  /* Error count at TMCC or TPS carrier */


No enumeration for two bit error rate methods like quality?
I don't still see much difference if it is BER or PER. Users usually 
just want look if there is some errors and compare to uncorrected blocks 
or picture to see if those can be fixed be demod (inner FEC). Random 
running numbers for error rate is just enough, unless you are not making 
some measurement equipment :]



+#define DTV_FE_STRENGTH54
+#define DTV_FE_SIGNAL  55


What is difference these two?


+#define DTV_FE_UNC 56
+
+#define DTV_MAX_COMMANDDTV_FE_UNC

  typedef enum fe_pilot {
PILOT_ON,
@@ -372,12 +386,74 @@ struct dtv_cmds_h {
__u32   reserved:30;/* Align */
  };

+/**
+ * Scale types for the quality parameters.
+ * @FE_SCALE_DECIBEL: The scale is measured in dB, typically
+ *   used on signal measures.
+ * @FE_SCALE_LINEAR: The scale is linear.
+ *  typically used on error QoS parameters.
+ * @FE_SCALE_RELATIVE: The scale is relative.
+ */
+enum fecap_scale_params {
+   FE_SCALE_DECIBEL,
+   FE_SCALE_LINEAR,
+   FE_SCALE_RELATIVE
+};


If we end up defining own commands for SNR/CNR/EsNo/EbNo/RELATIVE I 
don't see need to define scale any-more. Almost all those uses de Facto 
scale as dB. Define scale per measurement and use that.



+
+/**
+ * struct dtv_status - Used for reading a DTV status property
+ *
+ * @value: value of the measure. Should range from 0 to 0x;
+ * @scale: Filled with enum fecap_scale_params - the scale
+ * in usage for that parameter
+ * @min:   minimum value. Not used if the scale is relative.
+ * For non-relative measures, define the measure
+ * associated with dtv_status.value == 0.
+ * @max:   maximum value. Not used if the scale is relative.
+ * For non-relative measures, define the measure
+ * associated with dtv_status.value == 0x.
+ *
+ * At userspace, min/max values should be used to calculate the
+ * absolute value of that measure, if fecap_scale_params is not
+ * FE_SCALE_RELATIVE, using the following formula:
+ *  measure = min + (value * (max - min) / 0x)
+ *
+ * For error count measures, typically, min = 0, and max = 0x,
+ * and the measure rep

Re: mygica hdcap

2012-01-21 Thread Devin Heitmueller
On Sat, Jan 21, 2012 at 11:07 AM, Nathan  wrote:
> Any progress made with this?  I have this same card and I can't find a
> datasheet for tm6200.

Nobody has written an open source driver for the tm6200 (and nobody is
in the process of doing such), and there are no publicly available
datasheets for the part.

Devin

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


RE: mygica hdcap

2012-01-21 Thread Nathan
On Mar 10, 2011, at 12:26 PM, James Klaas wrote:

> I just got one of these the other day and I was wondering if anyone
> has looked at it.  It will take HDMI, component and composite input
> plus stereo.  I have a picture I can post somewhere of the board.  It
> has 3 main chips.
> 
> AD9985A - Component/composite input?
> SIL9013CLU - Audio input?
> TM6202 - HDMI input
> 
> I'm not sure if this falls under v4l since it has no tuner or dvb
> since it captures digital video.


Any progress made with this?  I have this same card and I can't find a
datasheet for tm6200.

Nate


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


[PATCH 20/35] [media] az6007: Use the new MFE support at dvb-usb

2012-01-21 Thread Mauro Carvalho Chehab
Use the newly dvb-usb MFE support added by
changeset 9bd9e3bd2c57530dfe3057dd0aa9bdb37824925d.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   74 ++-
 1 files changed, 38 insertions(+), 36 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index c9b6f80..b667854 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -59,7 +59,7 @@ struct az6007_device_state {
/* Due to DRX-K - probably need changes */
int (*gate_ctrl) (struct dvb_frontend *, int);
struct  semaphore pll_mutex;
-   booldont_attach_fe1;
+   booltuner_attached;
 };
 
 static struct drxk_config terratec_h7_drxk = {
@@ -290,56 +290,56 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
 {
struct az6007_device_state *st = adap->priv;
 
-   int result;
+   /* FIXME: dvb-usb will call this function twice! */
+   if (adap->fe[0])
+   return 0;
 
BUG_ON(!st);
 
az6007_frontend_poweron(adap);
 
-   info("az6007: attaching demod drxk");
-   adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
- &adap->dev->i2c_adap, &adap->fe2);
-   if (!adap->fe) {
-   result = -EINVAL;
-   goto out_free;
-   }
-
-   deb_info("Setting hacks\n");
+   info("attaching demod drxk");
+   adap->fe[0] = dvb_attach(drxk_attach, &terratec_h7_drxk,
+&adap->dev->i2c_adap, &adap->fe[1]);
+   if (!adap->fe[0])
+   return -EINVAL;
 
+   adap->fe[0]->sec_priv = adap;
/* FIXME: do we need a pll semaphore? */
-   adap->fe->sec_priv = adap;
sema_init(&st->pll_mutex, 1);
-   st->gate_ctrl = adap->fe->ops.i2c_gate_ctrl;
-   adap->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
-   adap->fe2->id = 1;
+   st->gate_ctrl = adap->fe[0]->ops.i2c_gate_ctrl;
+   adap->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
+   adap->dont_attach_fe[1] = true;
+
+   return 0;
+}
+
+static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
+{
+   struct az6007_device_state *st = adap->priv;
+
+   if (st->tuner_attached)
+   return 0;
+
+   st->tuner_attached = true;
 
-   info("az6007: attaching tuner mt2063");
+   info("attaching tuner mt2063");
/* Attach mt2063 to DVB-C frontend */
-   if (adap->fe->ops.i2c_gate_ctrl)
-   adap->fe->ops.i2c_gate_ctrl(adap->fe, 1);
-   if (!dvb_attach(mt2063_attach, adap->fe, &az6007_mt2063_config,
-   &adap->dev->i2c_adap)) {
-   result = -EINVAL;
+   if (adap->fe[0]->ops.i2c_gate_ctrl)
+   adap->fe[0]->ops.i2c_gate_ctrl(adap->fe[0], 1);
+   if (!dvb_attach(mt2063_attach, adap->fe[0], &az6007_mt2063_config,
+   &adap->dev->i2c_adap))
+   return -EINVAL;
 
-   goto out_free;
-   }
-   if (adap->fe->ops.i2c_gate_ctrl)
-   adap->fe->ops.i2c_gate_ctrl(adap->fe, 0);
+   if (adap->fe[0]->ops.i2c_gate_ctrl)
+   adap->fe[0]->ops.i2c_gate_ctrl(adap->fe[0], 0);
 
/* Hack - needed due to drxk */
-   adap->fe2->tuner_priv = adap->fe->tuner_priv;
-   memcpy(&adap->fe2->ops.tuner_ops,
-  &adap->fe->ops.tuner_ops, sizeof(adap->fe->ops.tuner_ops));
+   adap->fe[1]->tuner_priv = adap->fe[0]->tuner_priv;
+   memcpy(&adap->fe[1]->ops.tuner_ops,
+  &adap->fe[0]->ops.tuner_ops, sizeof(adap->fe[0]->ops.tuner_ops));
 
return 0;
-
-out_free:
-   if (adap->fe)
-   dvb_frontend_detach(adap->fe);
-   adap->fe = NULL;
-   adap->fe2 = NULL;
-
-   return result;
 }
 
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
@@ -530,7 +530,9 @@ static struct dvb_usb_device_properties az6007_properties = 
{
.num_adapters = 1,
.adapter = {
{
+   .num_frontends= 2,
.streaming_ctrl   = az6007_streaming_ctrl,
+   .tuner_attach = az6007_tuner_attach,
.frontend_attach  = az6007_frontend_attach,
 
/* parameter for the MPEG2-data transfer */
-- 
1.7.8

--
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 19/35] [media] az6007: improve the error messages for az6007 read/write calls

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index c9743ee..c9b6f80 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -110,16 +110,15 @@ static struct mt2063_config az6007_mt2063_config = {
 static int az6007_read(struct usb_device *udev, u8 req, u16 value,
u16 index, u8 *b, int blen)
 {
-   int ret = -1;
+   int ret;
 
ret = usb_control_msg(udev,
  usb_rcvctrlpipe(udev, 0),
  req,
  USB_TYPE_VENDOR | USB_DIR_IN,
  value, index, b, blen, 5000);
-
if (ret < 0) {
-   warn("usb in operation failed. (%d)", ret);
+   warn("usb read operation failed. (%d)", ret);
return -EIO;
}
 
@@ -151,7 +150,7 @@ static int az6007_write(struct usb_device *udev, u8 req, 
u16 value,
  USB_TYPE_VENDOR | USB_DIR_OUT,
  value, index, b, blen, 5000);
if (ret != blen) {
-   err("usb out operation failed. (%d)", ret);
+   err("usb write operation failed. (%d)", ret);
return -EIO;
}
 
-- 
1.7.8

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


[PATCH 22/35] [media] az6007: Use a per device private struct

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   11 +--
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 92ded30..342f929 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -82,7 +82,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
if (!adap)
return -EINVAL;
 
-   st = adap->priv;
+   st = adap->dev->priv;
 
if (!st)
return -EINVAL;
@@ -288,7 +288,7 @@ static int az6007_led_on_off(struct usb_interface *intf, 
int onoff)
 
 static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
-   struct az6007_device_state *st = adap->priv;
+   struct az6007_device_state *st = adap->dev->priv;
 
BUG_ON(!st);
 
@@ -311,7 +311,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
 
 static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 {
-   struct az6007_device_state *st = adap->priv;
+   struct az6007_device_state *st = adap->dev->priv;
 
if (st->tuner_attached)
return 0;
@@ -516,8 +516,8 @@ static struct dvb_usb_device_properties az6007_properties = 
{
.usb_ctrl = CYPRESS_FX2,
.firmware= "dvb-usb-terratec-h7-az6007.fw",
.no_reconnect= 1,
-
-   .identify_state = az6007_identify_state,
+   .size_of_priv= sizeof(struct az6007_device_state),
+   .identify_state  = az6007_identify_state,
.num_adapters = 1,
.adapter = {
{
@@ -538,7 +538,6 @@ static struct dvb_usb_device_properties az6007_properties = 
{
}
}
},
-   .size_of_priv = sizeof(struct az6007_device_state),
}}
} },
.power_ctrl   = az6007_power_ctrl,
-- 
1.7.8

--
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 25/35] [media] drxk: add support for Mpeg output clock drive strength config

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c  |3 +--
 drivers/media/dvb/frontends/drxk.h  |4 +++-
 drivers/media/dvb/frontends/drxk_hard.c |   12 ++--
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 00a0bf1..bf8d201 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -69,6 +69,7 @@ static struct drxk_config terratec_h7_drxk = {
.single_master = true,
.no_i2c_bridge = false,
.chunk_size = 64,
+   .mpeg_out_clk_strength = 0x02,
.microcode_name = "dvb-usb-terratec-h7-az6007.fw",
 };
 
@@ -278,12 +279,10 @@ static int az6007_led_on_off(struct usb_interface *intf, 
int onoff)
 {
struct usb_device *udev = interface_to_usbdev(intf);
int ret;
-
/* TS through */
ret = az6007_write(udev, AZ6007_POWER, onoff, 0, NULL, 0);
if (ret < 0)
err("%s failed with error %d", __func__, ret);
-
return ret;
 }
 
diff --git a/drivers/media/dvb/frontends/drxk.h 
b/drivers/media/dvb/frontends/drxk.h
index 6b0fd2c..ca921c7 100644
--- a/drivers/media/dvb/frontends/drxk.h
+++ b/drivers/media/dvb/frontends/drxk.h
@@ -17,6 +17,7 @@
  * @antenna_gpio:  GPIO bit used to control the antenna
  * @antenna_dvbt:  GPIO bit for changing antenna to DVB-C. A value of 1
  * means that 1=DVBC, 0 = DVBT. Zero means the opposite.
+ * @mpeg_out_clk_strength: DRXK Mpeg output clock drive strength.
  * @microcode_name:Name of the firmware file with the microcode
  *
  * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is
@@ -32,7 +33,8 @@ struct drxk_config {
boolantenna_dvbt;
u16 antenna_gpio;
 
-   intchunk_size;
+   u8  mpeg_out_clk_strength;
+   int chunk_size;
 
const char *microcode_name;
 };
diff --git a/drivers/media/dvb/frontends/drxk_hard.c 
b/drivers/media/dvb/frontends/drxk_hard.c
index 6570396..d25b0d2 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -91,10 +91,6 @@ bool IsA1WithRomCode(struct drxk_state *state)
 #define DRXK_MPEG_PARALLEL_OUTPUT_PIN_DRIVE_STRENGTH (0x03)
 #endif
 
-#ifndef DRXK_MPEG_OUTPUT_CLK_DRIVE_STRENGTH
-#define DRXK_MPEG_OUTPUT_CLK_DRIVE_STRENGTH (0x06)
-#endif
-
 #define DEFAULT_DRXK_MPEG_LOCK_TIMEOUT 700
 #define DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT 500
 
@@ -659,7 +655,6 @@ static int init_state(struct drxk_state *state)
u32 ulGPIOCfg = 0x0113;
u32 ulInvertTSClock = 0;
u32 ulTSDataStrength = DRXK_MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH;
-   u32 ulTSClockkStrength = DRXK_MPEG_OUTPUT_CLK_DRIVE_STRENGTH;
u32 ulDVBTBitrate = 5000;
u32 ulDVBCBitrate = DRXK_QAM_SYMBOLRATE_MAX * 8;
 
@@ -820,7 +815,6 @@ static int init_state(struct drxk_state *state)
state->m_DVBCBitrate = ulDVBCBitrate;
 
state->m_TSDataStrength = (ulTSDataStrength & 0x07);
-   state->m_TSClockkStrength = (ulTSClockkStrength & 0x07);
 
/* Maximum bitrate in b/s in case static clockrate is selected */
state->m_mpegTsStaticBitrate = 19392658;
@@ -6394,6 +6388,12 @@ struct dvb_frontend *drxk_attach(const struct 
drxk_config *config,
state->m_DVBCStaticCLK = 1;
}
 
+
+   if (config->mpeg_out_clk_strength)
+   state->m_TSClockkStrength = config->mpeg_out_clk_strength & 
0x07;
+   else
+   state->m_TSClockkStrength = 0x06;
+
if (config->parallel_ts)
state->m_enableParallel = true;
else
-- 
1.7.8

--
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/35] [media] az6007: Use DRX-K dynamic clock mode

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 342f929..00a0bf1 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -64,11 +64,12 @@ struct az6007_device_state {
 
 static struct drxk_config terratec_h7_drxk = {
.adr = 0x29,
-   .single_master = 1,
-   .no_i2c_bridge = 0,
+   .parallel_ts = true,
+   .dynamic_clk = true,
+   .single_master = true,
+   .no_i2c_bridge = false,
.chunk_size = 64,
-   .microcode_name = "dvb-usb-terratec-h7-drxk.fw",
-   .parallel_ts = 1,
+   .microcode_name = "dvb-usb-terratec-h7-az6007.fw",
 };
 
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
-- 
1.7.8

--
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 26/35] [media] drxk: Allow enabling MERR/MVAL cfg

2012-01-21 Thread Mauro Carvalho Chehab
Those two settings are different when used with az6007. Add
a config option to enable it.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c  |1 +
 drivers/media/dvb/frontends/drxk.h  |2 ++
 drivers/media/dvb/frontends/drxk_hard.c |   11 +--
 drivers/media/dvb/frontends/drxk_hard.h |1 +
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index bf8d201..81fdc90 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -67,6 +67,7 @@ static struct drxk_config terratec_h7_drxk = {
.parallel_ts = true,
.dynamic_clk = true,
.single_master = true,
+   .enable_merr_cfg = true,
.no_i2c_bridge = false,
.chunk_size = 64,
.mpeg_out_clk_strength = 0x02,
diff --git a/drivers/media/dvb/frontends/drxk.h 
b/drivers/media/dvb/frontends/drxk.h
index ca921c7..9d64e4f 100644
--- a/drivers/media/dvb/frontends/drxk.h
+++ b/drivers/media/dvb/frontends/drxk.h
@@ -12,6 +12,7 @@
  * Serial otherwise.
  * @dynamic_clk:   True means that the clock will be dynamically
  * adjusted. Static clock otherwise.
+ * @enable_merr_cfg:   Enable SIO_PDR_PERR_CFG/SIO_PDR_MVAL_CFG.
  * @single_master: Device is on the single master mode
  * @no_i2c_bridge: Don't switch the I2C bridge to talk with tuner
  * @antenna_gpio:  GPIO bit used to control the antenna
@@ -29,6 +30,7 @@ struct drxk_config {
boolno_i2c_bridge;
boolparallel_ts;
booldynamic_clk;
+   boolenable_merr_cfg;
 
boolantenna_dvbt;
u16 antenna_gpio;
diff --git a/drivers/media/dvb/frontends/drxk_hard.c 
b/drivers/media/dvb/frontends/drxk_hard.c
index d25b0d2..5fa1927 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -1179,6 +1179,7 @@ static int MPEGTSConfigurePins(struct drxk_state *state, 
bool mpegEnable)
int status = -1;
u16 sioPdrMclkCfg = 0;
u16 sioPdrMdxCfg = 0;
+   u16 err_cfg = 0;
 
dprintk(1, ": mpeg %s, %s mode\n",
mpegEnable ? "enable" : "disable",
@@ -1244,12 +1245,17 @@ static int MPEGTSConfigurePins(struct drxk_state 
*state, bool mpegEnable)
status = write16(state, SIO_PDR_MSTRT_CFG__A, sioPdrMdxCfg);
if (status < 0)
goto error;
-   status = write16(state, SIO_PDR_MERR_CFG__A, 0x);   /* 
Disable */
+
+   if (state->enable_merr_cfg)
+   err_cfg = sioPdrMdxCfg;
+
+   status = write16(state, SIO_PDR_MERR_CFG__A, err_cfg);
if (status < 0)
goto error;
-   status = write16(state, SIO_PDR_MVAL_CFG__A, 0x);   /* 
Disable */
+   status = write16(state, SIO_PDR_MVAL_CFG__A, err_cfg);
if (status < 0)
goto error;
+
if (state->m_enableParallel == true) {
/* paralel -> enable MD1 to MD7 */
status = write16(state, SIO_PDR_MD1_CFG__A, 
sioPdrMdxCfg);
@@ -6379,6 +6385,7 @@ struct dvb_frontend *drxk_attach(const struct drxk_config 
*config,
state->antenna_gpio = config->antenna_gpio;
state->antenna_dvbt = config->antenna_dvbt;
state->m_ChunkSize = config->chunk_size;
+   state->enable_merr_cfg = config->enable_merr_cfg;
 
if (config->dynamic_clk) {
state->m_DVBTStaticCLK = 0;
diff --git a/drivers/media/dvb/frontends/drxk_hard.h 
b/drivers/media/dvb/frontends/drxk_hard.h
index 3a58b73..4bbf841 100644
--- a/drivers/media/dvb/frontends/drxk_hard.h
+++ b/drivers/media/dvb/frontends/drxk_hard.h
@@ -332,6 +332,7 @@ struct drxk_state {
 
u16 UIO_mask;   /* Bits used by UIO */
 
+   boolenable_merr_cfg;
boolsingle_master;
boolno_i2c_bridge;
boolantenna_dvbt;
-- 
1.7.8

--
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/35] [media] az6007: code cleanups and fixes

2012-01-21 Thread Mauro Carvalho Chehab
Several changes were needed to make az6007 to work, producing
the same commands as the original driver. This patch does
that.

While here, be less verbose when debug is not enabled.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |  148 
 1 files changed, 83 insertions(+), 65 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 81fdc90..f0e4c01 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -54,12 +54,16 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 struct az6007_device_state {
struct  dvb_ca_en50221 ca;
struct  mutex ca_mutex;
-   u8  power_state;
+   unsignedwarm : 1;
 
/* Due to DRX-K - probably need changes */
int (*gate_ctrl) (struct dvb_frontend *, int);
struct  semaphore pll_mutex;
booltuner_attached;
+
+   unsigned char   data[4096];
+
+   struct usb_data_stream *stream;
 };
 
 static struct drxk_config terratec_h7_drxk = {
@@ -71,7 +75,7 @@ static struct drxk_config terratec_h7_drxk = {
.no_i2c_bridge = false,
.chunk_size = 64,
.mpeg_out_clk_strength = 0x02,
-   .microcode_name = "dvb-usb-terratec-h7-az6007.fw",
+   .microcode_name = "dvb-usb-terratec-h7-drxk.fw",
 };
 
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
@@ -162,7 +166,9 @@ static int az6007_write(struct usb_device *udev, u8 req, 
u16 value,
 
 static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 {
-   return 0;
+   deb_info("%s: %s", __func__, onoff ? "enable" : "disable");
+
+   return az6007_write(adap->dev->udev, 0xbc, onoff, 0, NULL, 0);
 }
 
 /* keys for the enclosed remote control */
@@ -236,46 +242,6 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, 
u8 mac[6])
return ret;
 }
 
-static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
-{
-   int ret;
-   struct usb_device *udev = adap->dev->udev;
-
-   deb_info("%s: adap=%p adap->dev=%p\n", __func__, adap, adap->dev);
-
-   ret = az6007_write(udev, AZ6007_POWER, 0, 2, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep(150);
-   ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep(100);
-   ret = az6007_write(udev, AZ6007_POWER, 1, 3, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep(100);
-   ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep(100);
-   ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep (10);
-   ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep (10);
-   ret = az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
-
-error:
-   if (ret < 0)
-   err("%s failed with error %d", __func__, ret);
-
-   return ret;
-}
-
 static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 {
struct usb_device *udev = interface_to_usbdev(intf);
@@ -293,9 +259,8 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
 
BUG_ON(!st);
 
-   az6007_frontend_poweron(adap);
+   deb_info("attaching demod drxk");
 
-   info("attaching demod drxk");
adap->fe_adap[0].fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
 &adap->dev->i2c_adap);
if (!adap->fe_adap[0].fe)
@@ -319,11 +284,11 @@ static int az6007_tuner_attach(struct dvb_usb_adapter 
*adap)
 
st->tuner_attached = true;
 
-   info("attaching tuner mt2063");
+   deb_info("attaching tuner mt2063");
/* Attach mt2063 to DVB-C frontend */
if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 1);
-   if (!dvb_attach(mt2063_attach, adap->fe_adap[0].fe, 
+   if (!dvb_attach(mt2063_attach, adap->fe_adap[0].fe,
&az6007_mt2063_config,
&adap->dev->i2c_adap))
return -EINVAL;
@@ -336,22 +301,69 @@ static int az6007_tuner_attach(struct dvb_usb_adapter 
*adap)
 
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
-   if (!onoff)
-   return 0;
+   struct az6007_device_state *st = d->priv;
+   struct usb_device *udev = d->udev;
+   int ret;
+
+   deb_info("%s()\n", __func__);
+
+   if (!st->warm) {
+   u8 data[6];
+
+   az6007_read(udev, FX2_OED, 1, 0, data, 1); /* {0x01} */
+   az6007_read(udev, AZ6007_READ_DATA, 0, 8160, data, 1); /* 
{0x20} */
+   az6007_read(udev, 

[PATCH 28/35] [media] az6007: Driver cleanup

2012-01-21 Thread Mauro Carvalho Chehab
Remove commented test code, remove unused poweroff stuff, and
fix the copyright data.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   56 ---
 1 files changed, 13 insertions(+), 43 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index f0e4c01..534d326 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -7,8 +7,9 @@
  * 
http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
  * The original driver's license is GPL, as declared with MODULE_LICENSE()
  *
- *  Driver modifiyed by Mauro Carvalho Chehab  in order
- * to work with upstream drxk driver, and to fix some bugs.
+ * Copyright (c) 2010-2011 Mauro Carvalho Chehab 
+ * Driver modified by in order to work with upstream drxk driver, and
+ * tons of bugs got fixed.
  *
  * 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
@@ -58,7 +59,6 @@ struct az6007_device_state {
 
/* Due to DRX-K - probably need changes */
int (*gate_ctrl) (struct dvb_frontend *, int);
-   struct  semaphore pll_mutex;
booltuner_attached;
 
unsigned char   data[4096];
@@ -94,17 +94,11 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int 
enable)
if (!st)
return -EINVAL;
 
-   if (enable) {
-#if 0
-   down(&st->pll_mutex);
-#endif
+   if (enable)
status = st->gate_ctrl(fe, 1);
-   } else {
-#if 0
+   else
status = st->gate_ctrl(fe, 0);
-#endif
-   up(&st->pll_mutex);
-   }
+
return status;
 }
 
@@ -221,14 +215,6 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
return 0;
 }
 
-#if 0
-int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
-   u8 v = onoff;
-   return az6007_write(d->udev, AZ6007_POWER, v , 3, NULL, 1);
-}
-#endif
-
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
int ret;
@@ -246,6 +232,7 @@ static int az6007_led_on_off(struct usb_interface *intf, 
int onoff)
 {
struct usb_device *udev = interface_to_usbdev(intf);
int ret;
+
/* TS through */
ret = az6007_write(udev, AZ6007_POWER, onoff, 0, NULL, 0);
if (ret < 0)
@@ -257,8 +244,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
 {
struct az6007_device_state *st = adap->dev->priv;
 
-   BUG_ON(!st);
-
deb_info("attaching demod drxk");
 
adap->fe_adap[0].fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
@@ -267,8 +252,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
return -EINVAL;
 
adap->fe_adap[0].fe->sec_priv = adap;
-   /* FIXME: do we need a pll semaphore? */
-   sema_init(&st->pll_mutex, 1);
st->gate_ctrl = adap->fe_adap[0].fe->ops.i2c_gate_ctrl;
adap->fe_adap[0].fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
 
@@ -282,9 +265,8 @@ static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
if (st->tuner_attached)
return 0;
 
-   st->tuner_attached = true;
-
deb_info("attaching tuner mt2063");
+
/* Attach mt2063 to DVB-C frontend */
if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 1);
@@ -296,6 +278,8 @@ static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 0);
 
+   st->tuner_attached = true;
+
return 0;
 }
 
@@ -355,25 +339,9 @@ int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
az6007_write(udev, AZ6007_TS_THROUGH, 0, 0, NULL, 0);
 
-#if 0
-   // Seems to be a poweroff sequence
-   az6007_write(udev, 0xbc, 1, 3, NULL, 0);
-   az6007_write(udev, 0xbc, 1, 4, NULL, 0);
-   az6007_write(udev, 0xc0, 0, 3, NULL, 0);
-   az6007_write(udev, 0xc0, 1, 3, NULL, 0);
-   az6007_write(udev, 0xbc, 0, 1, NULL, 0);
-#endif
-
return 0;
 }
 
-static struct dvb_usb_device_properties az6007_properties;
-
-static void az6007_usb_disconnect(struct usb_interface *intf)
-{
-   dvb_usb_device_exit(intf);
-}
-
 /* I2C */
 static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
   int num)
@@ -513,6 +481,8 @@ int az6007_identify_state(struct usb_device *udev,
return 0;
 }
 
+static struct dvb_usb_device_properties az6007_properties;
+
 static int az6007_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
 {
@@ -589,7 +559,6 @@ static struct usb_driver 

[PATCH 30/35] [media] az6007: Be sure to use kmalloc'ed buffer for transfers

2012-01-21 Thread Mauro Carvalho Chehab
USB data transfers may not work if the buffer is allocated at
the stack. Be sure to use kmalloc on all places where a buffer
is needed.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   27 +--
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 6177332..142ef7b 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -201,8 +201,8 @@ static struct rc_map_table rc_map_az6007_table[] = {
 /* remote control stuff (does not work with my box) */
 static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 {
+   struct az6007_device_state *st = d->priv;
struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
-   u8 key[10];
int i;
 
/*
@@ -212,9 +212,9 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
 */
return 0;
 
-   az6007_read(d, AZ6007_READ_IR, 0, 0, key, 10);
+   az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
 
-   if (key[1] == 0x44) {
+   if (st->data[1] == 0x44) {
*state = REMOTE_NO_KEY_PRESSED;
return 0;
}
@@ -228,11 +228,11 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 
* event, int *state)
 * 88 80 7e 0d f2 ff 00 82 63 82 (another NEC-extended based IR)
 * I suspect that the IR data is at bytes 1 to 4, and byte 5 is parity
 */
-   deb_rc("remote query key: %x %d\n", key[1], key[1]);
-   print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, key, 10);
+   deb_rc("remote query key: %x %d\n", st->data[1], st->data[1]);
+   print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, st->data, 10);
 
for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
-   if (rc5_custom(&keymap[i]) == key[1]) {
+   if (rc5_custom(&keymap[i]) == st->data[1]) {
*event = keymap[i].keycode;
*state = REMOTE_KEY_PRESSED;
 
@@ -244,8 +244,11 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
 
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
+   struct az6007_device_state *st = d->priv;
int ret;
-   ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, mac, 6);
+
+   ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, st->data, 6);
+   memcpy(mac, st->data, sizeof(mac));
 
if (ret > 0)
deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -464,7 +467,11 @@ int az6007_identify_state(struct usb_device *udev,
  struct dvb_usb_device_description **desc, int *cold)
 {
int ret;
-   u8 mac[6];
+   u8 *mac;
+
+   mac = kmalloc(6, GFP_ATOMIC);
+   if (!mac)
+   return -ENOMEM;
 
/* Try to read the mac address */
ret = __az6007_read(udev, AZ6007_READ_DATA, 6, 0, mac, 6);
@@ -473,6 +480,8 @@ int az6007_identify_state(struct usb_device *udev,
else
*cold = 1;
 
+   kfree(mac);
+
if (*cold) {
__az6007_write(udev, 0x09, 1, 0, NULL, 0);
__az6007_write(udev, 0x00, 0, 0, NULL, 0);
@@ -488,8 +497,6 @@ static struct dvb_usb_device_properties az6007_properties;
 static int az6007_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
 {
-   struct usb_device *udev = interface_to_usbdev(intf);
-
return dvb_usb_device_init(intf, &az6007_properties,
   THIS_MODULE, NULL, adapter_nr);
 }
-- 
1.7.8

--
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 29/35] [media] az6007: Protect read/write calls with a mutex

2012-01-21 Thread Mauro Carvalho Chehab
This will avoid interference with CI and IR I/O operations.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |  122 ++--
 1 files changed, 62 insertions(+), 60 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 534d326..6177332 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -53,17 +53,11 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 #define AZ6007_READ_IR 0xb4
 
 struct az6007_device_state {
-   struct  dvb_ca_en50221 ca;
-   struct  mutex ca_mutex;
-   unsignedwarm : 1;
-
-   /* Due to DRX-K - probably need changes */
+   struct mutexmutex;
+   struct dvb_ca_en50221   ca;
+   unsignedwarm:1;
int (*gate_ctrl) (struct dvb_frontend *, int);
-   booltuner_attached;
-
unsigned char   data[4096];
-
-   struct usb_data_stream *stream;
 };
 
 static struct drxk_config terratec_h7_drxk = {
@@ -107,8 +101,7 @@ static struct mt2063_config az6007_mt2063_config = {
.refclock = 36125000,
 };
 
-/* check for mutex FIXME */
-static int az6007_read(struct usb_device *udev, u8 req, u16 value,
+static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
u16 index, u8 *b, int blen)
 {
int ret;
@@ -130,7 +123,23 @@ static int az6007_read(struct usb_device *udev, u8 req, 
u16 value,
return ret;
 }
 
-static int az6007_write(struct usb_device *udev, u8 req, u16 value,
+static int az6007_read(struct dvb_usb_device *d, u8 req, u16 value,
+   u16 index, u8 *b, int blen)
+{
+   struct az6007_device_state *st = d->priv;
+   int ret;
+
+   if (mutex_lock_interruptible(&st->mutex) < 0)
+   return -EAGAIN;
+
+   ret = __az6007_read(d->udev, req, value, index, b, blen);
+
+   mutex_unlock(&st->mutex);
+
+   return ret;
+}
+
+static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
 u16 index, u8 *b, int blen)
 {
int ret;
@@ -158,11 +167,29 @@ static int az6007_write(struct usb_device *udev, u8 req, 
u16 value,
return 0;
 }
 
+static int az6007_write(struct dvb_usb_device *d, u8 req, u16 value,
+   u16 index, u8 *b, int blen)
+{
+   struct az6007_device_state *st = d->priv;
+   int ret;
+
+   if (mutex_lock_interruptible(&st->mutex) < 0)
+   return -EAGAIN;
+
+   ret = __az6007_write(d->udev, req, value, index, b, blen);
+
+   mutex_unlock(&st->mutex);
+
+   return ret;
+}
+
 static int az6007_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 {
+   struct dvb_usb_device *d = adap->dev;
+
deb_info("%s: %s", __func__, onoff ? "enable" : "disable");
 
-   return az6007_write(adap->dev->udev, 0xbc, onoff, 0, NULL, 0);
+   return az6007_write(d, 0xbc, onoff, 0, NULL, 0);
 }
 
 /* keys for the enclosed remote control */
@@ -185,7 +212,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
 */
return 0;
 
-   az6007_read(d->udev, AZ6007_READ_IR, 0, 0, key, 10);
+   az6007_read(d, AZ6007_READ_IR, 0, 0, key, 10);
 
if (key[1] == 0x44) {
*state = REMOTE_NO_KEY_PRESSED;
@@ -218,7 +245,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
int ret;
-   ret = az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+   ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, mac, 6);
 
if (ret > 0)
deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -228,18 +255,6 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, 
u8 mac[6])
return ret;
 }
 
-static int az6007_led_on_off(struct usb_interface *intf, int onoff)
-{
-   struct usb_device *udev = interface_to_usbdev(intf);
-   int ret;
-
-   /* TS through */
-   ret = az6007_write(udev, AZ6007_POWER, onoff, 0, NULL, 0);
-   if (ret < 0)
-   err("%s failed with error %d", __func__, ret);
-   return ret;
-}
-
 static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
struct az6007_device_state *st = adap->dev->priv;
@@ -260,11 +275,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
 
 static int az6007_tuner_attach(struct dvb_usb_adapter *adap)
 {
-   struct az6007_device_state *st = adap->dev->priv;
-
-   if (st->tuner_attached)
-   return 0;
-
deb_info("attaching tuner mt2063");
 
/* Attach mt2063 to DVB-C frontend */
@@ -278,53 +288,45 @@ static int az6007_tuner_attach(struct dvb_usb_adapter 
*adap)
if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
adap->f

[PATCH 31/35] [media] az6007: Fix IR handling

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   31 +--
 1 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 142ef7b..a8aedb8 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -204,13 +204,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
struct az6007_device_state *st = d->priv;
struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
int i;
-
-   /*
-* FIXME: remove the following return to enabled remote querying
-* The driver likely needs proper locking to avoid troubles between
-* this call and other concurrent calls.
-*/
-   return 0;
+   unsigned code = 0;
 
az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
 
@@ -219,20 +213,21 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 
* event, int *state)
return 0;
}
 
-   /*
-* FIXME: need to make something useful with the keycodes and to
-* convert it to the non-legacy mode. Yet, it is producing some
-* debug info already, like:
-* 88 04 eb 02 fd ff 00 82 63 82 (terratec IR)
-* 88 04 eb 03 fc 00 00 82 63 82 (terratec IR)
-* 88 80 7e 0d f2 ff 00 82 63 82 (another NEC-extended based IR)
-* I suspect that the IR data is at bytes 1 to 4, and byte 5 is parity
-*/
-   deb_rc("remote query key: %x %d\n", st->data[1], st->data[1]);
+   if ((st->data[1] ^ st->data[2]) == 0xff)
+   code = st->data[1];
+   else
+   code = st->data[1] << 8 | st->data[2];
+
+   if ((st->data[3] ^ st->data[4]) == 0xff)
+   code = code << 8 | st->data[3];
+   else
+   code = code << 16 | st->data[3] << 8| st->data[4];
+
+   printk("remote query key: %04x\n", code);
print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, st->data, 10);
 
for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
-   if (rc5_custom(&keymap[i]) == st->data[1]) {
+   if (rc5_custom(&keymap[i]) == code) {
*event = keymap[i].keycode;
*state = REMOTE_KEY_PRESSED;
 
-- 
1.7.8

--
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 34/35] [media] az6007: Enable the driver at the building system

2012-01-21 Thread Mauro Carvalho Chehab
Add the corresponding entries to allow building this driver.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/Kconfig  |8 
 drivers/media/dvb/dvb-usb/Makefile |4 +++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/Kconfig 
b/drivers/media/dvb/dvb-usb/Kconfig
index 9f203c6..e894bad 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -361,6 +361,14 @@ config DVB_USB_EC168
help
  Say Y here to support the E3C EC168 DVB-T USB2.0 receiver.
 
+config DVB_USB_AZ6007
+   tristate "AzureWave 6007 and clones DVB-T/C USB2.0 support"
+   depends on DVB_USB
+   select DVB_DRXK if !DVB_FE_CUSTOMISE
+   select MEDIA_TUNER_MT2063 if !DVB_FE_CUSTOMISE
+   help
+ Say Y here to support theAfatech AF9005 based DVB-T/DVB-C receivers.
+
 config DVB_USB_AZ6027
tristate "Azurewave DVB-S/S2 USB2.0 AZ6027 support"
depends on DVB_USB
diff --git a/drivers/media/dvb/dvb-usb/Makefile 
b/drivers/media/dvb/dvb-usb/Makefile
index 26c8b9e..d9549cb 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -54,7 +54,6 @@ obj-$(CONFIG_DVB_USB_DIB0700) += dvb-usb-dib0700.o
 dvb-usb-opera-objs = opera1.o
 obj-$(CONFIG_DVB_USB_OPERA1) += dvb-usb-opera.o
 
-
 dvb-usb-af9005-objs = af9005.o af9005-fe.o
 obj-$(CONFIG_DVB_USB_AF9005) += dvb-usb-af9005.o
 
@@ -88,6 +87,9 @@ obj-$(CONFIG_DVB_USB_FRIIO) += dvb-usb-friio.o
 dvb-usb-ec168-objs = ec168.o
 obj-$(CONFIG_DVB_USB_EC168) += dvb-usb-ec168.o
 
+dvb-usb-az6007-objs = az6007.o
+obj-$(CONFIG_DVB_USB_AZ6007) += dvb-usb-az6007.o
+
 dvb-usb-az6027-objs = az6027.o
 obj-$(CONFIG_DVB_USB_AZ6027) += dvb-usb-az6027.o
 
-- 
1.7.8

--
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 35/35] [media] az6007: CodingStyle fixes

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   27 +--
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 14733b8..02efd94 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -211,9 +211,7 @@ static int az6007_rc_query(struct dvb_usb_device *d)
if ((st->data[3] ^ st->data[4]) == 0xff)
code = code << 8 | st->data[3];
else
-   code = code << 16 | st->data[3] << 8| st->data[4];
-
-   printk("remote query key: %04x\n", code);
+   code = code << 16 | st->data[3] << 8 | st->data[4];
 
rc_keydown(d->rc_dev, code, st->data[5]);
 
@@ -302,11 +300,11 @@ int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
ret = az6007_write(d, FX2_SCON1, 0, 3, NULL, 0);
if (ret < 0)
return ret;
-   msleep (150);
+   msleep(150);
ret = az6007_write(d, FX2_SCON1, 1, 3, NULL, 0);
if (ret < 0)
return ret;
-   msleep (430);
+   msleep(430);
ret = az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
if (ret < 0)
return ret;
@@ -362,8 +360,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msgs[],
value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
-   ret = __az6007_read(d->udev, req, value, index, 
st->data,
-  length);
+   ret = __az6007_read(d->udev, req, value, index,
+   st->data, length);
if (ret >= len) {
for (j = 0; j < len; j++) {
msgs[i + 1].buf[j] = st->data[j + 5];
@@ -391,10 +389,11 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, 
struct i2c_msg msgs[],
for (j = 0; j < len; j++) {
st->data[j] = msgs[i].buf[j + 1];
if (dvb_usb_az6007_debug & 2)
-   printk(KERN_CONT "0x%02x ", 
st->data[j]);
+   printk(KERN_CONT "0x%02x ",
+  st->data[j]);
}
-   ret =  __az6007_write(d->udev, req, value, index, 
st->data,
-length);
+   ret =  __az6007_write(d->udev, req, value, index,
+ st->data, length);
} else {
/* read bytes */
if (dvb_usb_az6007_debug & 2)
@@ -406,8 +405,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
-   ret = __az6007_read(d->udev, req, value, index, 
st->data,
-  length);
+   ret = __az6007_read(d->udev, req, value, index,
+   st->data, length);
for (j = 0; j < len; j++) {
msgs[i].buf[j] = st->data[j + 5];
if (dvb_usb_az6007_debug & 2)
@@ -466,7 +465,7 @@ int az6007_identify_state(struct usb_device *udev,
__az6007_write(udev, 0x00, 0, 0, NULL, 0);
}
 
-   deb_info("Device is on %s state\n", *cold? "warm" : "cold");
+   deb_info("Device is on %s state\n", *cold ? "warm" : "cold");
return 0;
 }
 
@@ -514,7 +513,7 @@ static struct dvb_usb_device_properties az6007_properties = 
{
}
}
},
-   }}
+   } }
} },
.power_ctrl   = az6007_power_ctrl,
.read_mac_address = az6007_read_mac_addr,
-- 
1.7.8

--
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 32/35] [media] az6007: Convert IR to use the rc_core logic

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   30 +++---
 1 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index a8aedb8..2288916 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -192,26 +192,16 @@ static int az6007_streaming_ctrl(struct dvb_usb_adapter 
*adap, int onoff)
return az6007_write(d, 0xbc, onoff, 0, NULL, 0);
 }
 
-/* keys for the enclosed remote control */
-static struct rc_map_table rc_map_az6007_table[] = {
-   {0x0001, KEY_1},
-   {0x0002, KEY_2},
-};
-
 /* remote control stuff (does not work with my box) */
-static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
+static int az6007_rc_query(struct dvb_usb_device *d)
 {
struct az6007_device_state *st = d->priv;
-   struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
-   int i;
unsigned code = 0;
 
az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10);
 
-   if (st->data[1] == 0x44) {
-   *state = REMOTE_NO_KEY_PRESSED;
+   if (st->data[1] == 0x44)
return 0;
-   }
 
if ((st->data[1] ^ st->data[2]) == 0xff)
code = st->data[1];
@@ -224,16 +214,9 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
code = code << 16 | st->data[3] << 8| st->data[4];
 
printk("remote query key: %04x\n", code);
-   print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, st->data, 10);
 
-   for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
-   if (rc5_custom(&keymap[i]) == code) {
-   *event = keymap[i].keycode;
-   *state = REMOTE_KEY_PRESSED;
+   rc_keydown(d->rc_dev, code, st->data[5]);
 
-   return 0;
-   }
-   }
return 0;
 }
 
@@ -536,11 +519,12 @@ static struct dvb_usb_device_properties az6007_properties 
= {
.power_ctrl   = az6007_power_ctrl,
.read_mac_address = az6007_read_mac_addr,
 
-   .rc.legacy = {
-   .rc_map_table  = rc_map_az6007_table,
-   .rc_map_size  = ARRAY_SIZE(rc_map_az6007_table),
+   .rc.core = {
.rc_interval  = 400,
+   .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
+   .module_name  = "az6007",
.rc_query = az6007_rc_query,
+   .allowed_protos   = RC_TYPE_NEC,
},
.i2c_algo = &az6007_i2c_algo,
 
-- 
1.7.8

--
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 33/35] [media] az6007: Use the right keycode for Terratec H7

2012-01-21 Thread Mauro Carvalho Chehab
Instead of using a fake keycode, just for testing, use the
right one, for Terratec H7.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |2 +-
 .../media/rc/keymaps/rc-nec-terratec-cinergy-xs.c  |   52 
 2 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 2288916..14733b8 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -521,7 +521,7 @@ static struct dvb_usb_device_properties az6007_properties = 
{
 
.rc.core = {
.rc_interval  = 400,
-   .rc_codes = RC_MAP_DIB0700_NEC_TABLE,
+   .rc_codes = RC_MAP_NEC_TERRATEC_CINERGY_XS,
.module_name  = "az6007",
.rc_query = az6007_rc_query,
.allowed_protos   = RC_TYPE_NEC,
diff --git a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c 
b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
index f3b86c8..8d4dae2 100644
--- a/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
+++ b/drivers/media/rc/keymaps/rc-nec-terratec-cinergy-xs.c
@@ -18,6 +18,8 @@
  */
 
 static struct rc_map_table nec_terratec_cinergy_xs[] = {
+
+   /* Terratec Grey IR, with most keys in orange */
{ 0x1441, KEY_HOME},
{ 0x1401, KEY_POWER2},
 
@@ -78,6 +80,56 @@ static struct rc_map_table nec_terratec_cinergy_xs[] = {
{ 0x144e, KEY_REWIND},
{ 0x144f, KEY_FASTFORWARD},
{ 0x145c, KEY_NEXT},
+
+   /* Terratec Black IR, with most keys in black */
+   { 0x04eb01, KEY_POWER2},
+
+   { 0x04eb02, KEY_1},
+   { 0x04eb03, KEY_2},
+   { 0x04eb04, KEY_3},
+   { 0x04eb05, KEY_4},
+   { 0x04eb06, KEY_5},
+   { 0x04eb07, KEY_6},
+   { 0x04eb08, KEY_7},
+   { 0x04eb09, KEY_8},
+   { 0x04eb0a, KEY_9},
+   { 0x04eb0c, KEY_0},
+
+   { 0x04eb0b, KEY_TEXT},  /* TXT */
+   { 0x04eb0d, KEY_REFRESH},   /* Refresh */
+
+   { 0x04eb0e, KEY_HOME},
+   { 0x04eb0f, KEY_EPG},
+
+   { 0x04eb10, KEY_UP},
+   { 0x04eb11, KEY_LEFT},
+   { 0x04eb12, KEY_OK},
+   { 0x04eb13, KEY_RIGHT},
+   { 0x04eb14, KEY_DOWN},
+
+   { 0x04eb15, KEY_BACKSPACE},
+   { 0x04eb16, KEY_INFO},
+
+   { 0x04eb17, KEY_RED},
+   { 0x04eb18, KEY_GREEN},
+   { 0x04eb19, KEY_YELLOW},
+   { 0x04eb1a, KEY_BLUE},
+
+   { 0x04eb1c, KEY_VOLUMEUP},
+   { 0x04eb1e, KEY_VOLUMEDOWN},
+
+   { 0x04eb1d, KEY_MUTE},
+
+   { 0x04eb1b, KEY_CHANNELUP},
+   { 0x04eb1f, KEY_CHANNELDOWN},
+
+   { 0x04eb40, KEY_RECORD},
+   { 0x04eb4c, KEY_PLAY},
+   { 0x04eb58, KEY_PAUSE},
+
+   { 0x04eb54, KEY_REWIND},
+   { 0x04eb48, KEY_STOP},
+   { 0x04eb5c, KEY_NEXT},
 };
 
 static struct rc_map_list nec_terratec_cinergy_xs_map = {
-- 
1.7.8

--
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 23/35] [media] drxk: Allow setting it on dynamic_clock mode

2012-01-21 Thread Mauro Carvalho Chehab
This is used on az6007.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/frontends/drxk.h  |   17 ++---
 drivers/media/dvb/frontends/drxk_hard.c |   14 +-
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/media/dvb/frontends/drxk.h 
b/drivers/media/dvb/frontends/drxk.h
index 0209818..6b0fd2c 100644
--- a/drivers/media/dvb/frontends/drxk.h
+++ b/drivers/media/dvb/frontends/drxk.h
@@ -7,15 +7,17 @@
 /**
  * struct drxk_config - Configure the initial parameters for DRX-K
  *
- * adr:I2C Address of the DRX-K
- * parallel_ts:true means that the device uses parallel TS,
+ * @adr:   I2C Address of the DRX-K
+ * @parallel_ts:   True means that the device uses parallel TS,
  * Serial otherwise.
- * single_master:  Device is on the single master mode
- * no_i2c_bridge:  Don't switch the I2C bridge to talk with tuner
- * antenna_gpio:   GPIO bit used to control the antenna
- * antenna_dvbt:   GPIO bit for changing antenna to DVB-C. A value of 1
+ * @dynamic_clk:   True means that the clock will be dynamically
+ * adjusted. Static clock otherwise.
+ * @single_master: Device is on the single master mode
+ * @no_i2c_bridge: Don't switch the I2C bridge to talk with tuner
+ * @antenna_gpio:  GPIO bit used to control the antenna
+ * @antenna_dvbt:  GPIO bit for changing antenna to DVB-C. A value of 1
  * means that 1=DVBC, 0 = DVBT. Zero means the opposite.
- * microcode_name: Name of the firmware file with the microcode
+ * @microcode_name:Name of the firmware file with the microcode
  *
  * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is
  * UIO-3.
@@ -25,6 +27,7 @@ struct drxk_config {
boolsingle_master;
boolno_i2c_bridge;
boolparallel_ts;
+   booldynamic_clk;
 
boolantenna_dvbt;
u16 antenna_gpio;
diff --git a/drivers/media/dvb/frontends/drxk_hard.c 
b/drivers/media/dvb/frontends/drxk_hard.c
index 4b99255..6570396 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -650,9 +650,6 @@ static int init_state(struct drxk_state *state)
u32 ulQual83 = DEFAULT_MER_83;
u32 ulQual93 = DEFAULT_MER_93;
 
-   u32 ulDVBTStaticTSClock = 1;
-   u32 ulDVBCStaticTSClock = 1;
-
u32 ulMpegLockTimeOut = DEFAULT_DRXK_MPEG_LOCK_TIMEOUT;
u32 ulDemodLockTimeOut = DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT;
 
@@ -815,8 +812,7 @@ static int init_state(struct drxk_state *state)
state->m_invertSTR = false; /* If TRUE; invert STR signals */
state->m_invertVAL = false; /* If TRUE; invert VAL signals */
state->m_invertCLK = (ulInvertTSClock != 0);/* If TRUE; invert CLK 
signals */
-   state->m_DVBTStaticCLK = (ulDVBTStaticTSClock != 0);
-   state->m_DVBCStaticCLK = (ulDVBCStaticTSClock != 0);
+
/* If TRUE; static MPEG clockrate will be used;
   otherwise clockrate will adapt to the bitrate of the TS */
 
@@ -6390,6 +6386,14 @@ struct dvb_frontend *drxk_attach(const struct 
drxk_config *config,
state->antenna_dvbt = config->antenna_dvbt;
state->m_ChunkSize = config->chunk_size;
 
+   if (config->dynamic_clk) {
+   state->m_DVBTStaticCLK = 0;
+   state->m_DVBCStaticCLK = 0;
+   } else {
+   state->m_DVBTStaticCLK = 1;
+   state->m_DVBCStaticCLK = 1;
+   }
+
if (config->parallel_ts)
state->m_enableParallel = true;
else
-- 
1.7.8

--
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 21/35] [media] az6007: Change it to use the MFE solution adopted at dvb-usb

2012-01-21 Thread Mauro Carvalho Chehab
This driver were written to use a previous solution for MFE at dvb-usb.
Due to the internal API changes, change the binding to work with the
new way.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   42 ++-
 1 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index b667854..92ded30 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -66,7 +66,7 @@ static struct drxk_config terratec_h7_drxk = {
.adr = 0x29,
.single_master = 1,
.no_i2c_bridge = 0,
-   .max_size = 64,
+   .chunk_size = 64,
.microcode_name = "dvb-usb-terratec-h7-drxk.fw",
.parallel_ts = 1,
 };
@@ -290,26 +290,21 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
 {
struct az6007_device_state *st = adap->priv;
 
-   /* FIXME: dvb-usb will call this function twice! */
-   if (adap->fe[0])
-   return 0;
-
BUG_ON(!st);
 
az6007_frontend_poweron(adap);
 
info("attaching demod drxk");
-   adap->fe[0] = dvb_attach(drxk_attach, &terratec_h7_drxk,
-&adap->dev->i2c_adap, &adap->fe[1]);
-   if (!adap->fe[0])
+   adap->fe_adap[0].fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
+&adap->dev->i2c_adap);
+   if (!adap->fe_adap[0].fe)
return -EINVAL;
 
-   adap->fe[0]->sec_priv = adap;
+   adap->fe_adap[0].fe->sec_priv = adap;
/* FIXME: do we need a pll semaphore? */
sema_init(&st->pll_mutex, 1);
-   st->gate_ctrl = adap->fe[0]->ops.i2c_gate_ctrl;
-   adap->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
-   adap->dont_attach_fe[1] = true;
+   st->gate_ctrl = adap->fe_adap[0].fe->ops.i2c_gate_ctrl;
+   adap->fe_adap[0].fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
 
return 0;
 }
@@ -325,19 +320,15 @@ static int az6007_tuner_attach(struct dvb_usb_adapter 
*adap)
 
info("attaching tuner mt2063");
/* Attach mt2063 to DVB-C frontend */
-   if (adap->fe[0]->ops.i2c_gate_ctrl)
-   adap->fe[0]->ops.i2c_gate_ctrl(adap->fe[0], 1);
-   if (!dvb_attach(mt2063_attach, adap->fe[0], &az6007_mt2063_config,
+   if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
+   adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 1);
+   if (!dvb_attach(mt2063_attach, adap->fe_adap[0].fe, 
+   &az6007_mt2063_config,
&adap->dev->i2c_adap))
return -EINVAL;
 
-   if (adap->fe[0]->ops.i2c_gate_ctrl)
-   adap->fe[0]->ops.i2c_gate_ctrl(adap->fe[0], 0);
-
-   /* Hack - needed due to drxk */
-   adap->fe[1]->tuner_priv = adap->fe[0]->tuner_priv;
-   memcpy(&adap->fe[1]->ops.tuner_ops,
-  &adap->fe[0]->ops.tuner_ops, sizeof(adap->fe[0]->ops.tuner_ops));
+   if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
+   adap->fe_adap[0].fe->ops.i2c_gate_ctrl(adap->fe_adap[0].fe, 0);
 
return 0;
 }
@@ -530,7 +521,8 @@ static struct dvb_usb_device_properties az6007_properties = 
{
.num_adapters = 1,
.adapter = {
{
-   .num_frontends= 2,
+   .num_frontends = 1,
+   .fe = {{
.streaming_ctrl   = az6007_streaming_ctrl,
.tuner_attach = az6007_tuner_attach,
.frontend_attach  = az6007_frontend_attach,
@@ -547,8 +539,8 @@ static struct dvb_usb_device_properties az6007_properties = 
{
}
},
.size_of_priv = sizeof(struct az6007_device_state),
-   }
-   },
+   }}
+   } },
.power_ctrl   = az6007_power_ctrl,
.read_mac_address = az6007_read_mac_addr,
 
-- 
1.7.8

--
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 05/35] [media] az6007: Comment the gate_ctl mutex

2012-01-21 Thread Mauro Carvalho Chehab
The mutex is there to protect the I2C gate. However, for some reason,
it is being called twice:

[ 2103.542796] usbcore: registered new interface driver dvb_usb_az6007
[ 2103.772392] az6007: drxk_gate_ctrl: enable
[ 2103.793900] az6007: drxk_gate_ctrl: enable

For now, let's just comment, to allow the driver to run.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 56126d4..ed376b8 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -52,7 +52,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
struct az6007_device_state *st;
int status;
 
-   info("%s", __func__);
+   info("%s: %s", __func__, enable? "enable" : "disable" );
 
if (!adap)
return -EINVAL;
@@ -64,10 +64,14 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int 
enable)
 
 
if (enable) {
+#if 0
down(&st->pll_mutex);
+#endif
status = st->gate_ctrl(fe, 1);
} else {
+#if 0
status = st->gate_ctrl(fe, 0);
+#endif
up(&st->pll_mutex);
}
return status;
-- 
1.7.8

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


[PATCH 18/35] [media] az6007: Fix IR receive code

2012-01-21 Thread Mauro Carvalho Chehab
The code still needs to be commented, as there's a mutex
missing at the az6007_read() call. A mutex there is needed,
in order to prevent RC (or CI) calls while other operations
are in progress.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   37 +--
 1 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 912ba67..c9743ee 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -49,7 +49,7 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 #define AZ6007_I2C_WR  0xbd
 #define FX2_SCON1  0xc0
 #define AZ6007_TS_THROUGH  0xc7
-#define AZ6007_READ_IR 0xc5
+#define AZ6007_READ_IR 0xb4
 
 struct az6007_device_state {
struct  dvb_ca_en50221 ca;
@@ -172,30 +172,45 @@ static struct rc_map_table rc_map_az6007_table[] = {
 /* remote control stuff (does not work with my box) */
 static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
 {
-   return 0;
-#if 0
+   struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table;
u8 key[10];
int i;
 
-   /* remove the following return to enabled remote querying */
+   /*
+* FIXME: remove the following return to enabled remote querying
+* The driver likely needs proper locking to avoid troubles between
+* this call and other concurrent calls.
+*/
+   return 0;
 
az6007_read(d->udev, AZ6007_READ_IR, 0, 0, key, 10);
 
-   deb_rc("remote query key: %x %d\n", key[1], key[1]);
-
if (key[1] == 0x44) {
*state = REMOTE_NO_KEY_PRESSED;
return 0;
}
 
-   for (i = 0; i < ARRAY_SIZE(az6007_rc_keys); i++)
-   if (az6007_rc_keys[i].custom == key[1]) {
+   /*
+* FIXME: need to make something useful with the keycodes and to
+* convert it to the non-legacy mode. Yet, it is producing some
+* debug info already, like:
+* 88 04 eb 02 fd ff 00 82 63 82 (terratec IR)
+* 88 04 eb 03 fc 00 00 82 63 82 (terratec IR)
+* 88 80 7e 0d f2 ff 00 82 63 82 (another NEC-extended based IR)
+* I suspect that the IR data is at bytes 1 to 4, and byte 5 is parity
+*/
+   deb_rc("remote query key: %x %d\n", key[1], key[1]);
+   print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, key, 10);
+
+   for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
+   if (rc5_custom(&keymap[i]) == key[1]) {
+   *event = keymap[i].keycode;
*state = REMOTE_KEY_PRESSED;
-   *event = az6007_rc_keys[i].event;
-   break;
+
+   return 0;
}
+   }
return 0;
-#endif
 }
 
 #if 0
-- 
1.7.8

--
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/35] Add a driver for Terratec H7

2012-01-21 Thread Mauro Carvalho Chehab
Terratec H7 is a Cypress FX2 device with a mt2063 tuner and a drx-k
demod. This series add support for it. It started with a public
tree found at:
 
http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz

The driver were almost completely re-written, and it is now working,
at least with DVB-C. I don't have a DVB-T signal here for testing,
but I suspect it should also work fine.

The FX2 firmware has a NEC IR decoder. The driver has support for
it. The default keytable has support for the black Terratec IR
and for the grey IR with orange keys.

The CI support inside the driver is similar to the one found at the
az6027 driver. I don't have a CI module here, so it is not tested.

Tests and feedback are welcome.

Mauro Carvalho Chehab (35):
  [media] dvb: Add a new driver for az6007
  [media] az6007: Fix compilation troubles at az6007
  [media] az6007: Fix it to allow loading it without crash
  [media] az6007: Fix the I2C code in order to handle mt2063
  [media] az6007: Comment the gate_ctl mutex
  [media] az6007: Remove some dead code that doesn't seem to be needed
  [media] az6007: CodingStyle cleanup
  [media] az6007: Get rid of az6007.h
  [media] az6007: Replace the comments at the beginning of the driver
  [media] az6007: move device PID's to the proper place
  [media] az6007: make driver less verbose
  [media] drxk: Don't assume a default firmware name
  [media] az6007: need to define drivers name before including dvb-usb.h
  [media] az6007: Fix some init sequences and use the right firmwares
  [media] az6007: Change the az6007 read/write routine parameter
  [media] az6007: Simplify the read/write logic
  [media] az6007: Simplify the code by removing an uneeded function
  [media] az6007: Fix IR receive code
  [media] az6007: improve the error messages for az6007 read/write calls
  [media] az6007: Use the new MFE support at dvb-usb
  [media] az6007: Change it to use the MFE solution adopted at dvb-usb
  [media] az6007: Use a per device private struct
  [media] drxk: Allow setting it on dynamic_clock mode
  [media] az6007: Use DRX-K dynamic clock mode
  [media] drxk: add support for Mpeg output clock drive strength config
  [media] drxk: Allow enabling MERR/MVAL cfg
  [media] az6007: code cleanups and fixes
  [media] az6007: Driver cleanup
  [media] az6007: Protect read/write calls with a mutex
  [media] az6007: Be sure to use kmalloc'ed buffer for transfers
  [media] az6007: Fix IR handling
  [media] az6007: Convert IR to use the rc_core logic
  [media] az6007: Use the right keycode for Terratec H7
  [media] az6007: Enable the driver at the building system
  [media] az6007: CodingStyle fixes

 drivers/media/common/tuners/mt2063.c   |2 +-
 drivers/media/dvb/ddbridge/ddbridge-core.c |1 +
 drivers/media/dvb/dvb-usb/Kconfig  |8 +
 drivers/media/dvb/dvb-usb/Makefile |4 +-
 drivers/media/dvb/dvb-usb/az6007.c |  581 
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h|2 +
 drivers/media/dvb/frontends/drxk.h |   23 +-
 drivers/media/dvb/frontends/drxk_hard.c|   41 +-
 drivers/media/dvb/frontends/drxk_hard.h|1 +
 drivers/media/dvb/ngene/ngene-cards.c  |1 +
 .../media/rc/keymaps/rc-nec-terratec-cinergy-xs.c  |   52 ++
 11 files changed, 690 insertions(+), 26 deletions(-)
 create mode 100644 drivers/media/dvb/dvb-usb/az6007.c

-- 
1.7.8

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


[PATCH 16/35] [media] az6007: Simplify the read/write logic

2012-01-21 Thread Mauro Carvalho Chehab
This patch introduces no functional changes. It basically defines
a macro for each different req found at the driver, and cleans the
code to use them, making easier to understand the code.

With regards to the IR handling code, although the original code
doesn't define what's the request, it is clear, from the USB logs,
that 0xc5 is for IR polling.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |  185 +---
 1 files changed, 87 insertions(+), 98 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index f098e47..8add81a 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -40,6 +40,17 @@ MODULE_PARM_DESC(debug, "set debugging level 
(1=info,xfer=2,rc=4 (or-able))."
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
+/* Known requests (Cypress FX2 firmware + az6007 "private" ones*/
+
+#define FX2_OED0xb5
+#define AZ6007_READ_DATA   0xb7
+#define AZ6007_I2C_RD  0xb9
+#define AZ6007_POWER   0xbc
+#define AZ6007_I2C_WR  0xbd
+#define FX2_SCON1  0xc0
+#define AZ6007_TS_THROUGH  0xc7
+#define AZ6007_READ_IR 0xc5
+
 struct az6007_device_state {
struct  dvb_ca_en50221 ca;
struct  mutex ca_mutex;
@@ -168,7 +179,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
 
/* remove the following return to enabled remote querying */
 
-   az6007_read(d->udev, READ_REMOTE_REQ, 0, 0, key, 10);
+   az6007_read(d->udev, AZ6007_READ_IR, 0, 0, key, 10);
 
deb_rc("remote query key: %x %d\n", key[1], key[1]);
 
@@ -187,127 +198,104 @@ static int az6007_rc_query(struct dvb_usb_device *d, 
u32 * event, int *state)
 #endif
 }
 
-/*
+#if 0
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
u8 v = onoff;
-   return az6007_write(d->udev,0xBC,v,3,NULL,1);
+   return az6007_write(d->udev, AZ6007_POWER, v , 3, NULL, 1);
 }
-*/
+#endif
 
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
-   az6007_read(d->udev, 0xb7, 6, 0, &mac[0], 6);
-   return 0;
-}
+   int ret;
+   ret = az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
 
-#define AZ6007_POWER   0xbc
-#define FX2_SCON1  0xc0
-#define AZ6007_TS_THROUGH  0xc7
+   if (ret > 0)
+   deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n",
+__func__, mac[0], mac[1], mac[2],
+mac[3], mac[4], mac[5]);
+
+   return ret;
+}
 
 static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 {
-   struct dvb_usb_device *d = adap->dev;
+   int ret;
+   struct usb_device *udev = adap->dev->udev;
 
-   deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
-adap, adap->dev);
+   deb_info("%s: adap=%p adap->dev=%p\n", __func__, adap, adap->dev);
 
-   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
+   ret = az6007_write(udev, AZ6007_POWER, 0, 2, NULL, 0);
+   if (ret < 0)
+   goto error;
msleep(150);
-   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+   ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
+   if (ret < 0)
+   goto error;
msleep(100);
-   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
+   ret = az6007_write(udev, AZ6007_POWER, 1, 3, NULL, 0);
+   if (ret < 0)
+   goto error;
msleep(100);
-   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+   ret = az6007_write(udev, AZ6007_POWER, 1, 4, NULL, 0);
+   if (ret < 0)
+   goto error;
msleep(100);
-   az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
+   ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
+   if (ret < 0)
+   goto error;
msleep (10);
-   az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
+   ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
+   if (ret < 0)
+   goto error;
msleep (10);
-   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
+   ret = az6007_write(udev, AZ6007_POWER, 0, 0, NULL, 0);
 
-   deb_info("az6007_frontend_poweron: OK\n");
+error:
+   if (ret < 0)
+   err("%s failed with error %d", __func__, ret);
 
-   return 0;
+   return ret;
 }
 
 static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
 {
+   struct usb_device *udev = adap->dev->udev;
int ret;
-   u8 req;
-   u16 value;
-   u16 index;
-   int blen;
 
deb_info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, 
adap->dev);
 
/* reset demodulator */
-   req = 0xC0;
-   value = 1;  /* high */
-   index = 3;
-   blen = 0;
-   ret = az6007

[PATCH 17/35] [media] az6007: Simplify the code by removing an uneeded function

2012-01-21 Thread Mauro Carvalho Chehab
Everything to reset the demod is already at
az6007_frontend_poweron().

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   29 -
 1 files changed, 0 insertions(+), 29 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 8add81a..912ba67 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -259,34 +259,6 @@ error:
return ret;
 }
 
-static int az6007_frontend_reset(struct dvb_usb_adapter *adap)
-{
-   struct usb_device *udev = adap->dev->udev;
-   int ret;
-
-   deb_info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, 
adap->dev);
-
-   /* reset demodulator */
-   ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep(200);
-   ret = az6007_write(udev, FX2_SCON1, 0, 3, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep(200);
-   ret = az6007_write(udev, FX2_SCON1, 1, 3, NULL, 0);
-   if (ret < 0)
-   goto error;
-   msleep(200);
-
-error:
-   if (ret < 0)
-   err("%s failed with error %d", __func__, ret);
-
-   return ret;
-}
-
 static int az6007_led_on_off(struct usb_interface *intf, int onoff)
 {
struct usb_device *udev = interface_to_usbdev(intf);
@@ -309,7 +281,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
BUG_ON(!st);
 
az6007_frontend_poweron(adap);
-   az6007_frontend_reset(adap);
 
info("az6007: attaching demod drxk");
adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
-- 
1.7.8

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


[PATCH 06/35] [media] az6007: Remove some dead code that doesn't seem to be needed

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   79 +++
 1 files changed, 16 insertions(+), 63 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index ed376b8..1fc174b 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -17,17 +17,8 @@ int dvb_usb_az6007_debug;
 module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." 
DVB_USB_DEBUG_STATUS);
 
-
-static int az6007_type =0;
-module_param(az6007_type, int, 0644);
-MODULE_PARM_DESC(az6007_type, "select delivery mode (0=DVB-T, 1=DVB-T");
-
-//module_param_named(type, 6007_type, int, 0644);
-//MODULE_PARM_DESC(type, "select delivery mode (0=DVB-T, 1=DVB-C)");
-
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
-
 struct az6007_device_state {
struct dvb_ca_en50221 ca;
struct mutex ca_mutex;
@@ -110,57 +101,22 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
 {
int ret;
 
-#if 0
-   int i=0, cyc=0, rem=0;
-   cyc = blen/64;
-   rem = blen%64;
-#endif
-
deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: 
",req,value,index);
debug_dump(b,blen,deb_xfer);
 
-
-#if 0
-   if (blen>64)
-   {
-   for (i=0; iudev,
-   usb_sndctrlpipe(d->udev,0),
-   req,
-   USB_TYPE_VENDOR | USB_DIR_OUT,
-   value,index+i*64,b+i*64,64,
-   5000)) != 64) {
-   warn("usb out operation failed. (%d)",ret);
-   return -EIO;
-   }
-   }
-
-   if (rem>0)
-   {
-   if ((ret = usb_control_msg(d->udev,
-   usb_sndctrlpipe(d->udev,0),
-   req,
-   USB_TYPE_VENDOR | USB_DIR_OUT,
-   value,index+cyc*64,b+cyc*64,rem,
-   5000)) != rem) {
-   warn("usb out operation failed. (%d)",ret);
-   return -EIO;
-   }
-   }
+   if (blen > 64) {
+   printk(KERN_ERR "az6007: doesn't suport I2C transactions longer 
than 64 bytes\n");
+   return -EOPNOTSUPP;
}
-   else
-#endif
-   {
-   if ((ret = usb_control_msg(d->udev,
-   usb_sndctrlpipe(d->udev,0),
-   req,
-   USB_TYPE_VENDOR | USB_DIR_OUT,
-   value,index,b,blen,
-   5000)) != blen) {
-   warn("usb out operation failed. (%d)",ret);
-   return -EIO;
-   }
+
+   if ((ret = usb_control_msg(d->udev,
+   usb_sndctrlpipe(d->udev,0),
+   req,
+   USB_TYPE_VENDOR | USB_DIR_OUT,
+   value,index,b,blen,
+   5000)) != blen) {
+   warn("usb out operation failed. (%d)",ret);
+   return -EIO;
}
 
return 0;
@@ -232,7 +188,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter 
*adap)
info("az6007_frontend_poweron adap=%p adap->dev=%p", adap, adap->dev);
 
req = 0xBC;
-   value = 1;//power on
+   value = 1;  /* power on */
index = 3;
blen =0;
 
@@ -245,7 +201,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter 
*adap)
msleep_interruptible(200);
 
req = 0xBC;
-   value = 0;//power on
+   value = 0;  /* power off */
index = 3;
blen =0;
 
@@ -258,7 +214,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter 
*adap)
msleep_interruptible(200);
 
req = 0xBC;
-   value = 1;//power on
+   value = 1;  /* power on */
index = 3;
blen =0;
 
@@ -552,9 +508,6 @@ static u32 az6007_i2c_func(struct i2c_adapter *adapter)
 static struct i2c_algorithm az6007_i2c_algo = {
.master_xfer   = az6007_i2c_xfer,
.functionality = az6007_i2c_func,
-#ifdef NEED_ALGO_CONTROL
-   .algo_control = dummy_algo_control,
-#endif
 };
 
 int az6007_identify_state(struct usb_device *udev, struct 
dvb_usb_device_properties *props,
@@ -678,5 +631,5 @@ module_exit(az6007_usb_module_exit);
 
 MODULE_AUTHOR("Henry Wang ");
 MODULE_DESCRIPTION("Driver for AzureWave 6007 DVB-C/T USB2.0 and clones");
-MODULE_VERSION("1.0");
+MODULE_VERSION("1.1");
 MODULE_LICENSE("GPL");
-- 
1.7.8

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

[PATCH 04/35] [media] az6007: Fix the I2C code in order to handle mt2063

2012-01-21 Thread Mauro Carvalho Chehab
mt2063 uses a one-byte transfer. This requires a special handling
inside the i2c code. Fix it to properly accept i2c reads. This
is needed to make the mt2063 to be detected.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   47 +++-
 1 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 6a21f92..56126d4 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -42,7 +42,7 @@ struct az6007_device_state {
 struct drxk_config terratec_h7_drxk = {
.adr = 0x29,
.single_master = 1,
-   .no_i2c_bridge = 1,
+   .no_i2c_bridge = 0,
.microcode_name = "dvb-usb-terratec-h5-drxk.fw",
 };
 
@@ -451,7 +451,6 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap,struct 
i2c_msg msgs[],int nu
 
for (i = 0; i < num; i++) {
addr = msgs[i].addr << 1;
-
if (((i + 1) < num)
&& (msgs[i].len == 1)
&& (!msgs[i].flags & I2C_M_RD)
@@ -462,44 +461,55 @@ static int az6007_i2c_xfer(struct i2c_adapter 
*adap,struct i2c_msg msgs[],int nu
 * the first xfer has just 1 byte length.
 * Need to join both into one operation
 */
-   printk("az6007 I2C xfer write+read addr=0x%x len=%d/%d: 
",
-   addr, msgs[i].len, msgs[i + 1].len);
+   if (dvb_usb_az6007_debug & 2)
+   printk(KERN_DEBUG
+  "az6007 I2C xfer write+read addr=0x%x 
len=%d/%d: ",
+  addr, msgs[i].len, msgs[i + 1].len);
req = 0xb9;
-   index = 0;
-   value = addr;
-   for (j = 0; j < msgs[i].len; j++)
-   data[j] = msgs[i].buf[j];
+   index = msgs[i].buf[0];
+   value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
ret = az6007_usb_in_op(d,req,value,index,data,length);
if (ret >= len) {
for (j = 0; j < len; j++) {
msgs[i + 1].buf[j] = data[j + 5];
-   printk("0x%02x ", msgs[i + 1].buf[j]);
+   if (dvb_usb_az6007_debug & 2)
+   printk(KERN_CONT
+  "0x%02x ",
+  msgs[i + 1].buf[j]);
}
} else
ret = -EIO;
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
-// printk("az6007 I2C xfer write addr=0x%x len=%d: ",
-//  addr, msgs[i].len);
+   if (dvb_usb_az6007_debug & 2)
+   printk(KERN_DEBUG
+  "az6007 I2C xfer write addr=0x%x len=%d: 
",
+  addr, msgs[i].len);
req = 0xbd;
index = msgs[i].buf[0];
value = addr | (1 << 8);
length = msgs[i].len - 1;
len = msgs[i].len - 1;
-// printk("(0x%02x) ", msgs[i].buf[0]);
+   if (dvb_usb_az6007_debug & 2)
+   printk(KERN_CONT
+  "(0x%02x) ", msgs[i].buf[0]);
for (j = 0; j < len; j++)
{
data[j] = msgs[i].buf[j + 1];
-// printk("0x%02x ", data[j]);
+   if (dvb_usb_az6007_debug & 2)
+   printk(KERN_CONT
+  "0x%02x ", data[j]);
}
ret = az6007_usb_out_op(d,req,value,index,data,length);
} else {
/* read bytes */
-// printk("az6007 I2C xfer read addr=0x%x len=%d: ",
-//  addr, msgs[i].len);
+   if (dvb_usb_az6007_debug & 2)
+   printk(KERN_DEBUG
+  "az6007 I2C xfer read addr=0x%x len=%d: 
",
+  addr, msgs[i].len);
req = 0xb9;
index = msgs[i].buf[0];
value = addr;
@@ -509,10 +519,13 @@ static int 

[PATCH 09/35] [media] az6007: Replace the comments at the beginning of the driver

2012-01-21 Thread Mauro Carvalho Chehab
The comments there is wrong.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   23 ---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 1791cb0..f946b1b 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -1,6 +1,23 @@
-/* DVB USB compliant Linux driver for the AzureWave 6017 USB2.0 DVB-S
- * receiver.
- * see Documentation/dvb/README.dvb-usb for more information
+/*
+ * Driver for AzureWave 6007 DVB-C/T USB2.0 and clones
+ *
+ * Copyright (c) Henry Wang 
+ *
+ * This driver was made publicly available by Terratec, at:
+ * 
http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
+ * The original driver's license is GPL, as declared with MODULE_LICENSE()
+ *
+ *  Driver modifiyed by Mauro Carvalho Chehab  in order
+ * to work with upstream drxk driver, and to fix some bugs.
+ *
+ * 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 under version 2 of the License.
+ *
+ * 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 "drxk.h"
-- 
1.7.8

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


[PATCH 08/35] [media] az6007: Get rid of az6007.h

2012-01-21 Thread Mauro Carvalho Chehab
The header file serves for no purpose and exports some things
that should be static.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   11 +--
 drivers/media/dvb/dvb-usb/az6007.h |   18 --
 2 files changed, 9 insertions(+), 20 deletions(-)
 delete mode 100644 drivers/media/dvb/dvb-usb/az6007.h

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index a709cec..1791cb0 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -3,13 +3,15 @@
  * see Documentation/dvb/README.dvb-usb for more information
  */
 
-#include "az6007.h"
 #include "drxk.h"
 #include "mt2063.h"
 #include "dvb_ca_en50221.h"
+#include "dvb-usb.h"
+
+#define DVB_USB_LOG_PREFIX "az6007"
 
 /* HACK: Should be moved to the right place */
-#define USB_PID_AZUREWAVE_6007 0xccd
+#define USB_PID_AZUREWAVE_6007 0x0ccd
 #define USB_PID_TERRATEC_H70x10b4
 
 /* debug */
@@ -18,6 +20,11 @@ module_param_named(debug, dvb_usb_az6007_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))."
 DVB_USB_DEBUG_STATUS);
 
+#define deb_info(args...) dprintk(dvb_usb_az6007_debug, 0x01, args)
+#define deb_xfer(args...) dprintk(dvb_usb_az6007_debug, 0x02, args)
+#define deb_rc(args...)   dprintk(dvb_usb_az6007_debug, 0x04, args)
+#define deb_fe(args...)   dprintk(dvb_usb_az6007_debug, 0x08, args)
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct az6007_device_state {
diff --git a/drivers/media/dvb/dvb-usb/az6007.h 
b/drivers/media/dvb/dvb-usb/az6007.h
deleted file mode 100644
index aefa5b5..000
--- a/drivers/media/dvb/dvb-usb/az6007.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef _DVB_USB_AZ6007_H_
-#define _DVB_USB_AZ6007_H_
-
-#define DVB_USB_LOG_PREFIX "az6007"
-#include "dvb-usb.h"
-
-
-extern int dvb_usb_az6007_debug;
-#define deb_info(args...) dprintk(dvb_usb_az6007_debug,0x01,args)
-#define deb_xfer(args...) dprintk(dvb_usb_az6007_debug,0x02,args)
-#define deb_rc(args...)   dprintk(dvb_usb_az6007_debug,0x04,args)
-#define deb_fe(args...)   dprintk(dvb_usb_az6007_debug,0x08,args)
-
-
-extern int vp702x_usb_out_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, 
int ilen, int msec);
-extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 
index, u8 *b, int blen);
-
-#endif
-- 
1.7.8

--
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 07/35] [media] az6007: CodingStyle cleanup

2012-01-21 Thread Mauro Carvalho Chehab
make checkpatch.pl happy

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |  239 ++--
 1 files changed, 120 insertions(+), 119 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 1fc174b..a709cec 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -14,23 +14,24 @@
 
 /* debug */
 int dvb_usb_az6007_debug;
-module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." 
DVB_USB_DEBUG_STATUS);
+module_param_named(debug, dvb_usb_az6007_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))."
+DVB_USB_DEBUG_STATUS);
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct az6007_device_state {
-   struct dvb_ca_en50221 ca;
-   struct mutex ca_mutex;
-   u8 power_state;
+   struct  dvb_ca_en50221 ca;
+   struct  mutex ca_mutex;
+   u8  power_state;
 
/* Due to DRX-K - probably need changes */
-   int (*gate_ctrl)(struct dvb_frontend *, int);
-   struct semaphore  pll_mutex;
+   int (*gate_ctrl) (struct dvb_frontend *, int);
+   struct  semaphore pll_mutex;
booldont_attach_fe1;
 };
 
-struct drxk_config terratec_h7_drxk = {
+static struct drxk_config terratec_h7_drxk = {
.adr = 0x29,
.single_master = 1,
.no_i2c_bridge = 0,
@@ -43,7 +44,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
struct az6007_device_state *st;
int status;
 
-   info("%s: %s", __func__, enable? "enable" : "disable" );
+   info("%s: %s", __func__, enable ? "enable" : "disable");
 
if (!adap)
return -EINVAL;
@@ -53,7 +54,6 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
if (!st)
return -EINVAL;
 
-
if (enable) {
 #if 0
down(&st->pll_mutex);
@@ -68,30 +68,31 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int 
enable)
return status;
 }
 
-struct mt2063_config az6007_mt2063_config = {
+static struct mt2063_config az6007_mt2063_config = {
.tuner_address = 0x60,
.refclock = 36125000,
 };
 
 /* check for mutex FIXME */
-int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, 
u8 *b, int blen)
+static int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value,
+   u16 index, u8 *b, int blen)
 {
int ret = -1;
 
-   ret = usb_control_msg(d->udev,
-   usb_rcvctrlpipe(d->udev,0),
-   req,
-   USB_TYPE_VENDOR | USB_DIR_IN,
-   value,index,b,blen,
-   5000);
+   ret = usb_control_msg(d->udev,
+ usb_rcvctrlpipe(d->udev, 0),
+ req,
+ USB_TYPE_VENDOR | USB_DIR_IN,
+ value, index, b, blen, 5000);
 
if (ret < 0) {
warn("usb in operation failed. (%d)", ret);
return -EIO;
}
 
-   deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: 
",req,value,index);
-   debug_dump(b,blen,deb_xfer);
+   deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: ", req, value,
+index);
+   debug_dump(b, blen, deb_xfer);
 
return ret;
 }
@@ -101,21 +102,23 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
 {
int ret;
 
-   deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: 
",req,value,index);
-   debug_dump(b,blen,deb_xfer);
+   deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: ", req, value,
+index);
+   debug_dump(b, blen, deb_xfer);
 
if (blen > 64) {
-   printk(KERN_ERR "az6007: doesn't suport I2C transactions longer 
than 64 bytes\n");
+   printk(KERN_ERR
+  "az6007: doesn't suport I2C transactions longer than 64 
bytes\n");
return -EOPNOTSUPP;
}
 
-   if ((ret = usb_control_msg(d->udev,
-   usb_sndctrlpipe(d->udev,0),
-   req,
-   USB_TYPE_VENDOR | USB_DIR_OUT,
-   value,index,b,blen,
-   5000)) != blen) {
-   warn("usb out operation failed. (%d)",ret);
+   ret = usb_control_msg(d->udev,
+ usb_sndctrlpipe(d->udev, 0),
+ req,
+ USB_TYPE_VENDOR | USB_DIR_OUT,
+ value, index, b, blen, 5000);
+   if (ret != blen) {
+   warn("usb out operation failed. (%d)", ret);
return

[PATCH 14/35] [media] az6007: Fix some init sequences and use the right firmwares

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |  105 +++-
 1 files changed, 43 insertions(+), 62 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 87dff93..03e318d 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -56,7 +56,8 @@ static struct drxk_config terratec_h7_drxk = {
.single_master = 1,
.no_i2c_bridge = 0,
.max_size = 64,
-// .microcode_name = "dvb-usb-terratec-h5-drxk.fw",
+   .microcode_name = "dvb-usb-terratec-h7-drxk.fw",
+   .parallel_ts = 1,
 };
 
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
@@ -200,53 +201,31 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, 
u8 mac[6])
return 0;
 }
 
+#define AZ6007_POWER   0xbc
+#define FX2_SCON1  0xc0
+#define AZ6007_TS_THROUGH  0xc7
+
 static int az6007_frontend_poweron(struct dvb_usb_adapter *adap)
 {
-   int ret;
-   u8 req;
-   u16 value;
-   u16 index;
-   int blen;
+   struct dvb_usb_device *d = adap->dev;
 
deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
 adap, adap->dev);
 
-   req = 0xBC;
-   value = 1;  /* power on */
-   index = 3;
-   blen = 0;
-
-   ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
-   if (ret != 0) {
-   err("az6007_frontend_poweron failed!!!");
-   return -EIO;
-   }
-
-   msleep_interruptible(200);
-
-   req = 0xBC;
-   value = 0;  /* power off */
-   index = 3;
-   blen = 0;
-
-   ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
-   if (ret != 0) {
-   err("az6007_frontend_poweron failed!!!");
-   return -EIO;
-   }
-
-   msleep_interruptible(200);
-
-   req = 0xBC;
-   value = 1;  /* power on */
-   index = 3;
-   blen = 0;
+   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
+   msleep(150);
+   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+   msleep(100);
+   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
+   msleep(100);
+   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+   msleep(100);
+   az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
+   msleep (10);
+   az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
+   msleep (10);
+   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
 
-   ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
-   if (ret != 0) {
-   err("az6007_frontend_poweron failed!!!");
-   return -EIO;
-   }
deb_info("az6007_frontend_poweron: OK\n");
 
return 0;
@@ -333,25 +312,6 @@ static int az6007_led_on_off(struct usb_interface *intf, 
int onoff)
return ret;
 }
 
-static int az6007_frontend_tsbypass(struct dvb_usb_adapter *adap, int onoff)
-{
-   int ret;
-   u8 req;
-   u16 value;
-   u16 index;
-   int blen;
-   /* TS through */
-   req = 0xC7;
-   value = onoff;
-   index = 0;
-   blen = 0;
-
-   ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
-   if (ret != 0)
-   return -EIO;
-   return 0;
-}
-
 static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
 {
struct az6007_device_state *st = adap->priv;
@@ -409,6 +369,27 @@ out_free:
return result;
 }
 
+int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
+{
+   if (!onoff)
+   return 0;
+
+
+   info("Sending poweron sequence");
+
+   az6007_usb_out_op(d, AZ6007_TS_THROUGH /* 0xc7 */, 0, 0, NULL, 0);
+
+#if 0
+   // Seems to be a poweroff sequence
+   az6007_usb_out_op(d, 0xbc, 1, 3, NULL, 0);
+   az6007_usb_out_op(d, 0xbc, 1, 4, NULL, 0);
+   az6007_usb_out_op(d, 0xc0, 0, 3, NULL, 0);
+   az6007_usb_out_op(d, 0xc0, 1, 3, NULL, 0);
+   az6007_usb_out_op(d, 0xbc, 0, 1, NULL, 0);
+#endif
+   return 0;
+}
+
 static struct dvb_usb_device_properties az6007_properties;
 
 static void az6007_usb_disconnect(struct usb_interface *intf)
@@ -568,7 +549,7 @@ MODULE_DEVICE_TABLE(usb, az6007_usb_table);
 static struct dvb_usb_device_properties az6007_properties = {
.caps = DVB_USB_IS_AN_I2C_ADAPTER,
.usb_ctrl = CYPRESS_FX2,
-   .firmware= "dvb-usb-az6007-03.fw",
+   .firmware= "dvb-usb-terratec-h7-az6007.fw",
.no_reconnect= 1,
 
.identify_state = az6007_identify_state,
@@ -592,7 +573,7 @@ static struct dvb_usb_device_properties az6007_properties = 
{
.size_of_priv = sizeof(struct az6007_device_state),
}
},
-   /* .power_ctrl   = az6007_power_ctrl, */

[PATCH 10/35] [media] az6007: move device PID's to the proper place

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c  |4 
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h |2 ++
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index f946b1b..780a480 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -27,10 +27,6 @@
 
 #define DVB_USB_LOG_PREFIX "az6007"
 
-/* HACK: Should be moved to the right place */
-#define USB_PID_AZUREWAVE_6007 0x0ccd
-#define USB_PID_TERRATEC_H70x10b4
-
 /* debug */
 int dvb_usb_az6007_debug;
 module_param_named(debug, dvb_usb_az6007_debug, int, 0644);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h 
b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index d390dda..b3e7be4 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -80,6 +80,7 @@
 #define USB_PID_ANSONIC_DVBT_USB   0x6000
 #define USB_PID_ANYSEE 0x861f
 #define USB_PID_AZUREWAVE_AD_TU700 0x3237
+#define USB_PID_AZUREWAVE_6007 0x0ccd
 #define USB_PID_AVERMEDIA_DVBT_USB_COLD0x0001
 #define USB_PID_AVERMEDIA_DVBT_USB_WARM0x0002
 #define USB_PID_AVERMEDIA_DVBT_USB2_COLD   0xa800
@@ -226,6 +227,7 @@
 #define USB_PID_TERRATEC_CINERGY_T_EXPRESS 0x0062
 #define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078
 #define USB_PID_TERRATEC_CINERGY_T_XXS_2   0x00ab
+#define USB_PID_TERRATEC_H70x10b4
 #define USB_PID_TERRATEC_T30x10a0
 #define USB_PID_TERRATEC_T50x10a1
 #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e
-- 
1.7.8

--
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 15/35] [media] az6007: Change the az6007 read/write routine parameter

2012-01-21 Thread Mauro Carvalho Chehab
Use usb_device for those routines, as it allows using them on
all places. While there, rename to better express the meaning.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   56 ++--
 1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 03e318d..f098e47 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -96,13 +96,13 @@ static struct mt2063_config az6007_mt2063_config = {
 };
 
 /* check for mutex FIXME */
-static int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value,
+static int az6007_read(struct usb_device *udev, u8 req, u16 value,
u16 index, u8 *b, int blen)
 {
int ret = -1;
 
-   ret = usb_control_msg(d->udev,
- usb_rcvctrlpipe(d->udev, 0),
+   ret = usb_control_msg(udev,
+ usb_rcvctrlpipe(udev, 0),
  req,
  USB_TYPE_VENDOR | USB_DIR_IN,
  value, index, b, blen, 5000);
@@ -119,7 +119,7 @@ static int az6007_usb_in_op(struct dvb_usb_device *d, u8 
req, u16 value,
return ret;
 }
 
-static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
+static int az6007_write(struct usb_device *udev, u8 req, u16 value,
 u16 index, u8 *b, int blen)
 {
int ret;
@@ -134,8 +134,8 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
return -EOPNOTSUPP;
}
 
-   ret = usb_control_msg(d->udev,
- usb_sndctrlpipe(d->udev, 0),
+   ret = usb_control_msg(udev,
+ usb_sndctrlpipe(udev, 0),
  req,
  USB_TYPE_VENDOR | USB_DIR_OUT,
  value, index, b, blen, 5000);
@@ -168,7 +168,7 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * 
event, int *state)
 
/* remove the following return to enabled remote querying */
 
-   az6007_usb_in_op(d, READ_REMOTE_REQ, 0, 0, key, 10);
+   az6007_read(d->udev, READ_REMOTE_REQ, 0, 0, key, 10);
 
deb_rc("remote query key: %x %d\n", key[1], key[1]);
 
@@ -191,13 +191,13 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 
* event, int *state)
 int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)
 {
u8 v = onoff;
-   return az6007_usb_out_op(d,0xBC,v,3,NULL,1);
+   return az6007_write(d->udev,0xBC,v,3,NULL,1);
 }
 */
 
 static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6])
 {
-   az6007_usb_in_op(d, 0xb7, 6, 0, &mac[0], 6);
+   az6007_read(d->udev, 0xb7, 6, 0, &mac[0], 6);
return 0;
 }
 
@@ -212,19 +212,19 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter 
*adap)
deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
 adap, adap->dev);
 
-   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
+   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 2, NULL, 0);
msleep(150);
-   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
msleep(100);
-   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
+   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 3, NULL, 0);
msleep(100);
-   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
+   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 1, 4, NULL, 0);
msleep(100);
-   az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
+   az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 0, 3, NULL, 0);
msleep (10);
-   az6007_usb_out_op(d, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
+   az6007_write(d->udev, FX2_SCON1 /* 0xc0 */, 1, 3, NULL, 0);
msleep (10);
-   az6007_usb_out_op(d, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
+   az6007_write(d->udev, AZ6007_POWER /* 0xbc */, 0, 0, NULL, 0);
 
deb_info("az6007_frontend_poweron: OK\n");
 
@@ -246,7 +246,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter 
*adap)
value = 1;  /* high */
index = 3;
blen = 0;
-   ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+   ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
if (ret != 0) {
err("az6007_frontend_reset failed 1 !!!");
return -EIO;
@@ -257,7 +257,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter 
*adap)
index = 3;
blen = 0;
msleep_interruptible(200);
-   ret = az6007_usb_out_op(adap->dev, req, value, index, NULL, blen);
+   ret = az6007_write(adap->dev->udev, req, value, index, NULL, blen);
if (ret != 0) {
err("a

[PATCH 12/35] [media] drxk: Don't assume a default firmware name

2012-01-21 Thread Mauro Carvalho Chehab
Move the ngene/ddbridge firmware into their drivers.

There are two reasons for that:
1) The firmware used there didn't work for a few devices
I tested here (Terratec H5, H6 and H7);
2) At least Terratec H7 doesn't seem to require a firmware
for it to work.

After this change, if firmware is not specified, the driver will
use a rom-based firmware (this seems to be the case for Terratec
H7, although I need to better check the USB dumps to be sure about
that).

In any case, the firmware seems to be optional, as the DRX-K driver
don't return the firmware load error.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/ddbridge/ddbridge-core.c |1 +
 drivers/media/dvb/dvb-usb/az6007.c |8 +---
 drivers/media/dvb/frontends/drxk_hard.c|4 +---
 drivers/media/dvb/ngene/ngene-cards.c  |1 +
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c 
b/drivers/media/dvb/ddbridge/ddbridge-core.c
index 2f31648..243dbb3 100644
--- a/drivers/media/dvb/ddbridge/ddbridge-core.c
+++ b/drivers/media/dvb/ddbridge/ddbridge-core.c
@@ -578,6 +578,7 @@ static int demod_attach_drxk(struct ddb_input *input)
struct drxk_config config;
 
memset(&config, 0, sizeof(config));
+   config.microcode_name = "drxk_a3.mc";
config.adr = 0x29 + (input->nr & 1);
 
fe = input->fe = dvb_attach(drxk_attach, &config, i2c);
diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index bb597c6..523972f 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -55,7 +55,8 @@ static struct drxk_config terratec_h7_drxk = {
.adr = 0x29,
.single_master = 1,
.no_i2c_bridge = 0,
-   .microcode_name = "dvb-usb-terratec-h5-drxk.fw",
+   .max_size = 64,
+// .microcode_name = "dvb-usb-terratec-h5-drxk.fw",
 };
 
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
@@ -127,7 +128,8 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
debug_dump(b, blen, deb_xfer);
 
if (blen > 64) {
-   err("az6007: doesn't suport I2C transactions longer than 64 
bytes\n");
+   err("az6007: tried to write %d bytes, but I2C max size is 64 
bytes\n",
+   blen);
return -EOPNOTSUPP;
}
 
@@ -395,6 +397,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
adap->fe2->tuner_priv = adap->fe->tuner_priv;
memcpy(&adap->fe2->ops.tuner_ops,
   &adap->fe->ops.tuner_ops, sizeof(adap->fe->ops.tuner_ops));
+
return 0;
 
 out_free:
@@ -572,7 +575,6 @@ static struct dvb_usb_device_properties az6007_properties = 
{
.num_adapters = 1,
.adapter = {
{
-   /* .caps = 
DVB_USB_ADAP_RECEIVES_204_BYTE_TS, */
.streaming_ctrl   = az6007_streaming_ctrl,
.frontend_attach  = az6007_frontend_attach,
 
diff --git a/drivers/media/dvb/frontends/drxk_hard.c 
b/drivers/media/dvb/frontends/drxk_hard.c
index 6980ed7..4b99255 100644
--- a/drivers/media/dvb/frontends/drxk_hard.c
+++ b/drivers/media/dvb/frontends/drxk_hard.c
@@ -6070,9 +6070,7 @@ static int init_drxk(struct drxk_state *state)
if (status < 0)
goto error;
 
-   if (!state->microcode_name)
-   load_microcode(state, "drxk_a3.mc");
-   else
+   if (state->microcode_name)
load_microcode(state, state->microcode_name);
 
/* disable token-ring bus through OFDM block for possible ucode 
upload */
diff --git a/drivers/media/dvb/ngene/ngene-cards.c 
b/drivers/media/dvb/ngene/ngene-cards.c
index 8418c02..7539a5d 100644
--- a/drivers/media/dvb/ngene/ngene-cards.c
+++ b/drivers/media/dvb/ngene/ngene-cards.c
@@ -216,6 +216,7 @@ static int demod_attach_drxk(struct ngene_channel *chan,
struct drxk_config config;
 
memset(&config, 0, sizeof(config));
+   config.microcode_name = "drxk_a3.mc";
config.adr = 0x29 + (chan->number ^ 2);
 
chan->fe = dvb_attach(drxk_attach, &config, i2c);
-- 
1.7.8

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


[PATCH 13/35] [media] az6007: need to define drivers name before including dvb-usb.h

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 523972f..87dff93 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -23,9 +23,9 @@
 #include "drxk.h"
 #include "mt2063.h"
 #include "dvb_ca_en50221.h"
-#include "dvb-usb.h"
 
 #define DVB_USB_LOG_PREFIX "az6007"
+#include "dvb-usb.h"
 
 /* debug */
 int dvb_usb_az6007_debug;
-- 
1.7.8

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


[PATCH 11/35] [media] az6007: make driver less verbose

2012-01-21 Thread Mauro Carvalho Chehab
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |   35 +--
 1 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 780a480..bb597c6 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -62,9 +62,9 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 {
struct dvb_usb_adapter *adap = fe->sec_priv;
struct az6007_device_state *st;
-   int status;
+   int status = 0;
 
-   info("%s: %s", __func__, enable ? "enable" : "disable");
+   deb_info("%s: %s\n", __func__, enable ? "enable" : "disable");
 
if (!adap)
return -EINVAL;
@@ -127,8 +127,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
debug_dump(b, blen, deb_xfer);
 
if (blen > 64) {
-   printk(KERN_ERR
-  "az6007: doesn't suport I2C transactions longer than 64 
bytes\n");
+   err("az6007: doesn't suport I2C transactions longer than 64 
bytes\n");
return -EOPNOTSUPP;
}
 
@@ -138,7 +137,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
  USB_TYPE_VENDOR | USB_DIR_OUT,
  value, index, b, blen, 5000);
if (ret != blen) {
-   warn("usb out operation failed. (%d)", ret);
+   err("usb out operation failed. (%d)", ret);
return -EIO;
}
 
@@ -207,7 +206,8 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter 
*adap)
u16 index;
int blen;
 
-   info("az6007_frontend_poweron adap=%p adap->dev=%p", adap, adap->dev);
+   deb_info("az6007_frontend_poweron adap=%p adap->dev=%p\n",
+adap, adap->dev);
 
req = 0xBC;
value = 1;  /* power on */
@@ -245,7 +245,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter 
*adap)
err("az6007_frontend_poweron failed!!!");
return -EIO;
}
-   info("az6007_frontend_poweron: OK");
+   deb_info("az6007_frontend_poweron: OK\n");
 
return 0;
 }
@@ -258,7 +258,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter 
*adap)
u16 index;
int blen;
 
-   info("az6007_frontend_reset adap=%p adap->dev=%p", adap, adap->dev);
+   deb_info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, 
adap->dev);
 
/* reset demodulator */
req = 0xC0;
@@ -295,7 +295,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter 
*adap)
 
msleep_interruptible(200);
 
-   info("reset az6007 frontend");
+   deb_info("reset az6007 frontend\n");
 
return 0;
 }
@@ -361,8 +361,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
az6007_frontend_poweron(adap);
az6007_frontend_reset(adap);
 
-   info("az6007_frontend_attach: drxk");
-
+   info("az6007: attaching demod drxk");
adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
  &adap->dev->i2c_adap, &adap->fe2);
if (!adap->fe) {
@@ -370,7 +369,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
goto out_free;
}
 
-   info("Setting hacks");
+   deb_info("Setting hacks\n");
 
/* FIXME: do we need a pll semaphore? */
adap->fe->sec_priv = adap;
@@ -379,7 +378,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
adap->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
adap->fe2->id = 1;
 
-   info("az6007_frontend_attach: mt2063");
+   info("az6007: attaching tuner mt2063");
/* Attach mt2063 to DVB-C frontend */
if (adap->fe->ops.i2c_gate_ctrl)
adap->fe->ops.i2c_gate_ctrl(adap->fe, 1);
@@ -513,7 +512,7 @@ err:
mutex_unlock(&d->i2c_mutex);
 
if (ret < 0) {
-   info("%s ERROR: %i\n", __func__, ret);
+   info("%s ERROR: %i", __func__, ret);
return ret;
}
return num;
@@ -538,11 +537,11 @@ int az6007_identify_state(struct usb_device *udev,
  0xb7, USB_TYPE_VENDOR | USB_DIR_IN, 6, 0, b,
  6, USB_CTRL_GET_TIMEOUT);
 
-   info("FW GET_VERSION length: %d", ret);
+   deb_info("FW GET_VERSION length: %d\n", ret);
 
*cold = ret <= 0;
 
-   info("cold: %d", *cold);
+   deb_info("cold: %d\n", *cold);
return 0;
 }
 
@@ -629,7 +628,7 @@ static struct usb_driver az6007_usb_driver = {
 static int __init az6007_usb_module_init(void)
 {
int result;
-   info("az6007 usb module init");
+   deb_info("az6007 usb module init\n");
 
result = usb_register(&az6007_usb_driver);
if (result) {
@@ -643,7 +642,7 @@ static int __init az6007_usb_mod

[PATCH 01/35] [media] dvb: Add a new driver for az6007

2012-01-21 Thread Mauro Carvalho Chehab
Import the az6007 driver from Terratec H7 source, as-is.

It won't compile or run, so latter patches are needed in order
to fix it.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |  627 
 drivers/media/dvb/dvb-usb/az6007.h |   18 +
 2 files changed, 645 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/dvb/dvb-usb/az6007.c
 create mode 100644 drivers/media/dvb/dvb-usb/az6007.h

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
new file mode 100644
index 000..cd5dd4c
--- /dev/null
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -0,0 +1,627 @@
+/* DVB USB compliant Linux driver for the AzureWave 6017 USB2.0 DVB-S
+ * receiver.
+ * see Documentation/dvb/README.dvb-usb for more information
+ */
+
+#include "az6007.h"
+#include "drxk.h"
+#include "mt2063.h"
+#include "dvb_ca_en50221.h"
+
+/* debug */
+int dvb_usb_az6007_debug;
+module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." 
DVB_USB_DEBUG_STATUS);
+
+
+static int az6007_type =0;
+module_param(az6007_type, int, 0644);
+MODULE_PARM_DESC(az6007_type, "select delivery mode (0=DVB-T, 1=DVB-T");
+
+//module_param_named(type, 6007_type, int, 0644);
+//MODULE_PARM_DESC(type, "select delivery mode (0=DVB-T, 1=DVB-C)");
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+
+struct az6007_device_state {
+   struct dvb_ca_en50221 ca;
+   struct mutex ca_mutex;
+   u8 power_state;
+};
+
+struct drxk3913_config az6007_drxk3913_config_DVBT = { 
+   .demod_address = 0x52,
+   .min_delay_ms = 100,
+   .standard   = MTTUNEA_DVBT,
+   .set_tuner = mt2063_setTune,
+   .tuner_getlocked = mt2063_lockStatus,
+   .tuner_MT2063_Open = tuner_MT2063_Open,
+   .tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
+   .tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
+};
+
+struct drxk3913_config az6007_drxk3913_config_DVBC = { 
+   .demod_address = 0x52,
+   .min_delay_ms = 100,
+   .standard   = MTTUNEA_DVBC,
+   .set_tuner = mt2063_setTune,
+   .tuner_getlocked = mt2063_lockStatus,
+   .tuner_MT2063_Open = tuner_MT2063_Open,
+   .tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
+   .tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
+};
+
+struct mt2063_config az6007_mt2063_config = {
+   .tuner_address = 0xc0,
+   .refclock = 36125000,
+};
+
+/* check for mutex FIXME */
+int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, 
u8 *b, int blen)
+{
+   int ret = -1;
+
+   ret = usb_control_msg(d->udev,
+   usb_rcvctrlpipe(d->udev,0),
+   req,
+   USB_TYPE_VENDOR | USB_DIR_IN,
+   value,index,b,blen,
+   5000);
+
+   if (ret < 0) {
+   warn("usb in operation failed. (%d)", ret);
+   ret = -EIO;
+   } else
+   ret = 0;
+
+
+   deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: 
",req,value,index);
+   debug_dump(b,blen,deb_xfer);
+
+   return ret;
+}
+
+static int az6007_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
+u16 index, u8 *b, int blen)
+{
+   int ret;
+
+#if 0  
+   int i=0, cyc=0, rem=0;
+   cyc = blen/64;
+   rem = blen%64;
+#endif
+
+   deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: 
",req,value,index);
+   debug_dump(b,blen,deb_xfer);
+
+   
+#if 0
+   if (blen>64)
+   {
+   for (i=0; iudev,
+   usb_sndctrlpipe(d->udev,0),
+   req,
+   USB_TYPE_VENDOR | USB_DIR_OUT,
+   value,index+i*64,b+i*64,64,
+   5000)) != 64) {
+   warn("usb out operation failed. (%d)",ret);
+   return -EIO;
+   }   
+   }
+
+   if (rem>0)
+   {
+   if ((ret = usb_control_msg(d->udev,
+   usb_sndctrlpipe(d->udev,0),
+   req,
+   USB_TYPE_VENDOR | USB_DIR_OUT,
+   value,index+cyc*64,b+cyc*64,rem,
+   5000)) != rem) {
+   warn("usb out operation failed. (%d)",ret);
+   return -EIO;
+   }
+   }
+   }
+   else
+#endif 
+   {
+   if ((ret = usb_control_msg(d->udev,
+   usb_sndctrlpipe(d->udev,0),
+   req,
+   USB_TYPE_VENDOR | USB_DIR_OUT,
+  

[PATCH 02/35] [media] az6007: Fix compilation troubles at az6007

2012-01-21 Thread Mauro Carvalho Chehab
Some changes are needed, in order to make az6007 compile with the
upstream tree. Most of the changes are due to the upstream drxk
module.

Even allowing its compilation, the driver is not working yet.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/common/tuners/mt2063.c |2 +-
 drivers/media/dvb/dvb-usb/az6007.c   |  174 --
 2 files changed, 104 insertions(+), 72 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index c89af3c..7bbf25d 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -350,7 +350,7 @@ static int MT2063_Sleep(struct dvb_frontend *fe)
/*
 *  ToDo:  Add code here to implement a OS blocking
 */
-   msleep(10);
+   msleep(100);
 
return 0;
 }
diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index cd5dd4c..5873759 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -8,6 +8,10 @@
 #include "mt2063.h"
 #include "dvb_ca_en50221.h"
 
+/* HACK: Should be moved to the right place */
+#define USB_PID_AZUREWAVE_6007 0xccd
+#define USB_PID_TERRATEC_H70x10b4
+
 /* debug */
 int dvb_usb_az6007_debug;
 module_param_named(debug,dvb_usb_az6007_debug, int, 0644);
@@ -28,30 +32,39 @@ struct az6007_device_state {
struct dvb_ca_en50221 ca;
struct mutex ca_mutex;
u8 power_state;
-};
 
-struct drxk3913_config az6007_drxk3913_config_DVBT = { 
-   .demod_address = 0x52,
-   .min_delay_ms = 100,
-   .standard   = MTTUNEA_DVBT,
-   .set_tuner = mt2063_setTune,
-   .tuner_getlocked = mt2063_lockStatus,
-   .tuner_MT2063_Open = tuner_MT2063_Open,
-   .tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
-   .tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
+   /* Due to DRX-K - probably need changes */
+   int (*gate_ctrl)(struct dvb_frontend *, int);
+   struct semaphore  pll_mutex;
+   booldont_attach_fe1;
 };
 
-struct drxk3913_config az6007_drxk3913_config_DVBC = { 
-   .demod_address = 0x52,
-   .min_delay_ms = 100,
-   .standard   = MTTUNEA_DVBC,
-   .set_tuner = mt2063_setTune,
-   .tuner_getlocked = mt2063_lockStatus,
-   .tuner_MT2063_Open = tuner_MT2063_Open,
-   .tuner_MT2063_SoftwareShutdown = tuner_MT2063_SoftwareShutdown,
-   .tuner_MT2063_ClearPowerMaskBits = tuner_MT2063_ClearPowerMaskBits,
+struct drxk_config terratec_h7_drxk = {
+   .adr = 0x29,
+   .single_master = 1,
+   .no_i2c_bridge = 1,
+   .microcode_name = "dvb-usb-terratec-h5-drxk.fw",
 };
 
+static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
+{
+   struct dvb_usb_adapter *adap = fe->sec_priv;
+   struct az6007_device_state *st = adap->priv;
+   int status;
+
+   if (!adap || !st)
+   return -EINVAL;
+
+   if (enable) {
+   down(&st->pll_mutex);
+   status = st->gate_ctrl(fe, 1);
+   } else {
+   status = st->gate_ctrl(fe, 0);
+   up(&st->pll_mutex);
+   }
+   return status;
+}
+
 struct mt2063_config az6007_mt2063_config = {
.tuner_address = 0xc0,
.refclock = 36125000,
@@ -87,7 +100,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
 {
int ret;
 
-#if 0  
+#if 0
int i=0, cyc=0, rem=0;
cyc = blen/64;
rem = blen%64;
@@ -96,7 +109,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
deb_xfer("out: req. %02x, val: %04x, ind: %04x, buffer: 
",req,value,index);
debug_dump(b,blen,deb_xfer);
 
-   
+
 #if 0
if (blen>64)
{
@@ -110,7 +123,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
5000)) != 64) {
warn("usb out operation failed. (%d)",ret);
return -EIO;
-   }   
+   }
}
 
if (rem>0)
@@ -127,7 +140,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
}
}
else
-#endif 
+#endif
{
if ((ret = usb_control_msg(d->udev,
usb_sndctrlpipe(d->udev,0),
@@ -139,7 +152,7 @@ static int az6007_usb_out_op(struct dvb_usb_device *d, u8 
req, u16 value,
return -EIO;
}
}
-   
+
return 0;
 }
 
@@ -149,9 +162,9 @@ static int az6007_streaming_ctrl(struct dvb_usb_adapter 
*adap, int onoff)
 }
 
 /* keys for the enclosed remote control */
-static struct dvb_usb_rc_key az6007_rc_keys[] = {
-   { 0x00, 0x01, KEY_1 },
-   { 0x00, 0x02, KEY_2 },
+struct rc_map_table rc_map_az6007_table[] = {
+   

[PATCH 03/35] [media] az6007: Fix it to allow loading it without crash

2012-01-21 Thread Mauro Carvalho Chehab
Add some fixes to allow frontend attachment. The patch is not
complete yet, as just the frontend 0 is initialized. So, more
changes will be needed, including some changes at dvb-usb core.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/dvb/dvb-usb/az6007.c |  190 ++-
 1 files changed, 98 insertions(+), 92 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/az6007.c 
b/drivers/media/dvb/dvb-usb/az6007.c
index 5873759..6a21f92 100644
--- a/drivers/media/dvb/dvb-usb/az6007.c
+++ b/drivers/media/dvb/dvb-usb/az6007.c
@@ -49,12 +49,20 @@ struct drxk_config terratec_h7_drxk = {
 static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 {
struct dvb_usb_adapter *adap = fe->sec_priv;
-   struct az6007_device_state *st = adap->priv;
+   struct az6007_device_state *st;
int status;
 
-   if (!adap || !st)
+   info("%s", __func__);
+
+   if (!adap)
+   return -EINVAL;
+
+   st = adap->priv;
+
+   if (!st)
return -EINVAL;
 
+
if (enable) {
down(&st->pll_mutex);
status = st->gate_ctrl(fe, 1);
@@ -66,7 +74,7 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
 }
 
 struct mt2063_config az6007_mt2063_config = {
-   .tuner_address = 0xc0,
+   .tuner_address = 0x60,
.refclock = 36125000,
 };
 
@@ -84,10 +92,8 @@ int az6007_usb_in_op(struct dvb_usb_device *d, u8 req, u16 
value, u16 index, u8
 
if (ret < 0) {
warn("usb in operation failed. (%d)", ret);
-   ret = -EIO;
-   } else
-   ret = 0;
-
+   return -EIO;
+   }
 
deb_xfer("in: req. %02x, val: %04x, ind: %04x, buffer: 
",req,value,index);
debug_dump(b,blen,deb_xfer);
@@ -219,7 +225,7 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter 
*adap)
u16 index;
int blen;
 
-   info("az6007_frontend_poweron adap=%p adap->dev=%p\n", adap, adap->dev);
+   info("az6007_frontend_poweron adap=%p adap->dev=%p", adap, adap->dev);
 
req = 0xBC;
value = 1;//power on
@@ -257,7 +263,8 @@ static int az6007_frontend_poweron(struct dvb_usb_adapter 
*adap)
err("az6007_frontend_poweron failed!!!");
 return -EIO;
}
-   info("az6007_frontend_poweron\n");
+   info("az6007_frontend_poweron: OK");
+
return 0;
 }
 
@@ -269,7 +276,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter 
*adap)
u16 index;
int blen;
 
-   info("az6007_frontend_reset adap=%p adap->dev=%p\n", adap, adap->dev);
+   info("az6007_frontend_reset adap=%p adap->dev=%p", adap, adap->dev);
 
//reset demodulator
req = 0xC0;
@@ -306,7 +313,7 @@ static int az6007_frontend_reset(struct dvb_usb_adapter 
*adap)
 
msleep_interruptible(200);
 
-   info("reset az6007 frontend\n");
+   info("reset az6007 frontend");
 
return 0;
 }
@@ -367,10 +374,12 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
 
int result;
 
+   BUG_ON(!st);
+
az6007_frontend_poweron(adap);
az6007_frontend_reset(adap);
 
-   info("az6007_frontend_attach\n");
+   info("az6007_frontend_attach: drxk");
 
adap->fe = dvb_attach(drxk_attach, &terratec_h7_drxk,
  &adap->dev->i2c_adap, &adap->fe2);
@@ -379,6 +388,8 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
goto out_free;
}
 
+   info("Setting hacks");
+
/* FIXME: do we need a pll semaphore? */
adap->fe->sec_priv = adap;
sema_init(&st->pll_mutex, 1);
@@ -386,6 +397,7 @@ static int az6007_frontend_attach(struct dvb_usb_adapter 
*adap)
adap->fe->ops.i2c_gate_ctrl = drxk_gate_ctrl;
adap->fe2->id = 1;
 
+   info("az6007_frontend_attach: mt2063");
/* Attach mt2063 to DVB-C frontend */
if (adap->fe->ops.i2c_gate_ctrl)
adap->fe->ops.i2c_gate_ctrl(adap->fe, 1);
@@ -423,100 +435,95 @@ az6007_usb_disconnect(struct usb_interface *intf)
 }
 
 /* I2C */
-static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int 
num)
+static int az6007_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msgs[],int 
num)
 {
struct dvb_usb_device *d = i2c_get_adapdata(adap);
-   int j=0,len=0;
-   int ret=0;
+   int i, j, len;
+   int ret = 0;
u16 index;
u16 value;
int length;
-   u8 req;
+   u8 req, addr;
u8 data[512];
 
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
-   if (num > 2)
-   warn("more than 2 i2c messages at a time is not handled yet. 
TODO.");
 
-
-   if (msg[0].addr == 0xc0) //MT2063
-   {
-   if (msg[0].flags != I2C_M_RD) //write
-   {
-   //printk("Tuner Tuner Write DevAddr=%02x  
RegAddr=%d\n", msg

Re: [patch 2/2] [media] ds3000: off by one in ds3000_read_snr()

2012-01-21 Thread Dan Carpenter
On Thu, Jan 19, 2012 at 03:22:02PM +0300, Dan Carpenter wrote:
> It's a good point.  I will redo the patch.

Sorry, I've decided to bail on this.  The original code is buggy but
I don't know what's going on well enough to fix it with any
confidence.

regards,
dan carpenter



signature.asc
Description: Digital signature


[PATCH] anysee: repeat failed USB control messages

2012-01-21 Thread Antti Palosaari
Control message load increased heavily after CI/CAM support due
to dvb_ca_en50221. It looks like CI/CAM drops to non-working
state easily after error is returned to its callbacks. Due to
that, add some logic to avoid errors repeating failed messages.

Signed-off-by: Antti Palosaari 
---
 drivers/media/dvb/dvb-usb/anysee.c |   38 ++-
 1 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/anysee.c 
b/drivers/media/dvb/dvb-usb/anysee.c
index fdee856..6eb7046 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -58,7 +58,7 @@ static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 
*sbuf, u8 slen,
u8 *rbuf, u8 rlen)
 {
struct anysee_state *state = d->priv;
-   int act_len, ret;
+   int act_len, ret, i;
u8 buf[64];
 
memcpy(&buf[0], sbuf, slen);
@@ -73,26 +73,52 @@ static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 
*sbuf, u8 slen,
/* We need receive one message more after dvb_usb_generic_rw due
   to weird transaction flow, which is 1 x send + 2 x receive. */
ret = dvb_usb_generic_rw(d, buf, sizeof(buf), buf, sizeof(buf), 0);
-   if (!ret) {
+   if (ret)
+   goto error_unlock;
+
+   /* TODO FIXME: dvb_usb_generic_rw() fails rarely with error code -32
+* (EPIPE, Broken pipe). Function supports currently msleep() as a
+* parameter but I would not like to use it, since according to
+* Documentation/timers/timers-howto.txt it should not be used such
+* short, under < 20ms, sleeps. Repeating failed message would be
+* better choice as not to add unwanted delays...
+* Fixing that correctly is one of those or both;
+* 1) use repeat if possible
+* 2) add suitable delay
+*/
+
+   /* get answer, retry few times if error returned */
+   for (i = 0; i < 3; i++) {
/* receive 2nd answer */
ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev,
d->props.generic_bulk_ctrl_endpoint), buf, sizeof(buf),
&act_len, 2000);
-   if (ret)
-   err("%s: recv bulk message failed: %d", __func__, ret);
-   else {
+
+   if (ret) {
+   deb_info("%s: recv bulk message failed: %d",
+   __func__, ret);
+   } else {
deb_xfer("<<< ");
debug_dump(buf, rlen, deb_xfer);
 
if (buf[63] != 0x4f)
deb_info("%s: cmd failed\n", __func__);
+
+   break;
}
}
 
+   if (ret) {
+   /* all retries failed, it is fatal */
+   err("%s: recv bulk message failed: %d", __func__, ret);
+   goto error_unlock;
+   }
+
/* read request, copy returned data to return buf */
-   if (!ret && rbuf && rlen)
+   if (rbuf && rlen)
memcpy(rbuf, buf, rlen);
 
+error_unlock:
mutex_unlock(&anysee_usb_mutex);
 
return ret;
-- 
1.7.4.4

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


Re: [PATCH/RFC v4 3/3] gspca: zc3xx: Add V4L2_CID_JPEG_COMPRESSION_QUALITY control support

2012-01-21 Thread Sylwester Nawrocki
On 01/14/2012 08:53 PM, Sylwester Nawrocki wrote:
> The JPEG compression quality control is currently done by means of the
> VIDIOC_S/G_JPEGCOMP ioctls. As the quality field of struct v4l2_jpgecomp
> is being deprecated, we add the V4L2_CID_JPEG_COMPRESSION_QUALITY control,
> so after the deprecation period VIDIOC_S/G_JPEGCOMP ioctl handlers can be
> removed, leaving the control the only user interface for compression
> quality configuration.
> 
> Cc: Jean-Francois Moine
> Signed-off-by: Sylwester Nawrocki

Dear Jean-Francois,

is this patch looking OK or you, or would you have any further remarks ?
I'd like to add it to a pull request in coming week, together with remaining
patches in this series plus a patch for some SoC JPEG codec driver.
Please let me know if there is anything that could be changed/improved.

--
Best regards,
Sylwester

> ---
> Removed unneeded substitution of jpeg_set_qual() with set_quality().
> 
>   drivers/media/video/gspca/zc3xx.c |   43 
> +
>   1 files changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/video/gspca/zc3xx.c 
> b/drivers/media/video/gspca/zc3xx.c
> index f22e02f..1b78598 100644
> --- a/drivers/media/video/gspca/zc3xx.c
> +++ b/drivers/media/video/gspca/zc3xx.c
> @@ -46,6 +46,7 @@ enum e_ctrl {
>   AUTOGAIN,
>   LIGHTFREQ,
>   SHARPNESS,
> + QUALITY,
>   NCTRLS  /* number of controls */
>   };
> 
> @@ -57,11 +58,6 @@ struct sd {
> 
>   struct gspca_ctrl ctrls[NCTRLS];
> 
> - u8 quality; /* image quality */
> -#define QUALITY_MIN 50
> -#define QUALITY_MAX 80
> -#define QUALITY_DEF 70
> -
>   u8 bridge;
>   u8 sensor;  /* Type of image sensor chip */
>   u16 chip_revision;
> @@ -101,6 +97,12 @@ static void setexposure(struct gspca_dev *gspca_dev);
>   static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
>   static void setlightfreq(struct gspca_dev *gspca_dev);
>   static void setsharpness(struct gspca_dev *gspca_dev);
> +static void set_quality(struct gspca_dev *gspca_dev);
> +
> +/* JPEG image quality */
> +#define QUALITY_MIN 50
> +#define QUALITY_MAX 80
> +#define QUALITY_DEF 70
> 
>   static const struct ctrl sd_ctrls[NCTRLS] = {
>   [BRIGHTNESS] = {
> @@ -188,6 +190,18 @@ static const struct ctrl sd_ctrls[NCTRLS] = {
>   },
>   .set_control = setsharpness
>   },
> +[QUALITY] = {
> + {
> + .id  = V4L2_CID_JPEG_COMPRESSION_QUALITY,
> + .type= V4L2_CTRL_TYPE_INTEGER,
> + .name= "Compression Quality",
> + .minimum = QUALITY_MIN,
> + .maximum = QUALITY_MAX,
> + .step= 1,
> + .default_value = QUALITY_DEF,
> + },
> + .set_control = set_quality
> + },
>   };
> 
>   static const struct v4l2_pix_format vga_mode[] = {
> @@ -6411,7 +6425,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
>   sd->sensor = id->driver_info;
> 
>   gspca_dev->cam.ctrls = sd->ctrls;
> - sd->quality = QUALITY_DEF;
> 
>   return 0;
>   }
> @@ -6685,7 +6698,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
>   /* create the JPEG header */
>   jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
>   0x21);  /* JPEG 422 */
> - jpeg_set_qual(sd->jpeg_hdr, sd->quality);
> + jpeg_set_qual(sd->jpeg_hdr, sd->ctrls[QUALITY].val);
> 
>   mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
>   switch (sd->sensor) {
> @@ -6893,17 +6906,19 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
>   return -EINVAL;
>   }
> 
> +static void set_quality(struct gspca_dev *gspca_dev)
> +{
> + struct sd *sd = (struct sd *) gspca_dev;
> + jpeg_set_qual(sd->jpeg_hdr, sd->ctrls[QUALITY].val);
> +}
> +
>   static int sd_set_jcomp(struct gspca_dev *gspca_dev,
>   struct v4l2_jpegcompression *jcomp)
>   {
>   struct sd *sd = (struct sd *) gspca_dev;
> 
> - if (jcomp->quality<  QUALITY_MIN)
> - sd->quality = QUALITY_MIN;
> - else if (jcomp->quality>  QUALITY_MAX)
> - sd->quality = QUALITY_MAX;
> - else
> - sd->quality = jcomp->quality;
> + sd->ctrls[QUALITY].val = clamp_t(u8, jcomp->quality,
> +  QUALITY_MIN, QUALITY_MAX);
>   if (gspca_dev->streaming)
>   jpeg_set_qual(sd->jpeg_hdr, sd->quality);
>   return gspca_dev->usb_err;
> @@ -6915,7 +6930,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
>   struct sd *sd = (struct sd *) gspca_dev;
> 
>   memset(jcomp, 0, sizeof *jcomp);
> - jcomp->quality = sd->quality;
> + jcomp->quality = sd->ctrls[QUALITY].val;
>   jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
>   | V4L2_JPEG_MARKER_DQT;
>   return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to 

Re: Siano DVB USB device called "Smart Plus"

2012-01-21 Thread Denilson Figueiredo de Sá
On Fri, Jan 20, 2012 at 08:01, Mauro Carvalho Chehab  wrote:
>
>> Then I added a few lines, as shown below, but it seems
>> the driver still tries to load "dvb_nova_12mhz_b0.inp" instead of
>> "isdbt_nova_12mhz_b0.inp".
>
> No. there's a parameter for the smsmdtv module to select the right
> standard:
>
> drivers/media/dvb/siano/smscoreapi.c:module_param(default_mode, int, 0644);
>
> You need to pass "default_mode=6" for ISDB-T to work. Just renaming
> the firmware won't work. Of course, the firmware name entry needs to be
> filled.

Okay, I did:
modprobe smsmdtv default_mode=6
Now it loads the correct firmware. But, still, neither vlc nor w_scan
can find any channels.

I bet it requires deeper debugging and more knowledge than what I have now.

-- 
Denilson Figueiredo de Sá
Belo Horizonte - Brasil
--
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: No video0, /dev/dvb/adapter0 present

2012-01-21 Thread Steve Myatt
Cliffe  ii.net> writes:

> 
> Hello I would really appreciate some help.
> 
[...cropped...]
> [9.079590] af9013: found a 'Afatech AF9013 DVB-T' in warm state.
> [9.082319] af9013: firmware version:4.95.0
> [9.094043] DVB: registering adapter 1 frontend 0 (Afatech AF9013 
> DVB-T)...
> [9.094211] tda18271 1-00c0: creating new instance
> [9.096393] af9015: command failed:2
> [9.098032] tda18271_read_regs: [1-00c0|M] ERROR: i2c_transfer 
> returned: -1
> [9.098046] Unknown device detected @ 1-00c0, device not supported.
> [9.100368] af9015: command failed:2
[...cropped...]
> Thanks,
> 
> Cliffe.
> 
> 


Hi Cliffe

Have you checked to see if there's a different report after a completely cold
(power plug out) boot, compared to a warm reboot?

I'm chasing what appears to me to be a similar problem, different card, same
chips (by the look of it) and I found the same report in my syslog:

Unknown device detected @ 1-00c0, device not supported.

I see you haven't had any responses here; did you get any further with this?

Symptoms in my system: got a dual tuner card (PEAK 221544AGPK PCI) which,
following warm boot, doesn't see the second tuner. Suspect firmware not being
loaded due to warm state. I'm documenting this at

http://www.slm.dnsdojo.net/content/tech/myth/index.php#begin_peak.html

Cheers
Steve Myatt

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


Re: [PATCH] [media] convert drivers/media/* to use module_i2c_driver()

2012-01-21 Thread Sylwester Nawrocki
On 01/21/2012 11:10 AM, Axel Lin wrote:
> This patch converts the drivers in drivers/media/* to use the
> module_i2_driver() macro which makes the code smaller and a bit simpler.
> 
> Signed-off-by: Axel Lin

For s5k6aa, noon010pc30, sr030pc30, m5mols modules,

Acked-by: Sylwester Nawrocki 

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


Re: [PATCH] [media] convert drivers/media/* to use module_i2c_driver()

2012-01-21 Thread Laurent Pinchart
Hi Axel,

Thanks for the patch.

On Saturday 21 January 2012 11:10:45 Axel Lin wrote:
> This patch converts the drivers in drivers/media/* to use the
> module_i2_driver() macro which makes the code smaller and a bit simpler.
> 
> Signed-off-by: Axel Lin 

For the following modules,

>  drivers/media/video/adp1653.c |   19 +
>  drivers/media/video/as3645a.c |   19 +
>  drivers/media/video/mt9p031.c |   13 +--
>  drivers/media/video/mt9t001.c |   13 +--
>  drivers/media/video/mt9v032.c |   13 +--

Acked-by: Laurent Pinchart 

-- 
Regards,

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


Re: DVB-S2 multistream support

2012-01-21 Thread Christian Prähauser

Dear Marek,

Konstantin and I are currently work on making the BB-demux work with  
recent version of Linux DVB
and the TBS 6925. We well let you know as soon as a working patch is  
available (early february).


In the meantime, maybe you want to tell me more about your use-case,  
for helping us understand
what the user-space API requirements are. I assume you need the data  
in user-space? Would it be

enough for you if you receive the BBFrames (header + data field)?

Kind regards,
Christian.

Am 19.01.2012 um 14:34 schrieb Marek Ochaba:


Hello Christian,

we interest to your patch for BBFrame demux (we want to read some BBF
header flags and read GS decapsulated data). Could you please publish
latest version of it ? And send link to it ?

Is there also need adaptation in device driver ? We want to us it by  
DVB-S2

card TBS-6925, which use STV0900 chip.

--
Marek Ochaba


---
Dipl.-Ing. Christian Praehauser 

|| //\\//\\ || Multimedia Communications Group,
||//  \/  \\|| Department of Computer Sciences, University of Salzburg
http://www.cosy.sbg.ac.at/~cpraehaus/
http://www.network-research.org/
http://www.uni-salzburg.at/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] convert drivers/media/* to use module_i2c_driver()

2012-01-21 Thread Axel Lin
This patch converts the drivers in drivers/media/* to use the
module_i2_driver() macro which makes the code smaller and a bit simpler.

Signed-off-by: Axel Lin 
Cc: Mauro Carvalho Chehab 
Cc: Kyungmin Park 
Cc: Heungjun Kim 
Cc: Jonathan Corbet 
Cc: Tomasz Stanislawski 
Cc: Hans Verkuil 
Cc: Joonyoung Shim 
Cc: Laurent Pinchart 
Cc: Guennadi Liakhovetski 
Cc: Andrew Chew 
Cc: Paul Mundt 
Cc: Michael Grzeschik 
Cc: Johannes Obermaier 
Cc: Sylwester Nawrocki 
Cc: Steven Toth 
---
 drivers/media/dvb/frontends/au8522_decoder.c  |   13 +--
 drivers/media/radio/radio-tea5764.c   |   19 +
 drivers/media/radio/saa7706h.c|   13 +--
 drivers/media/radio/si470x/radio-si470x-i2c.c |   28 +
 drivers/media/radio/si4713-i2c.c  |   15 +
 drivers/media/radio/tef6862.c |   14 +---
 drivers/media/video/adp1653.c |   19 +
 drivers/media/video/adv7170.c |   13 +--
 drivers/media/video/adv7175.c |   13 +--
 drivers/media/video/adv7180.c |   14 +---
 drivers/media/video/adv7343.c |   13 +--
 drivers/media/video/ak881x.c  |   13 +--
 drivers/media/video/as3645a.c |   19 +
 drivers/media/video/bt819.c   |   13 +--
 drivers/media/video/bt856.c   |   13 +--
 drivers/media/video/bt866.c   |   13 +--
 drivers/media/video/cs5345.c  |   13 +--
 drivers/media/video/cs53l32a.c|   13 +--
 drivers/media/video/cx25840/cx25840-core.c|   13 +--
 drivers/media/video/imx074.c  |   13 +--
 drivers/media/video/indycam.c |   13 +--
 drivers/media/video/ir-kbd-i2c.c  |   17 ++
 drivers/media/video/ks0127.c  |   13 +--
 drivers/media/video/m52790.c  |   13 +--
 drivers/media/video/m5mols/m5mols_core.c  |   13 +--
 drivers/media/video/msp3400-driver.c  |   13 +--
 drivers/media/video/mt9m001.c |   13 +--
 drivers/media/video/mt9m111.c |   13 +--
 drivers/media/video/mt9p031.c |   13 +--
 drivers/media/video/mt9t001.c |   13 +--
 drivers/media/video/mt9t031.c |   13 +--
 drivers/media/video/mt9t112.c |   16 +-
 drivers/media/video/mt9v011.c |   13 +--
 drivers/media/video/mt9v022.c |   13 +--
 drivers/media/video/mt9v032.c |   13 +--
 drivers/media/video/noon010pc30.c |   13 +--
 drivers/media/video/ov2640.c  |   16 +-
 drivers/media/video/ov5642.c  |   13 +--
 drivers/media/video/ov6650.c  |   13 +--
 drivers/media/video/ov7670.c  |   13 +--
 drivers/media/video/ov772x.c  |   17 +--
 drivers/media/video/ov9640.c  |   13 +--
 drivers/media/video/ov9740.c  |   13 +--
 drivers/media/video/rj54n1cb0c.c  |   13 +--
 drivers/media/video/s5k6aa.c  |   13 +--
 drivers/media/video/s5p-tv/hdmiphy_drv.c  |   12 +-
 drivers/media/video/saa6588.c |   13 +--
 drivers/media/video/saa7110.c |   13 +--
 drivers/media/video/saa7115.c |   13 +--
 drivers/media/video/saa7127.c |   13 +--
 drivers/media/video/saa7134/saa6752hs.c   |   13 +--
 drivers/media/video/saa717x.c |   13 +--
 drivers/media/video/saa7185.c |   13 +--
 drivers/media/video/saa7191.c |   13 +--
 drivers/media/video/sr030pc30.c   |   13 +--
 drivers/media/video/tda7432.c |   13 +--
 drivers/media/video/tda9840.c |   13 +--
 drivers/media/video/tea6415c.c|   13 +--
 drivers/media/video/tea6420.c |   13 +--
 drivers/media/video/ths7303.c |   14 +---
 drivers/media/video/tlv320aic23b.c|   13 +--
 drivers/media/video/tuner-core.c  |   13 +--
 drivers/media/video/tvaudio.c |   13 +--
 drivers/media/video/tvp514x.c |   13 +--
 drivers/media/video/tvp5150.c |   13 +--
 drivers/media/video/tvp7002.c |   25 +-
 drivers/media/video/tw9910.c  |   16 +-
 drivers/media/video/upd64031a.