[PATCH] media: media-dev: Add media devices for EXYNOS5

2012-02-14 Thread Sungchun Kang
Since the EXYNOS5 SoCs have various multimedia IPs
such as Gscaler, FIMC-LITE, and MIXER, and so on.
Additionally, media controller interface is needed
to configure connection between them and to control each IPs.

This patch adds support media device for EXYNOS5 SoCs.
Actually, there are three media devices such as below
diagram which are using media control framework.
Since they are not belong to one hardware block, we
need to manage it for connecting with each devices.

Follwing is detailed list of them:

* Gscaler: general scaler
  Support memory to memory interface
  Support output interface from memory to display device(LCD, TV)
  Support capture interface from device(FIMC-LITE, FIMD) to memory

* MIPI-CSIS
  Support interconnection(subdev interface) between devices

* FIMC-LITE
  Support capture interface from device(Sensor, MIPI-CSIS) to memory
  Support interconnection(subdev interface) between devices

* MIXER
  Support output interface from memory to device(HDMI)
  Support interconnection(subdev interface) between devices

* FIMD
  Support framebuffer interface
  Support subdev interface to display frames sent from Gscaler

* Rotator
  Support memory to memory interface

* m2m-scaler
  Support only memory to memory interface

* And so on...

 1) media 0
  LCD Output path consists of Gscaler and FIMD(display controller).
  ++ +--+
  | Gscaler-output | --> | FIMD | --> LCD
  ++ +--+

  HDMI Output path consists of Gscaler, Mixer and HDMI.
  ++ +---+ +--+
  | Gscaler-output | --> | MIXER | --> | HDMI | --> TV
  ++ +---+ +--+

++ +---+ +---+ +-+

 2) media 1
  Camera Capture path consists of MIPI-CSIS, FIMC-LITE and Gscaler
  ++ +---+ +-+
  | Sensor | --> | FIMC-LITE | --> | Gscaler-capture |
  ++ +---+ +-+

  ++ +---+ +---+ +-+
  | Sensor | --> | MIPI-CSIS | --> | FIMC-LITE | --> | Gscaler-capture |
  ++ +---+ +---+ +-+

Signed-off-by: Sungchun Kang 
---
 drivers/media/video/exynos/mdev/Kconfig   |8 ++
 drivers/media/video/exynos/mdev/Makefile  |2 +
 drivers/media/video/exynos/mdev/exynos-mdev.c |  115 ++
 include/media/exynos_mc.h |  160 +
 4 files changed, 285 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/exynos/mdev/Kconfig
 create mode 100644 drivers/media/video/exynos/mdev/Makefile
 create mode 100644 drivers/media/video/exynos/mdev/exynos-mdev.c
 create mode 100644 include/media/exynos_mc.h

diff --git a/drivers/media/video/exynos/mdev/Kconfig 
b/drivers/media/video/exynos/mdev/Kconfig
new file mode 100644
index 000..15134b0
--- /dev/null
+++ b/drivers/media/video/exynos/mdev/Kconfig
@@ -0,0 +1,8 @@
+config EXYNOS_MEDIA_DEVICE
+   bool
+   depends on MEDIA_EXYNOS
+   select MEDIA_CONTROLLER
+   select VIDEO_V4L2_SUBDEV_API
+   default y
+   help
+ This is a v4l2 driver for exynos media device.
diff --git a/drivers/media/video/exynos/mdev/Makefile 
b/drivers/media/video/exynos/mdev/Makefile
new file mode 100644
index 000..175a4bc
--- /dev/null
+++ b/drivers/media/video/exynos/mdev/Makefile
@@ -0,0 +1,2 @@
+mdev-objs := exynos-mdev.o
+obj-$(CONFIG_EXYNOS_MEDIA_DEVICE)  += mdev.o
diff --git a/drivers/media/video/exynos/mdev/exynos-mdev.c 
b/drivers/media/video/exynos/mdev/exynos-mdev.c
new file mode 100644
index 000..a76e7c3
--- /dev/null
+++ b/drivers/media/video/exynos/mdev/exynos-mdev.c
@@ -0,0 +1,115 @@
+/* drviers/media/video/exynos/mdev/exynos-mdev.c
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * EXYNOS5 SoC series media device driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int __devinit mdev_probe(struct platform_device *pdev)
+{
+   struct v4l2_device *v4l2_dev;
+   struct exynos_md *mdev;
+   int ret;
+
+   mdev = kzalloc(sizeof(struct exynos_md), GFP_KERNEL);
+   if (!mdev)
+   return -ENOMEM;
+
+   mdev->id = pdev->id;
+   mdev->pdev = pdev;
+   spin_lock_init(&mdev->slock);
+
+   snprintf(mdev->media_dev.model, sizeof(mdev->media_dev.model), "%s%d",
+dev_name(&pdev->dev), mdev->id);
+
+   mdev->media_dev.dev = &pdev->dev;
+
+   v4l2_dev = &mdev->v4l2_dev;
+   v4l2_dev->mdev = &mdev->media_dev;
+   snprintf(v4l2_dev->name, sizeof(v4l2_

Re: [PATCH] smsdvb - fix UNDEFINED delivery on driver hotplug

2012-02-14 Thread Eddi De Pieri
Someone can confirm my changes?

Regards,

Eddi

On Thu, Feb 2, 2012 at 10:13 AM, Eddi De Pieri  wrote:
> #dvb-fe-tool -a 1 -d DVBT
>
> Device Siano Mobile Digital MDTV Receiver (/dev/dvb/adapter1/frontend0)
> capabilities:
>
>     CAN_FEC_1_2 CAN_FEC_2_3 CAN_FEC_3_4 CAN_FEC_5_6 CAN_FEC_7_8
> CAN_FEC_AUTO CAN_GUARD_INTERVAL_AUTO CAN_HIERARCHY_AUTO CAN_INVERSION_AUTO
> CAN_QAM_16 CAN_QAM_64 CAN_QAM_AUTO CAN_QPSK CAN_RECOVER
> CAN_TRANSMISSION_MODE_AUTO
>
> DVB API Version 5.5, Current v5 delivery system: UNDEFINED
>
>
> Signed-off-by: Eddi De Pieri 
> ---
>  drivers/media/dvb/siano/smsdvb.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/dvb/siano/smsdvb.c
> b/drivers/media/dvb/siano/smsdvb.c
> index 654685c..7b584cb 100644
> --- a/drivers/media/dvb/siano/smsdvb.c
> +++ b/drivers/media/dvb/siano/smsdvb.c
> @@ -866,9 +866,6 @@ static int smsdvb_hotplug(struct smscore_device_t
> *coredev,
>     }
>
>     /* init and register frontend */
> -   memcpy(&client->frontend.ops, &smsdvb_fe_ops,
> -  sizeof(struct dvb_frontend_ops));
> -
>     switch (smscore_get_device_mode(coredev)) {
>     case DEVICE_MODE_DVBT:
>     case DEVICE_MODE_DVBT_BDA:
> @@ -880,6 +877,9 @@ static int smsdvb_hotplug(struct smscore_device_t
> *coredev,
>     break;
>     }
>
> +   memcpy(&client->frontend.ops, &smsdvb_fe_ops,
> +  sizeof(struct dvb_frontend_ops));
> +
>     rc = dvb_register_frontend(&client->adapter, &client->frontend);
>     if (rc < 0) {
>     sms_err("frontend registration failed %d", rc);
> --
> 1.7.2.5
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] hdpvr: update picture controls to support firmware versions > 0.15

2012-02-14 Thread Jarod Wilson
On Tue, Feb 14, 2012 at 4:32 PM, Devin Heitmueller
 wrote:
> On Tue, Feb 14, 2012 at 3:43 PM, Jarod Wilson  wrote:
>> Looks sane to me, and really needs to get in ASAP. I'd even suggest we
>> get it sent to stable, as these newer firmware HDPVR are pretty wonky
>> with any current kernel.
>>
>> Acked-by: Jarod Wilson 
>> Reviewed-by: Jarod Wilson 
>> CC: sta...@vger.kernel.org
>
> Where did the process break down here?  Taylor did this patch *months*
> ago, and there has been absolutely no comment with why it wouldn't go
> upstream.  If he hadn't been diligent in pinging the ML repeatedly, it
> would have been lost.

It looks like for some reason, the v3 patch got eaten. :\

http://patchwork.linuxtv.org/patch/8183/ is the v2, in state Changes
Requested, but you can see in the comments a mail that says v3 is
attached, which contains the requested change (added s-o-b). A v3
patch object is nowhere to be found though. The patch *was* indeed
attached to the mail though, I've got it here in my linux-media
mailbox.

So at least on this one, I think I'm blaming patchwork, but it would
be good to better understand how that patch got eaten, and to know if
indeed its happened to other patches as well.

-- 
Jarod Wilson
ja...@wilsonet.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: Fintek driver linux

2012-02-14 Thread Jarod Wilson

On 02/14/2012 04:25 PM, W R wrote:

Thanks for your quick reply. It does seem like I have the old version:

cat /proc/bus/input/devices

*I: Bus=0019 Vendor=1934 Product=0004 Version=0008*


Hm, okay, so the changes for newer hardware shouldn't matter at all.


N: Name="Fintek LPC SuperIO Consumer IR Transceiver"
P: Phys=fintek/cir0

...

Is there anything out of the ordinary? Any way to find out which modules
that cause the problem and can maybe be removed?


Nothing out of the ordinary, no. You'd have to capture serial console 
output or a vmcore from the time of the crash to really get a better 
idea of where its falling down. The panic trace ought to give a clue 
where to start looking.


I can't recall, have you tried using this under Windows, and if so, was 
it stable there? A hardware fault is always a possibility, especially 
when there's only a single report of something like this. Then again, 
this is a fairly young driver. But I never saw anything like this in my 
own testing during driver devel, nor did Fintek. :\


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


[PATCH 09/22] mt2063: move global setting into a header file

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c  |  385 +
 drivers/media/common/tuners/mt2063_priv.h |  234 +
 2 files changed, 239 insertions(+), 380 deletions(-)
 create mode 100644 drivers/media/common/tuners/mt2063_priv.h

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index c3b5108..ac8a0dc 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -27,6 +27,7 @@
 #include 
 
 #include "mt2063.h"
+#include "mt2063_priv.h"
 
 static unsigned int debug;
 module_param(debug, int, 0644);
@@ -46,121 +47,6 @@ if (debug >= level) 
\
printk(KERN_DEBUG "mt2063 %s: " fmt, __func__, ##arg);  \
 } while (0)
 
-/*
- * Parameter for function MT2063_SetPowerMask that specifies the power down
- * of various sections of the MT2063.
- */
-enum MT2063_Mask_Bits {
-   MT2063_REG_SD = 0x0040, /* Shutdown regulator */
-   MT2063_SRO_SD = 0x0020, /* Shutdown SRO   */
-   MT2063_AFC_SD = 0x0010, /* Shutdown AFC A/D   */
-   MT2063_PD_SD = 0x0002,  /* Enable power detector shutdown */
-   MT2063_PDADC_SD = 0x0001,   /* Enable power detector A/D shutdown */
-   MT2063_VCO_SD = 0x8000, /* Enable VCO shutdown*/
-   MT2063_LTX_SD = 0x4000, /* Enable LTX shutdown*/
-   MT2063_LT1_SD = 0x2000, /* Enable LT1 shutdown*/
-   MT2063_LNA_SD = 0x1000, /* Enable LNA shutdown*/
-   MT2063_UPC_SD = 0x0800, /* Enable upconverter shutdown*/
-   MT2063_DNC_SD = 0x0400, /* Enable downconverter shutdown  */
-   MT2063_VGA_SD = 0x0200, /* Enable VGA shutdown*/
-   MT2063_AMP_SD = 0x0100, /* Enable AMP shutdown*/
-   MT2063_ALL_SD = 0xFF73, /* All shutdown bits for this tuner   */
-   MT2063_NONE_SD = 0x /* No shutdown bits   */
-};
-
-/*
- *  Two-wire serial bus subaddresses of the tuner registers.
- *  Also known as the tuner's register addresses.
- */
-enum MT2063_Register_Offsets {
-   MT2063_REG_PART_REV = 0,/*  0x00: Part/Rev Code */
-   MT2063_REG_LO1CQ_1, /*  0x01: LO1C Queued Byte 1*/
-   MT2063_REG_LO1CQ_2, /*  0x02: LO1C Queued Byte 2*/
-   MT2063_REG_LO2CQ_1, /*  0x03: LO2C Queued Byte 1*/
-   MT2063_REG_LO2CQ_2, /*  0x04: LO2C Queued Byte 2*/
-   MT2063_REG_LO2CQ_3, /*  0x05: LO2C Queued Byte 3*/
-   MT2063_REG_RSVD_06, /*  0x06: Reserved  */
-   MT2063_REG_LO_STATUS,   /*  0x07: LO Status */
-   MT2063_REG_FIFFC,   /*  0x08: FIFF Center   */
-   MT2063_REG_CLEARTUNE,   /*  0x09: ClearTune Filter  */
-   MT2063_REG_ADC_OUT, /*  0x0A: ADC_OUT   */
-   MT2063_REG_LO1C_1,  /*  0x0B: LO1C Byte 1   */
-   MT2063_REG_LO1C_2,  /*  0x0C: LO1C Byte 2   */
-   MT2063_REG_LO2C_1,  /*  0x0D: LO2C Byte 1   */
-   MT2063_REG_LO2C_2,  /*  0x0E: LO2C Byte 2   */
-   MT2063_REG_LO2C_3,  /*  0x0F: LO2C Byte 3   */
-   MT2063_REG_RSVD_10, /*  0x10: Reserved  */
-   MT2063_REG_PWR_1,   /*  0x11: PWR Byte 1*/
-   MT2063_REG_PWR_2,   /*  0x12: PWR Byte 2*/
-   MT2063_REG_TEMP_STATUS, /*  0x13: Temp Status   */
-   MT2063_REG_XO_STATUS,   /*  0x14: Crystal Status*/
-   MT2063_REG_RF_STATUS,   /*  0x15: RF Attn Status*/
-   MT2063_REG_FIF_STATUS,  /*  0x16: FIF Attn Status   */
-   MT2063_REG_LNA_OV,  /*  0x17: LNA Attn Override */
-   MT2063_REG_RF_OV,   /*  0x18: RF Attn Override  */
-   MT2063_REG_FIF_OV,  /*  0x19: FIF Attn Override */
-   MT2063_REG_LNA_TGT, /*  0x1A: Reserved  */
-   MT2063_REG_PD1_TGT, /*  0x1B: Pwr Det 1 Target  */
-   MT2063_REG_PD2_TGT, /*  0x1C: Pwr Det 2 Target  */
-   MT2063_REG_RSVD_1D, /*  0x1D: Reserved  */
-   MT2063_REG_RSVD_1E, /*  0x1E: Reserved  */
-   MT2063_REG_RSVD_1F, /*  0x1F: Reserved  */
-   MT2063_REG_RSVD_20, /*  0x20: Reserved  */
-   MT2063_REG_BYP_CTRL,/*  0x21: Bypass Control*/
-   MT2063_REG_RSVD_22, /*  0x22: Reserved  */
-   MT2063_RE

[PATCH 05/22] mt2063: remove spurcheck

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |  585 --
 1 files changed, 0 insertions(+), 585 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index a79e4ef..ee59ebe 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -41,15 +41,6 @@ static LIST_HEAD(hybrid_tuner_instance_list);
  * 2 additional calculating, result etc.
  * 3 maximum debug information
 
-/* positive error codes used internally */
-
-/*  Info: Unavoidable LO-related spur may be present in the output  */
-#define MT2063_SPUR_PRESENT_ERR (0x0080)
-
-/*  Info: Mask of bits used for # of LO-related spurs that were avoided during 
tuning  */
-#define MT2063_SPUR_CNT_MASK(0x001f)
-#define MT2063_SPUR_SHIFT   (16)
-
 /*  Info: Upconverter frequency is out of range (may be reason for 
MT_UPC_UNLOCK) */
 #define MT2063_UPC_RANGE(0x0400)
 
@@ -69,61 +60,6 @@ if (debug >= level)  
\
printk(KERN_DEBUG "mt2063 %s: " fmt, __func__, ##arg);  \
 } while (0)
 
-/* DECT Frequency Avoidance */
-#define MT2063_DECT_AVOID_US_FREQS  0x0001
-
-#define MT2063_DECT_AVOID_EURO_FREQS0x0002
-
-#define MT2063_EXCLUDE_US_DECT_FREQUENCIES(s) (((s) & 
MT2063_DECT_AVOID_US_FREQS) != 0)
-
-#define MT2063_EXCLUDE_EURO_DECT_FREQUENCIES(s) (((s) & 
MT2063_DECT_AVOID_EURO_FREQS) != 0)
-
-enum MT2063_DECT_Avoid_Type {
-   MT2063_NO_DECT_AVOIDANCE = 0,   /* Do not 
create DECT exclusion zones. */
-   MT2063_AVOID_US_DECT = MT2063_DECT_AVOID_US_FREQS,  /* Avoid US 
DECT frequencies.  */
-   MT2063_AVOID_EURO_DECT = MT2063_DECT_AVOID_EURO_FREQS,  /* Avoid 
European DECT frequencies.*/
-   MT2063_AVOID_BOTH   /* Avoid both 
regions. Not typically used. */
-};
-
-#define MT2063_MAX_ZONES 48
-
-struct MT2063_ExclZone_t {
-   u32 min_;
-   u32 max_;
-   struct MT2063_ExclZone_t *next_;
-};
-
-/*
- *  Structure of data needed for Spur Avoidance
- */
-struct MT2063_AvoidSpursData_t {
-   u32 f_ref;
-   u32 f_in;
-   u32 f_LO1;
-   u32 f_if1_Center;
-   u32 f_if1_Request;
-   u32 f_if1_bw;
-   u32 f_LO2;
-   u32 f_out;
-   u32 f_out_bw;
-   u32 f_LO1_Step;
-   u32 f_LO2_Step;
-   u32 f_LO1_FracN_Avoid;
-   u32 f_LO2_FracN_Avoid;
-   u32 f_zif_bw;
-   u32 f_min_LO_Separation;
-   u32 maxH1;
-   u32 maxH2;
-   enum MT2063_DECT_Avoid_Type avoidDECT;
-   u32 bSpurPresent;
-   u32 bSpurAvoided;
-   u32 nSpursFound;
-   u32 nZones;
-   struct MT2063_ExclZone_t *freeZones;
-   struct MT2063_ExclZone_t *usedZones;
-   struct MT2063_ExclZone_t MT2063_ExclZones[MT2063_MAX_ZONES];
-};
-
 /*
  * Parameter for function MT2063_SetPowerMask that specifies the power down
  * of various sections of the MT2063.
@@ -375,351 +311,20 @@ static int MT2063_Sleep(struct dvb_frontend *fe)
 
 
 
-/*
- * MT_ChooseFirstIF - Choose the best available 1st IF
- *If f_Desired is not excluded, choose that first.
- *Otherwise, return the value closest to f_Center that is
- *not excluded
- */
-static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info)
-{
-   /*
-* Update "f_Desired" to be the nearest "combinational-multiple" of
-* "f_LO1_Step".
-* The resulting number, F_LO1 must be a multiple of f_LO1_Step.
-* And F_LO1 is the arithmetic sum of f_in + f_Center.
-* Neither f_in, nor f_Center must be a multiple of f_LO1_Step.
-* However, the sum must be.
-*/
-   const u32 f_Desired =
-   pAS_Info->f_LO1_Step *
-   ((pAS_Info->f_if1_Request + pAS_Info->f_in +
- pAS_Info->f_LO1_Step / 2) / pAS_Info->f_LO1_Step) -
-   pAS_Info->f_in;
-   const u32 f_Step =
-   (pAS_Info->f_LO1_Step >
-pAS_Info->f_LO2_Step) ? pAS_Info->f_LO1_Step : pAS_Info->
-   f_LO2_Step;
-   u32 f_Center;
-   s32 i;
-   s32 j = 0;
-   u32 bDesiredExcluded = 0;
-   u32 bZeroExcluded = 0;
-   s32 tmpMin, tmpMax;
-   s32 bestDiff;
-   struct MT2063_ExclZone_t *pNode = pAS_Info->usedZones;
-   struct MT2063_FIFZone_t zones[MT2063_MAX_ZONES];
-
-   dprintk(2, "\n");
-
-   if (pAS_Info->nZones == 0)
-   return f_Desired;
 
-   /*
-*  f_Center needs to be an integer multiple of f_Step away
-*  from f_Desired
-*/
-   if (pAS_Info->f_if1_Center > f_Desired)
-   f_Center =
-   f_Desired +
-   f_Step *
-   ((pAS_Info->f_if1_Center - f_Desired +
- f_Step / 2) / f_Step);
 

[PATCH 16/22] mt2063: add hybrid stuff in release function

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 0e26744..e5d96e9 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -486,10 +486,16 @@ static int mt2063_release(struct dvb_frontend *fe)
 {
struct mt2063_state *state = fe->tuner_priv;
 
-   dprintk(2, "\n");
+   dprintk(1,"\n");
+
+   mutex_lock(&mt2063_list_mutex);
+
+   if (state)
+   hybrid_tuner_release_state(state);
+
+   mutex_unlock(&mt2063_list_mutex);
 
fe->tuner_priv = NULL;
-   kfree(state);
 
return 0;
 }
-- 
1.7.7.6

--
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/22] mt2063: remove old get_if_frequency

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   14 --
 1 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 8d8e638..fb0a38b 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -643,22 +643,8 @@ static int mt2063_set_params(struct dvb_frontend *fe)
return 0;
 }
 
-static int mt2063_get_if_frequency(struct dvb_frontend *fe, u32 *freq)
-{
-   struct mt2063_state *state = fe->tuner_priv;
-
-   dprintk(2, "\n");
-
-   if (!state->init)
return -ENODEV;
 
-   *freq = state->AS_Data.f_out;
-
-   dprintk(1, "IF frequency: %d\n", *freq);
-
-   return 0;
-}
-
return -ENODEV;
 
 
-- 
1.7.7.6

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


[PATCH 22/22] mt2063: add mt2063_find_chip

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   43 ++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 7dd1d7c..a717479 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -557,18 +557,60 @@ static struct dvb_tuner_ops mt2063_ops = {
/* TODO */
 };
 
+static int mt2063_find_chip(struct mt2063_state *state)
 {
+   int err;
+   u8 chip = 0, chip_hi = 0;
+   char *step;
+   struct dvb_frontend *fe = state->frontend;
 
+   dprintk(1, "\n");
 
+   /* open gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 1);
 
+   /* Read the Part/Rev code from the tuner */
+   err = mt2063_read(state, MT2063_REG_PART_REV, &chip);
+   if (err < 0) {
+   printk(KERN_ERR "Can't read mt2063 part ID\n");
+   return -ENODEV;
+   }
+
+   /* Check the part/rev code */
+   switch (chip) {
+   case MT2063_B0:
+   step = "B0";
break;
+   case MT2063_B1:
+   step = "B1";
+   break;
+   case MT2063_B2:
+   step = "B2";
+   break;
+   case MT2063_B3:
+   step = "B3";
break;
default:
+   printk(KERN_ERR "mt2063: Unknown mt2063 device ID (0x%02x)\n",
+   chip);
return -ENODEV;
+   }
 
+   /* Check the 2nd byte of the Part/Rev code from the tuner */
+   mt2063_read(state, MT2063_REG_RSVD_3B, &chip_hi);
+   if ((chip_hi & 0x80) != 0x00) {
+   printk(KERN_ERR "mt2063: Unknown part ID (0x%02x%02x)\n",
+   chip, chip_hi);
return -ENODEV;
+   }
 
+   printk(KERN_INFO "mt2063: detected a mt2063 rev %s", step);
+   state->tuner_id = chip;
 
+   /* close gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 0);
 
return 0;
 }
@@ -599,6 +641,7 @@ struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
/* find chip */
mutex_init(&state->lock);
state->frontend = fe;
+   ret = mt2063_find_chip(state);
if (ret < 0)
goto fail;
fe->tuner_priv = state;
-- 
1.7.7.6

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


[PATCH 14/22] mt2063: remove get_status

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   12 
 1 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 452c517..3af5242 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -460,24 +460,12 @@ static int mt2063_init(struct dvb_frontend *fe)
return 0;
 }
 
-static int mt2063_get_status(struct dvb_frontend *fe, u32 *tuner_status)
 {
struct mt2063_state *state = fe->tuner_priv;
-   int status;
 
-   dprintk(2, "\n");
 
-   if (!state->init)
-   return -ENODEV;
 
-   *tuner_status = 0;
-   status = mt2063_lockStatus(state);
-   if (status < 0)
-   return status;
-   if (status)
-   *tuner_status = TUNER_STATUS_LOCKED;
 
-   dprintk(1, "Tuner status: %d", *tuner_status);
 
return 0;
 }
-- 
1.7.7.6

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


[PATCH 18/22] mt2063: add get_if_frequency

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 2a2cce3..8d8e638 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -541,11 +541,15 @@ static int mt2063_release(struct dvb_frontend *fe)
return 0;
 }
 
+static int mt2063_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
 {
struct mt2063_state *state = fe->tuner_priv;
 
+   dprintk(1, "\n");
 
+   *frequency = state->if2 * 1000;
 
+   dprintk(2, "if frequency is %d kHz\n", state->if2);
 
return 0;
 }
-- 
1.7.7.6

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


[PATCH 11/22] mt2063: remove get_bandwidth

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |9 -
 1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index dfa2e28..24c2c93 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -773,18 +773,9 @@ static int mt2063_get_if_frequency(struct dvb_frontend 
*fe, u32 *freq)
return 0;
 }
 
-static int mt2063_get_bandwidth(struct dvb_frontend *fe, u32 *bw)
-{
-   struct mt2063_state *state = fe->tuner_priv;
-
-   dprintk(2, "\n");
-
-   if (!state->init)
return -ENODEV;
 
-   *bw = state->AS_Data.f_out_bw - 75;
 
-   dprintk(1, "bandwidth: %d\n", *bw);
 
return 0;
 }
-- 
1.7.7.6

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


[PATCH 20/22] mt2063: change set_params function

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |  111 ++
 1 files changed, 46 insertions(+), 65 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index fb0a38b..0c5d472 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -320,20 +320,66 @@ err:
return ret;
 }
 
+static int mt2063_set_params(struct dvb_frontend *fe)
 {
+   struct mt2063_state *state = fe->tuner_priv;
+   struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+   u32 freq, bw;
+   int ret = 0;
 
+   dprintk(1, "\n");
 
+   mutex_lock(&state->lock);
 
+   /* open gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 1);
 
+   /* all calculation is in kHz */
+   freq = c->frequency / 1000;
 
+   switch (c->delivery_system) {
+   case SYS_DVBT:
+   if (c->bandwidth_hz == 0) {
+   ret = -EINVAL;
+   goto err;
}
+   bw = c->bandwidth_hz / 1000;
+   state->mode = MT2063_OFFAIR_COFDM;
+   state->if2 = 36000;
+   break;
+   case SYS_DVBC_ANNEX_A:
+   case SYS_DVBC_ANNEX_C:
+   bw = c->bandwidth_hz / 1000;
+   state->mode = MT2063_CABLE_QAM;
+   state->if2 = 36000;
+   break;
+   case SYS_ATSC:
+   /* TODO */
+   default:
+   ret = -EINVAL;
+   goto err;
}
 
+   state->frequency = freq;
+   /* for spurcheck */
+   state->bw = bw;
 
+   dprintk(2, "Set input frequency to %d kHz.\n", freq);
 
+   ret = mt2063_set_mode(state, state->mode);
+   if (ret < 0)
+   goto err;
 
+   ret = mt2063_tune(state);
 
+err:
+   /* close gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 0);
 
+   mutex_unlock(&state->lock);
+   return ret;
 }
 
 static int mt2063_init(struct dvb_frontend *fe)
@@ -570,79 +616,14 @@ static struct dvb_tuner_ops mt2063_ops = {
.get_if_frequency = mt2063_get_if_frequency,
/* TODO */
 };
-/*
- * As defined on EN 300 429, the DVB-C roll-off factor is 0.15.
- * So, the amount of the needed bandwith is given by:
- * Bw = Symbol_rate * (1 + 0.15)
- * As such, the maximum symbol rate supported by 6 MHz is given by:
- * max_symbol_rate = 6 MHz / 1.15 = 5217391 Bauds
- */
-#define MAX_SYMBOL_RATE_6MHz   5217391
 
-static int mt2063_set_params(struct dvb_frontend *fe)
 {
-   struct dtv_frontend_properties *c = &fe->dtv_property_cache;
-   struct mt2063_state *state = fe->tuner_priv;
-   int status;
-   s32 pict_car;
-   s32 pict2chanb_vsb;
-   s32 ch_bw;
-   s32 if_mid;
-   s32 rcvr_mode;
-
-   if (!state->init) {
-   status = mt2063_init(fe);
-   if (status < 0)
-   return status;
-   }
 
-   dprintk(2, "\n");
 
-   if (c->bandwidth_hz == 0)
-   return -EINVAL;
-   if (c->bandwidth_hz <= 600)
-   ch_bw = 600;
-   else if (c->bandwidth_hz <= 700)
-   ch_bw = 700;
-   else
-   ch_bw = 800;
 
-   switch (c->delivery_system) {
-   case SYS_DVBT:
-   rcvr_mode = MT2063_OFFAIR_COFDM;
-   pict_car = 36125000;
-   pict2chanb_vsb = -(ch_bw / 2);
break;
-   case SYS_DVBC_ANNEX_A:
-   case SYS_DVBC_ANNEX_C:
-   rcvr_mode = MT2063_CABLE_QAM;
-   pict_car = 36125000;
-   pict2chanb_vsb = -(ch_bw / 2);
break;
default:
-   return -EINVAL;
-   }
-   if_mid = pict_car - (pict2chanb_vsb + (ch_bw / 2));
-
-   state->AS_Data.f_LO2_Step = 125000; /* FIXME: probably 5000 for FM 
*/
-   state->AS_Data.f_out = if_mid;
-   state->AS_Data.f_out_bw = ch_bw + 75;
-   status = MT2063_SetReceiverMode(state, rcvr_mode);
-   if (status < 0)
-   return status;
-
-   dprintk(1, "Tuning to frequency: %d, bandwidth %d, foffset %d\n",
-   c->frequency, ch_bw, pict2chanb_vsb);
-
-   status = MT2063_Tune(state, (c->frequency + (pict2chanb_vsb + (ch_bw / 
2;
-
-   if (status < 0)
-   return status;
-
-   state->frequency = c->frequency;
-   return 0;
-}
-
return -ENODEV;
 
return -ENODEV;
-- 
1.7.7.6

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


[PATCH 17/22] mt2063: chane set_analog_params

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   97 ++---
 1 files changed, 41 insertions(+), 56 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index e5d96e9..2a2cce3 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -261,22 +261,63 @@ static int mt2063_tune(struct mt2063_state *state)
return 0;
 }
 
+static int mt2063_set_analog_params(struct dvb_frontend *fe,
+   struct analog_parameters *params)
 {
+   struct mt2063_state *state = fe->tuner_priv;
+   u32 freq, bw;
+   int ret = 0;
 
+   dprintk(1, "\n");
 
+   mutex_lock(&state->lock);
 
+   /* open gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 1);
 
+   /* all calculation is in kHz */
+   freq = params->frequency / 1000;
 
+   switch(params->mode) {
+   case V4L2_TUNER_RADIO:
+   state->mode = MT2063_OFFAIR_ANALOG;
+   state->if2 = 38900;
+   bw = 8000; /* TODO */
break;
+   case V4L2_TUNER_ANALOG_TV:
+   state->mode = MT2063_CABLE_ANALOG;
+   state->if2 = 38900;
+   if (params->std & ~V4L2_STD_MN)
+   bw = 6000;
+   else if (params->std & V4L2_STD_PAL_G)
+   bw = 7000;
+   else
+   bw = 8000;
break;
default:
+   ret = -EINVAL;
+   goto err;
}
 
+   state->frequency = freq;
+   state->bw = bw;
 
+   dprintk(2, "Set input frequency to %d kHz.\n", freq);
 
+   ret = mt2063_set_mode(state, state->mode);
+   if (ret < 0)
+   goto err;
 
+   ret = mt2063_tune(state);
 
+err:
+   /* close gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 0);
 
+   mutex_unlock(&state->lock);
+   return ret;
 }
 
 {
@@ -500,68 +541,12 @@ static int mt2063_release(struct dvb_frontend *fe)
return 0;
 }
 
-static int mt2063_set_analog_params(struct dvb_frontend *fe,
-   struct analog_parameters *params)
 {
struct mt2063_state *state = fe->tuner_priv;
-   s32 pict_car;
-   s32 pict2chanb_vsb;
-   s32 ch_bw;
-   s32 if_mid;
-   s32 rcvr_mode;
-   int status;
-
-   dprintk(2, "\n");
-
-   if (!state->init) {
-   status = mt2063_init(fe);
-   if (status < 0)
-   return status;
-   }
-
-   switch (params->mode) {
-   case V4L2_TUNER_RADIO:
-   pict_car = 3890;
-   ch_bw = 800;
-   pict2chanb_vsb = -(ch_bw / 2);
-   rcvr_mode = MT2063_OFFAIR_ANALOG;
-   break;
-   case V4L2_TUNER_ANALOG_TV:
-   rcvr_mode = MT2063_CABLE_ANALOG;
-   if (params->std & ~V4L2_STD_MN) {
-   pict_car = 3890;
-   ch_bw = 600;
-   pict2chanb_vsb = -125;
-   } else if (params->std & V4L2_STD_PAL_G) {
-   pict_car = 3890;
-   ch_bw = 700;
-   pict2chanb_vsb = -125;
-   } else {/* PAL/SECAM standards */
-   pict_car = 3890;
-   ch_bw = 800;
-   pict2chanb_vsb = -125;
-   }
-   break;
-   default:
-   return -EINVAL;
-   }
-   if_mid = pict_car - (pict2chanb_vsb + (ch_bw / 2));
 
-   state->AS_Data.f_LO2_Step = 125000; /* FIXME: probably 5000 for FM 
*/
-   state->AS_Data.f_out = if_mid;
-   state->AS_Data.f_out_bw = ch_bw + 75;
-   status = MT2063_SetReceiverMode(state, rcvr_mode);
-   if (status < 0)
-   return status;
 
-   dprintk(1, "Tuning to frequency: %d, bandwidth %d, foffset %d\n",
-   params->frequency, ch_bw, pict2chanb_vsb);
 
-   status = MT2063_Tune(state, (params->frequency + (pict2chanb_vsb + 
(ch_bw / 2;
-   if (status < 0)
-   return status;
 
-   state->frequency = params->frequency;
return 0;
 }
 
-- 
1.7.7.6

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


[PATCH 12/22] mt2063: remove LockStatus

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   36 --
 1 files changed, 0 insertions(+), 36 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 24c2c93..8cc58a1 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -179,46 +179,10 @@ static int mt2063_set_mode(struct mt2063_state *state, 
enum mt2063_delsys Mode)
 *
 *
 */
-/**
- * mt2063_lockStatus - Checks to see if LO1 and LO2 are locked
- *
- * @state: struct mt2063_state pointer
- *
- * This function returns 0, if no lock, 1 if locked and a value < 1 if error
- */
-static unsigned int mt2063_lockStatus(struct mt2063_state *state)
-{
-   const u32 nMaxWait = 100;   /*  wait a maximum of 100 msec   */
-   const u32 nPollRate = 2;/*  poll status bits every 2 ms */
-   const u32 nMaxLoops = nMaxWait / nPollRate;
-   const u8 LO1LK = 0x80;
-   u8 LO2LK = 0x08;
-   u32 status;
-   u32 nDelays = 0;
-
-   dprintk(2, "\n");
-
-   /*  LO2 Lock bit was in a different place for B0 version  */
-   if (state->tuner_id == MT2063_B0)
-   LO2LK = 0x40;
 
do {
-   status = mt2063_read(state, MT2063_REG_LO_STATUS,
-&state->reg[MT2063_REG_LO_STATUS], 1);
-
-   if (status < 0)
-   return status;
-
-   if ((state->reg[MT2063_REG_LO_STATUS] & (LO1LK | LO2LK)) ==
-   (LO1LK | LO2LK)) {
-   return TUNER_STATUS_LOCKED | TUNER_STATUS_STEREO;
}
-   msleep(nPollRate);  /*  Wait between retries  */
-   } while (++nDelays < nMaxLoops);
 
-   /*
-* Got no lock or partial lock
-*/
return 0;
 }
 
-- 
1.7.7.6

--
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/22] mt2063: change mt2063_init

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |  186 --
 1 files changed, 63 insertions(+), 123 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 0c5d472..7dd1d7c 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -384,165 +384,105 @@ err:
 
 static int mt2063_init(struct dvb_frontend *fe)
 {
-   u32 status;
struct mt2063_state *state = fe->tuner_priv;
-   u8 all_resets = 0xF0;   /* reset/load bits */
const u8 *def = NULL;
-   char *step;
-   u32 FCRUN;
-   s32 maxReads;
-   u32 fcu_osc;
-   u32 i;
-
-   dprintk(2, "\n");
-
-   state->rcvr_mode = MT2063_CABLE_QAM;
-
-   /*  Read the Part/Rev code from the tuner */
-   status = mt2063_read(state, MT2063_REG_PART_REV,
-&state->reg[MT2063_REG_PART_REV], 1);
-   if (status < 0) {
-   printk(KERN_ERR "Can't read mt2063 part ID\n");
-   return status;
-   }
+   u8 xo_lock = 1, i;
 
-   /* Check the part/rev code */
-   switch (state->reg[MT2063_REG_PART_REV]) {
-   case MT2063_B0:
-   step = "B0";
-   break;
-   case MT2063_B1:
-   step = "B1";
-   break;
-   case MT2063_B2:
-   step = "B2";
-   break;
-   case MT2063_B3:
-   step = "B3";
-   break;
-   default:
-   printk(KERN_ERR "mt2063: Unknown mt2063 device ID (0x%02x)\n",
-  state->reg[MT2063_REG_PART_REV]);
-   return -ENODEV; /*  Wrong tuner Part/Rev code */
-   }
+   dprintk(1, "\n");
 
-   /*  Check the 2nd byte of the Part/Rev code from the tuner */
-   status = mt2063_read(state, MT2063_REG_RSVD_3B,
-&state->reg[MT2063_REG_RSVD_3B], 1);
+   mutex_lock(&state->lock);
 
-   /* b7 != 0 ==> NOT MT2063 */
-   if (status < 0 || ((state->reg[MT2063_REG_RSVD_3B] & 0x80) != 0x00)) {
-   printk(KERN_ERR "mt2063: Unknown part ID (0x%02x%02x)\n",
-  state->reg[MT2063_REG_PART_REV],
-  state->reg[MT2063_REG_RSVD_3B]);
-   return -ENODEV; /*  Wrong tuner Part/Rev code */
-   }
+   /* open gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 1);
+
+   /* power on */
+   mt2063_shutdown(state, MT2063_NONE_SD);
 
-   printk(KERN_INFO "mt2063: detected a mt2063 %s\n", step);
+   /* reset */
+   mt2063_write(state, MT2063_REG_LO2CQ_3, 0xf0);
 
-   /*  Reset the tuner  */
-   status = mt2063_write(state, MT2063_REG_LO2CQ_3, &all_resets, 1);
-   if (status < 0)
-   return status;
+   /* debug dump */
+   if (debug >= 3) {
+   /* print all register after reset */
+   u8 reg[64];
+   /* fill all reg */
+   for (i = 0; i < 64; i++) {
+   mt2063_read(state, i, ®[i]);
+   }
+   print_hex_dump(KERN_DEBUG, "mt2063: ",
+   DUMP_PREFIX_OFFSET, 16, 1, reg, 64, false);
+   }
 
-   /* change all of the default values that vary from the HW reset values 
*/
-   /*  def = (state->reg[PART_REV] == MT2063_B0) ? MT2063B0_defaults : 
MT2063B1_defaults; */
-   switch (state->reg[MT2063_REG_PART_REV]) {
+   /* load defaults */
+   switch (state->tuner_id) {
case MT2063_B3:
def = MT2063B3_defaults;
break;
-
case MT2063_B1:
def = MT2063B1_defaults;
break;
-
case MT2063_B0:
def = MT2063B0_defaults;
break;
-
default:
-   return -ENODEV;
+   def = MT2063B1_defaults;
break;
}
 
-   while (status >= 0 && *def) {
+   while (*def) {
u8 reg = *def++;
u8 val = *def++;
-   status = mt2063_write(state, reg, &val, 1);
+   mt2063_write(state, reg, val);
}
-   if (status < 0)
-   return status;
 
-   /*  Wait for FIFF location to complete.  */
-   FCRUN = 1;
-   maxReads = 10;
-   while (status >= 0 && (FCRUN != 0) && (maxReads-- > 0)) {
+   /* wait to lock */
+   while (!xo_lock) {
msleep(2);
-   status = mt2063_read(state,
-MT2063_REG_XO_STATUS,
-&state->
-reg[MT2063_REG_XO_STATUS], 1);
-   FCRUN = (state->reg[MT2063_REG_XO_STATUS] & 0x40) >> 6;
+   mt2063_read(state, MT2063_REG_XO_STATUS, &xo_lock);
+   xo_lock = (xo_lock & 0x40) >> 6;
}
 
-   if (FCRUN != 0 || status < 

[PATCH 13/22] mt2063: new tune function

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |  225 --
 1 files changed, 76 insertions(+), 149 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 8cc58a1..452c517 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -172,16 +172,91 @@ static int mt2063_set_mode(struct mt2063_state *state, 
enum mt2063_delsys Mode)
return 0;
 }
 
+#define MT2063_IF1 151
+#define MT2063_OSC 16000
 
+static int mt2063_tune(struct mt2063_state *state)
+{
+   u32 f_lo1, f_lo2;
+   u32 div1, num1, div2;
+   u32 num2;
+   bool lock = false;
 
+   dprintk(1, "\n");
 
/*
+* it use ClearTune in auto mode, so it doesn't set ClearTune RF Band.
+*
+* first IF Filter Center frequency (f_if1) is static setted to 1510 MHz
+* the reference osc is always 16 MHz
+*
+* f_if1 = (f_ref / 8) * (FIFFC + 640)
+*
+* f_if2_of = (f_if1 (f_ref / 64)) - ( 8 * FIFFC) - 4992
 *
+* f_lo1 = f_in + f_if1
+*
+* f_lo2 = f_lo1 - f_in - f_if2
 *
 */
-
+   f_lo1 = state->frequency + MT2063_IF1;
+   /* rounding it to a multiple of 250 kHz */
+   f_lo1 = (f_lo1 / 250) * 250;
+
+   f_lo2 = f_lo1 - state->frequency - state->if2;
+   /* rounding it to a multiple of 50 kHz */
+   f_lo2 = ((f_lo2 + 25) / 50) * 50;
+
+   /* TODO: spuck check */
+
+   /* f_lo1 = 16MHz * (div1 + num1/64) */
+   num1 = f_lo1 / (MT2063_OSC / 64);
+   div1 = num1 / 64;
+   num1 &= 0x3f;
+
+   /* f_lo2 = 16MHz * (div2 + num2/8192) */
+   num2 = f_lo2 * 64 / (MT2063_OSC / 128);
+   div2 = num2 / 8192;
+   num2 &= 0x1fff;
+
+   state->frequency = f_lo1 - f_lo2 - state->if2;
+
+   dprintk(2, "Input frequency: %d kHz\n", state->frequency);
+   dprintk(2, "first IF Filter central frequency: %d kHz\n", 151);
+   dprintk(2, "IF Output frequency: %d kHz\n", state->if2);
+   dprintk(2, "LO1 frequency: %d kHz\n", f_lo1);
+   dprintk(2, "LO1 div: %d, 0x%02x\n", div1, div1);
+   dprintk(2, "LO1 num: %d/64, 0x%02x\n", num1, num1);
+   dprintk(2, "LO2 frequency: %d kHz\n", f_lo2);
+   dprintk(2, "LO2 div: %d, 0x%02x\n", div2, div2);
+   dprintk(2, "LO2 num: %d/8192, 0x%04x\n", num2, num2);
+
+   /* set first IF filter center frequency */
+   mt2063_write(state, MT2063_REG_FIFFC, 115);
+
+   /* set LO1 */
+   mt2063_write(state, MT2063_REG_LO1CQ_1, (div1 & 0xff));
+   mt2063_write(state, MT2063_REG_LO1CQ_2, (num1 & 0x3f));
+   /* set LO2, the lastest value with reset */
+   mt2063_write(state, MT2063_REG_LO2CQ_1, (((div2 & 0x7f) << 1) |
+   ((num2 & 0x1000) >> 12)));
+   mt2063_write(state, MT2063_REG_LO2CQ_2, ((num2 & 0x0ff0) >> 4));
+   mt2063_write(state, MT2063_REG_LO2CQ_3, ( 0xe0 | (num2 & 0x000f)));
+
+   /* wait util it's lock */
do {
+   u8 status;
+   /* read LO status bit */
+   mt2063_read(state, MT2063_REG_LO_STATUS, &status);
+
+   if (state->tuner_id == MT2063_B0) {
+   if ((status & 0xc0) == 0xc0)
+   lock = true;
+   } else {
+   if ((status & 0x88) == 0x88)
+   lock = true;
}
+   } while (!lock);
 
return 0;
 }
@@ -207,165 +282,17 @@ static int mt2063_set_mode(struct mt2063_state *state, 
enum mt2063_delsys Mode)
 {
 
 
-/*
- * MT2063_Tune() - Change the tuner's tuned frequency to RFin.
- */
-static u32 MT2063_Tune(struct mt2063_state *state, u32 f_in)
-{  /* RF input center frequency   */
-
-   u32 status = 0;
-   u32 LO1;/*  1st LO register value   */
-   u32 Num1;   /*  Numerator for LO1 reg. value*/
-   u32 f_IF1;  /*  1st IF requested*/
-   u32 LO2;/*  2nd LO register value   */
-   u32 Num2;   /*  Numerator for LO2 reg. value*/
-   u32 ofLO1, ofLO2;   /*  last time's LO frequencies  */
-   u8 fiffc = 0x80;/*  FIFF center freq from tuner */
-   u32 fiffof; /*  Offset from FIFF center freq*/
-   const u8 LO1LK = 0x80;  /*  Mask for LO1 Lock bit   */
-   u8 LO2LK = 0x08;/*  Mask for LO2 Lock bit   */
-   u8 val;
-   u32 RFBand;
 
-   dprintk(2, "\n");
-   /*  Check the input and output frequency ranges   */
-   if ((f_in < MT2063_MIN_FIN_FREQ) || (f_in > MT2063_MAX_FIN_FREQ))
-   return -EINVAL;
-
-   if ((state->AS_Data.f_out < MT2063_MIN_FOUT_FREQ)
-   || (state->AS_Data.f_out > MT2

[PATCH 15/22] mt_2063: add mt2063_sleep

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 3af5242..0e26744 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -460,13 +460,25 @@ static int mt2063_init(struct dvb_frontend *fe)
return 0;
 }
 
+static int mt2063_sleep(struct dvb_frontend *fe)
 {
struct mt2063_state *state = fe->tuner_priv;
 
+   dprintk(1, "\n");
+   mutex_lock(&state->lock);
 
+   /* open gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 1);
 
+   /* set all power bits off */
+   mt2063_shutdown(state, MT2063_ALL_SD);
 
+   /* close gate */
+   if (fe->ops.i2c_gate_ctrl)
+   fe->ops.i2c_gate_ctrl(fe, 0);
 
+   mutex_unlock(&state->lock);
return 0;
 }
 
-- 
1.7.7.6

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


[PATCH 10/22] mt2063: new set_mode

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |  161 +-
 1 files changed, 23 insertions(+), 138 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index ac8a0dc..dfa2e28 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -136,16 +136,39 @@ static void mt2063_shutdown(struct mt2063_state *state,
}
 }
 
+static int mt2063_set_mode(struct mt2063_state *state, enum mt2063_delsys Mode)
 {
+   dprintk(1, "\n");
 
+   /* check, if mode outside */
+   if (Mode > 5)
+   return -EINVAL;
 
+   /* set LNA R in (75 Ohm ??) */
+   mt2063_set_reg_mask(state, MT2063_REG_CTRL_2C, LNARIN[Mode], 0x03);
 
+   /* set LNA Target */
+   mt2063_set_reg_mask(state, MT2063_REG_LNA_TGT, LNATGT[Mode], 0x3f);
 
+   /* PD1 Target */
+   mt2063_set_reg_mask(state, MT2063_REG_PD1_TGT, PD1TGT[Mode], 0x3f);
 
+   /* PD2 Target */
+   mt2063_set_reg_mask(state, MT2063_REG_PD2_TGT, PD2TGT[Mode], 0x3f);
 
+   /* Ignore ATN Overload */
+   if (RFOVDIS[Mode])
+   mt2063_set_reg_mask(state, MT2063_REG_LNA_TGT, 0x80, 0x80);
else
+   mt2063_set_reg_mask(state, MT2063_REG_LNA_TGT, 0x00, 0x80);
 
+   /* Ignore FIF Overload */
+   if (FIFOVDIS[Mode])
+   mt2063_set_reg_mask(state, MT2063_REG_PD1_TGT, 0x80, 0x80);
+   else
+   mt2063_set_reg_mask(state, MT2063_REG_PD1_TGT, 0x00, 0x80);
 
+   dprintk(1, "mode changed to %s\n", mt2063_mode_name[Mode]);
return 0;
 }
 
@@ -208,147 +231,9 @@ static unsigned int mt2063_lockStatus(struct mt2063_state 
*state)
break;
break;
default:
-/*
- * MT2063_SetReceiverMode() - Set the MT2063 receiver mode, according with
- *   the selected enum mt2063_delivery_sys type.
- *
- *  (DNC1GC & DNC2GC are the values, which are used, when the specific
- *   DNC Output is selected, the other is always off)
- *
- * @state: ptr to mt2063_state structure
- * @Mode:  desired reciever delivery system
- *
- * Note: Register cache must be valid for it to work
- */
-
-static u32 MT2063_SetReceiverMode(struct mt2063_state *state,
- enum mt2063_delivery_sys Mode)
-{
-   u32 status = 0; /* Status to be returned*/
-   u8 val;
-   u32 longval;
-
-   dprintk(2, "\n");
-
-   if (Mode >= MT2063_NUM_RCVR_MODES)
-   status = -ERANGE;
-
-   /* RFAGCen */
-   if (status >= 0) {
-   val =
-   (state->
-reg[MT2063_REG_PD1_TGT] & (u8) ~0x40) | (RFAGCEN[Mode]
-  ? 0x40 :
-  0x00);
-   if (state->reg[MT2063_REG_PD1_TGT] != val)
-   status |= mt2063_setreg(state, MT2063_REG_PD1_TGT, val);
-   }
-
-   /* LNARin */
-   if (status >= 0) {
-   u8 val = (state->reg[MT2063_REG_CTRL_2C] & (u8) ~0x03) |
-(LNARIN[Mode] & 0x03);
-   if (state->reg[MT2063_REG_CTRL_2C] != val)
-   status |= mt2063_setreg(state, MT2063_REG_CTRL_2C, val);
-   }
-
-   /* FIFFQEN and FIFFQ */
-   if (status >= 0) {
-   val =
-   (state->
-reg[MT2063_REG_FIFF_CTRL2] & (u8) ~0xF0) |
-   (FIFFQEN[Mode] << 7) | (FIFFQ[Mode] << 4);
-   if (state->reg[MT2063_REG_FIFF_CTRL2] != val) {
-   status |=
-   mt2063_setreg(state, MT2063_REG_FIFF_CTRL2, val);
-   /* trigger FIFF calibration, needed after changing 
FIFFQ */
-   val =
-   (state->reg[MT2063_REG_FIFF_CTRL] | (u8) 0x01);
-   status |=
-   mt2063_setreg(state, MT2063_REG_FIFF_CTRL, val);
-   val =
-   (state->
-reg[MT2063_REG_FIFF_CTRL] & (u8) ~0x01);
-   status |=
-   mt2063_setreg(state, MT2063_REG_FIFF_CTRL, val);
-   }
-   }
-
-   /* acLNAmax */
-   if (status >= 0) {
-   u8 val = (state->reg[MT2063_REG_LNA_OV] & (u8) ~0x1F) |
-(ACLNAMAX[Mode] & 0x1F);
-   if (state->reg[MT2063_REG_LNA_OV] != val)
-   status |= mt2063_setreg(state, MT2063_REG_LNA_OV, val);
-   }
-
-   /* LNATGT */
-   if (status >= 0) {
-   u8 val = (state->reg[MT2063_REG_LNA_TGT] & (u8) ~0x3F) |
-(LNATGT[Mode] & 0x3F);
-   if (state->reg[MT2063_REG_LNA_TGT] != val)
-   status |= mt2063_setreg(

[PATCH 06/22] mt2063: remove remove up + down converter

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |  161 --
 1 files changed, 0 insertions(+), 161 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index ee59ebe..31cb636 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -40,20 +40,6 @@ static LIST_HEAD(hybrid_tuner_instance_list);
  * 1 called functions without i2c comunications
  * 2 additional calculating, result etc.
  * 3 maximum debug information
-
-/*  Info: Upconverter frequency is out of range (may be reason for 
MT_UPC_UNLOCK) */
-#define MT2063_UPC_RANGE(0x0400)
-
-/*  Info: Downconverter frequency is out of range (may be reason for 
MT_DPC_UNLOCK) */
-#define MT2063_DNC_RANGE(0x0800)
-
-/*
- *  Constant defining the version of the following structure
- *  and therefore the API for this code.
- *
- *  When compiling the tuner driver, the preprocessor will
- *  check against this version number to make sure that
- *  it matches the version that the tuner driver knows about.
  */
 #define dprintk(level, fmt, arg...) do {   \
 if (debug >= level)\
@@ -83,16 +69,6 @@ enum MT2063_Mask_Bits {
 };
 
 /*
- *  Possible values for MT2063_DNC_OUTPUT
- */
-enum MT2063_DNC_Output_Enable {
-   MT2063_DNC_NONE = 0,
-   MT2063_DNC_1,
-   MT2063_DNC_2,
-   MT2063_DNC_BOTH
-};
-
-/*
  *  Two-wire serial bus subaddresses of the tuner registers.
  *  Also known as the tuner's register addresses.
  */
@@ -469,152 +445,15 @@ static const u8 FIFOVDIS[]   = {  0,  0,  0,  0,  0, 
 0 };
 static const u8 ACFIFMAX[] = { 29, 29, 29, 29, 29, 29 };
 static const u8 PD2TGT[]   = { 40, 33, 38, 42, 30, 38 };
 
-/*
- * mt2063_set_dnc_output_enable()
- */
-static u32 mt2063_get_dnc_output_enable(struct mt2063_state *state,
-   enum MT2063_DNC_Output_Enable *pValue)
-{
-   dprintk(2, "\n");
-
-   if ((state->reg[MT2063_REG_DNC_GAIN] & 0x03) == 0x03) { /* if DNC1 is 
off */
-   if ((state->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03)   /* if 
DNC2 is off */
-   *pValue = MT2063_DNC_NONE;
-   else
-   *pValue = MT2063_DNC_2;
-   } else {/* DNC1 is on */
-   if ((state->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03)   /* if 
DNC2 is off */
-   *pValue = MT2063_DNC_1;
-   else
-   *pValue = MT2063_DNC_BOTH;
-   }
-   return 0;
-}
-
-/*
- * mt2063_set_dnc_output_enable()
- */
-static u32 mt2063_set_dnc_output_enable(struct mt2063_state *state,
-   enum MT2063_DNC_Output_Enable nValue)
 {
-   u32 status = 0; /* Status to be returned*/
-   u8 val = 0;
 
-   dprintk(2, "\n");
 
-   /* selects, which DNC output is used */
-   switch (nValue) {
-   case MT2063_DNC_NONE:
-   val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03;  /* Set 
DNC1GC=3 */
-   if (state->reg[MT2063_REG_DNC_GAIN] !=
-   val)
-   status |=
-   mt2063_setreg(state,
- MT2063_REG_DNC_GAIN,
- val);
 
-   val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03;  /* Set 
DNC2GC=3 */
-   if (state->reg[MT2063_REG_VGA_GAIN] !=
-   val)
-   status |=
-   mt2063_setreg(state,
- MT2063_REG_VGA_GAIN,
- val);
 
-   val = (state->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 
*/
-   if (state->reg[MT2063_REG_RSVD_20] !=
-   val)
-   status |=
-   mt2063_setreg(state,
- MT2063_REG_RSVD_20,
- val);
 
break;
-   case MT2063_DNC_1:
-   val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 
(DNC1GC[state->rcvr_mode] & 0x03); /* Set DNC1GC=x */
-   if (state->reg[MT2063_REG_DNC_GAIN] !=
-   val)
-   status |=
-   mt2063_setreg(state,
- MT2063_REG_DNC_GAIN,
- val);
-
-   val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03;  /* Set 
DNC2GC=3 */
-   if (state->reg[MT2063_REG_VGA_GAIN] !=
-   val)
-   status |=
-   mt2063_setreg(state,
- MT2063_REG_VGA_GAIN,
-

[PATCH 03/22] mt2063: add hybrid

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   57 +++---
 1 files changed, 39 insertions(+), 18 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 9f3a546..d5a9dd9 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -32,6 +32,8 @@ static unsigned int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Set debug level");
 
+static DEFINE_MUTEX(mt2063_list_mutex);
+static LIST_HEAD(hybrid_tuner_instance_list);
 
 /* debug level
  * 0 don't debug
@@ -2247,29 +2249,48 @@ static struct dvb_tuner_ops mt2063_ops = {
 };
 
 struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
-  struct mt2063_config *config,
-  struct i2c_adapter *i2c)
+   struct mt2063_config *config,
+   struct i2c_adapter *i2c)
 {
struct mt2063_state *state = NULL;
+   int instance, ret;
+
+   dprintk(1, "\n");
+
+   mutex_lock(&mt2063_list_mutex);
+
+   instance = hybrid_tuner_request_state(struct mt2063_state, state,
+  hybrid_tuner_instance_list,
+  i2c, config->tuner_address,
+  "mt2063");
+
+   switch(instance) {
+   case 0:
+   goto fail;
+   case 1:
+   /* new instance */
+   state->i2c = i2c;
+   state->i2c_addr = config->tuner_address;
+   /* find chip */
+   mutex_init(&state->lock);
+   state->frontend = fe;
+   if (ret < 0)
+   goto fail;
+   fe->tuner_priv = state;
+   fe->ops.tuner_ops = mt2063_ops;
+   break;
+   default:
+   fe->tuner_priv = state;
+   fe->ops.tuner_ops = mt2063_ops;
+   break;
+   }
+   mutex_unlock(&mt2063_list_mutex);
 
-   dprintk(2, "\n");
-
-   state = kzalloc(sizeof(struct mt2063_state), GFP_KERNEL);
-   if (state == NULL)
-   goto error;
-
-   state->config = config;
-   state->i2c = i2c;
-   state->frontend = fe;
-   state->reference = config->refclock / 1000; /* kHz */
-   fe->tuner_priv = state;
-   fe->ops.tuner_ops = mt2063_ops;
-
-   printk(KERN_INFO "%s: Attaching MT2063\n", __func__);
return fe;
 
-error:
-   kfree(state);
+fail:
+   hybrid_tuner_release_state(state);
+   mutex_unlock(&mt2063_list_mutex);
return NULL;
 }
 EXPORT_SYMBOL_GPL(mt2063_attach);
-- 
1.7.7.6

--
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/22] mt2063: read_reg, write_reg

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |  118 ++---
 1 files changed, 36 insertions(+), 82 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 31cb636..f659d4c 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -161,32 +161,22 @@ struct mt2063_state {
u32 num_regs;
u8 reg[MT2063_REG_END_REGS];
 };
-
-/*
- * mt2063_write - Write data into the I2C bus
- */
-static u32 mt2063_write(struct mt2063_state *state, u8 reg, u8 *data, u32 len)
+static int mt2063_write(struct mt2063_state *state, u8 reg, u8 data)
 {
-   struct dvb_frontend *fe = state->frontend;
int ret;
-   u8 buf[60];
+   u8 buf[2] = { reg, data };
+
struct i2c_msg msg = {
-   .addr = state->config->tuner_address,
+   .addr = state->i2c_addr,
.flags = 0,
.buf = buf,
-   .len = len + 1
+   .len = 2,
};
 
-   dprintk(2, "\n");
-
-   msg.buf[0] = reg;
-   memcpy(msg.buf + 1, data, len);
+   dprintk(3, "writeing at address 0x%02x, subadresse 0x%02x, \
+   value 0x%02x\n", state->i2c_addr, reg, data);
 
-   if (fe->ops.i2c_gate_ctrl)
-   fe->ops.i2c_gate_ctrl(fe, 1);
ret = i2c_transfer(state->i2c, &msg, 1);
-   if (fe->ops.i2c_gate_ctrl)
-   fe->ops.i2c_gate_ctrl(fe, 0);
 
if (ret < 0)
printk(KERN_ERR "%s error ret=%d\n", __func__, ret);
@@ -194,83 +184,48 @@ static u32 mt2063_write(struct mt2063_state *state, u8 
reg, u8 *data, u32 len)
return ret;
 }
 
-/*
- * mt2063_write - Write register data into the I2C bus, caching the value
- */
-static u32 mt2063_setreg(struct mt2063_state *state, u8 reg, u8 val)
+static int mt2063_read(struct mt2063_state *state, u8 reg, u8 *data)
 {
-   u32 status;
+   int ret = 0;
 
-   dprintk(2, "\n");
+   struct i2c_msg msg[] = { {
+   .addr = state->i2c_addr,
+   .flags = 0,
+   .buf = ®,
+   .len = 1,
+   }, {
+   .addr = state->i2c_addr,
+   .flags = I2C_M_RD,
+   .buf = data,
+   .len = 1,
+   } };
 
-   if (reg >= MT2063_REG_END_REGS)
-   return -ERANGE;
+   dprintk(3, "\n");
 
-   status = mt2063_write(state, reg, &val, 1);
-   if (status < 0)
-   return status;
+   ret = i2c_transfer(state->i2c, msg, 2);
+
+   if (ret < 0)
+   printk(KERN_ERR "Can't read from address 0x%02x,\n", reg);
 
-   state->reg[reg] = val;
+   dprintk(3, "readed at address 0x%02x, subadress 0x%02x, \
+   value 0x%02x\n", state->i2c_addr, reg, data[0]);
 
-   return 0;
+   return ret;
 }
 
-/*
- * mt2063_read - Read data from the I2C bus
- */
-static u32 mt2063_read(struct mt2063_state *state,
-  u8 subAddress, u8 *pData, u32 cnt)
+static int mt2063_set_reg_mask(struct mt2063_state *state, u8 reg,
+   u8 val, u8 mask)
 {
-   u32 status = 0; /* Status to be returned*/
-   struct dvb_frontend *fe = state->frontend;
-   u32 i = 0;
-
-   dprintk(2, "addr 0x%02x, cnt %d\n", subAddress, cnt);
-
-   if (fe->ops.i2c_gate_ctrl)
-   fe->ops.i2c_gate_ctrl(fe, 1);
-
-   for (i = 0; i < cnt; i++) {
-   u8 b0[] = { subAddress + i };
-   struct i2c_msg msg[] = {
-   {
-   .addr = state->config->tuner_address,
-   .flags = 0,
-   .buf = b0,
-   .len = 1
-   }, {
-   .addr = state->config->tuner_address,
-   .flags = I2C_M_RD,
-   .buf = pData + i,
-   .len = 1
-   }
-   };
+   u8 old_val, new_val;
 
-   status = i2c_transfer(state->i2c, msg, 2);
-   dprintk(2, "addr 0x%02x, ret = %d, val = 0x%02x\n",
-  subAddress + i, status, *(pData + i));
-   if (status < 0)
-   break;
-   }
-   if (fe->ops.i2c_gate_ctrl)
-   fe->ops.i2c_gate_ctrl(fe, 0);
+   dprintk(3, "\n");
 
-   if (status < 0)
-   printk(KERN_ERR "Can't read from address 0x%02x,\n",
-  subAddress + i);
+   mt2063_read(state, reg, &old_val);
 
-   return status;
-}
+   new_val = (old_val & ~mask) | (val & mask);
 
-/*
- * FIXME: Is this really needed?
- */
-static int MT2063_Sleep(struct dvb_frontend *fe)
-{
-   /*
-*  ToDo:  Add code here to implement a OS blocking
-*/
-   msleep(100);
+   if (new_v

[PATCH 04/22] mt2063: remove dect

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |  190 --
 1 files changed, 0 insertions(+), 190 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index d5a9dd9..a79e4ef 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -363,200 +363,17 @@ static int MT2063_Sleep(struct dvb_frontend *fe)
return 0;
 }
 
-/*
- * Microtune spur avoidance
- */
-
-/*  Implement ceiling, floor functions.  */
-#define ceil(n, d) (((n) < 0) ? (-((-(n))/(d))) : (n)/(d) + ((n)%(d) != 0))
-#define floor(n, d) (((n) < 0) ? (-((-(n))/(d))) - ((n)%(d) != 0) : (n)/(d))
-
-struct MT2063_FIFZone_t {
-   s32 min_;
-   s32 max_;
-};
-
-static struct MT2063_ExclZone_t *InsertNode(struct MT2063_AvoidSpursData_t
-   *pAS_Info,
-   struct MT2063_ExclZone_t *pPrevNode)
 {
-   struct MT2063_ExclZone_t *pNode;
 
-   dprintk(2, "\n");
-
-   /*  Check for a node in the free list  */
-   if (pAS_Info->freeZones != NULL) {
-   /*  Use one from the free list  */
-   pNode = pAS_Info->freeZones;
-   pAS_Info->freeZones = pNode->next_;
} else {
-   /*  Grab a node from the array  */
-   pNode = &pAS_Info->MT2063_ExclZones[pAS_Info->nZones];
-   }
-
-   if (pPrevNode != NULL) {
-   pNode->next_ = pPrevNode->next_;
-   pPrevNode->next_ = pNode;
-   } else {/*  insert at the beginning of the list  */
-
-   pNode->next_ = pAS_Info->usedZones;
-   pAS_Info->usedZones = pNode;
-   }
-
-   pAS_Info->nZones++;
-   return pNode;
-}
-
-static struct MT2063_ExclZone_t *RemoveNode(struct MT2063_AvoidSpursData_t
-   *pAS_Info,
-   struct MT2063_ExclZone_t *pPrevNode,
-   struct MT2063_ExclZone_t
-   *pNodeToRemove)
-{
-   struct MT2063_ExclZone_t *pNext = pNodeToRemove->next_;
-
-   dprintk(2, "\n");
-
-   /*  Make previous node point to the subsequent node  */
-   if (pPrevNode != NULL)
-   pPrevNode->next_ = pNext;
-
-   /*  Add pNodeToRemove to the beginning of the freeZones  */
-   pNodeToRemove->next_ = pAS_Info->freeZones;
-   pAS_Info->freeZones = pNodeToRemove;
-
-   /*  Decrement node count  */
-   pAS_Info->nZones--;
-
-   return pNext;
-}
-
-/*
- * MT_AddExclZone()
- *
- * Add (and merge) an exclusion zone into the list.
- * If the range (f_min, f_max) is totally outside the
- * 1st IF BW, ignore the entry.
- * If the range (f_min, f_max) is negative, ignore the entry.
- */
-static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info,
-  u32 f_min, u32 f_max)
-{
-   struct MT2063_ExclZone_t *pNode = pAS_Info->usedZones;
-   struct MT2063_ExclZone_t *pPrev = NULL;
-   struct MT2063_ExclZone_t *pNext = NULL;
-
-   dprintk(2, "\n");
-
-   /*  Check to see if this overlaps the 1st IF filter  */
-   if ((f_max > (pAS_Info->f_if1_Center - (pAS_Info->f_if1_bw / 2)))
-   && (f_min < (pAS_Info->f_if1_Center + (pAS_Info->f_if1_bw / 2)))
-   && (f_min < f_max)) {
-   /*
-*12 3  4   56
-*
-*   New entry:  |---||--|  |--||-||---||--|
-*or   oror or  or
-*   Existing:  |--|  |--|  |--||---|  |-|  |--|
-*/
-
-   /*  Check for our place in the list  */
-   while ((pNode != NULL) && (pNode->max_ < f_min)) {
-   pPrev = pNode;
-   pNode = pNode->next_;
-   }
-
-   if ((pNode != NULL) && (pNode->min_ < f_max)) {
-   /*  Combine me with pNode  */
-   if (f_min < pNode->min_)
-   pNode->min_ = f_min;
-   if (f_max > pNode->max_)
-   pNode->max_ = f_max;
-   } else {
-   pNode = InsertNode(pAS_Info, pPrev);
-   pNode->min_ = f_min;
-   pNode->max_ = f_max;
-   }
-
-   /*  Look for merging possibilities  */
-   pNext = pNode->next_;
-   while ((pNext != NULL) && (pNext->min_ < pNode->max_)) {
-   if (pNext->max_ > pNode->max_)
-   pNode->max_ = pNext->max_;
-   /*  Remove pNext, return ptr to pNext->next  */
-   pNext = RemoveNo

[PATCH 08/22] mt2063: add shutdown

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   47 +
 1 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index f659d4c..c3b5108 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -230,9 +230,23 @@ static int mt2063_set_reg_mask(struct mt2063_state *state, 
u8 reg,
return 0;
 }
 
+static void mt2063_shutdown(struct mt2063_state *state,
+   enum MT2063_Mask_Bits sd)
 {
+   dprintk(1, "\n");
 
+   /*
+* set all power bits
+*
+*/
+   if (sd == MT2063_NONE_SD) {
+   mt2063_write(state, MT2063_REG_PWR_1, 0x00);
+   mt2063_write(state, MT2063_REG_PWR_2, 0x00);
} else {
+   mt2063_set_reg_mask(state, MT2063_REG_PWR_1,
+   sd & 0xff, sd & 0xff);
+   mt2063_set_reg_mask(state, MT2063_REG_PWR_2, sd >> 8,
+   sd >> 8);
}
 }
 
@@ -1144,6 +1158,22 @@ static int mt2063_set_analog_params(struct dvb_frontend 
*fe,
return 0;
 }
 
+static struct dvb_tuner_ops mt2063_ops = {
+   .info = {
+   .name = "MT2063 Silicon Tuner",
+   .frequency_min = 4800,  /* 48 MHz */
+   .frequency_max = 100200,/* 1002 MHz */
+   .frequency_step = 5,/* 50 kHz */
+   },
+   .release = mt2063_release,
+   .init = mt2063_init,
+   .sleep = mt2063_sleep,
+
+   .set_params = mt2063_set_params,
+   .set_analog_params = mt2063_set_analog_params,
+   .get_if_frequency = mt2063_get_if_frequency,
+   /* TODO */
+};
 /*
  * As defined on EN 300 429, the DVB-C roll-off factor is 0.15.
  * So, the amount of the needed bandwith is given by:
@@ -1249,23 +1279,6 @@ static int mt2063_get_bandwidth(struct dvb_frontend *fe, 
u32 *bw)
return 0;
 }
 
-static struct dvb_tuner_ops mt2063_ops = {
-   .info = {
-.name = "MT2063 Silicon Tuner",
-.frequency_min = 4500,
-.frequency_max = 86500,
-.frequency_step = 0,
-},
-
-   .init = mt2063_init,
-   .get_status = mt2063_get_status,
-   .set_analog_params = mt2063_set_analog_params,
-   .set_params= mt2063_set_params,
-   .get_if_frequency = mt2063_get_if_frequency,
-   .get_bandwidth = mt2063_get_bandwidth,
-   .release = mt2063_release,
-};
-
 struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
struct mt2063_config *config,
struct i2c_adapter *i2c)
-- 
1.7.7.6

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


[PATCH 02/22] mt2063: remove unused functions

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   34 
 drivers/media/common/tuners/mt2063.h |   40 +++---
 2 files changed, 27 insertions(+), 47 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 872e9c0..9f3a546 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -2274,40 +2274,6 @@ error:
 }
 EXPORT_SYMBOL_GPL(mt2063_attach);
 
-/*
- * Ancillary routines visible outside mt2063
- * FIXME: Remove them in favor of using standard tuner callbacks
- */
-unsigned int tuner_MT2063_SoftwareShutdown(struct dvb_frontend *fe)
-{
-   struct mt2063_state *state = fe->tuner_priv;
-   int err = 0;
-
-   dprintk(2, "\n");
-
-   err = MT2063_SoftwareShutdown(state, 1);
-   if (err < 0)
-   printk(KERN_ERR "%s: Couldn't shutdown\n", __func__);
-
-   return err;
-}
-EXPORT_SYMBOL_GPL(tuner_MT2063_SoftwareShutdown);
-
-unsigned int tuner_MT2063_ClearPowerMaskBits(struct dvb_frontend *fe)
-{
-   struct mt2063_state *state = fe->tuner_priv;
-   int err = 0;
-
-   dprintk(2, "\n");
-
-   err = MT2063_ClearPowerMaskBits(state, MT2063_ALL_SD);
-   if (err < 0)
-   printk(KERN_ERR "%s: Invalid parameter\n", __func__);
-
-   return err;
-}
-EXPORT_SYMBOL_GPL(tuner_MT2063_ClearPowerMaskBits);
-
 MODULE_AUTHOR("Mauro Carvalho Chehab ");
 MODULE_DESCRIPTION("MT2063 Silicon tuner");
 MODULE_LICENSE("GPL");
diff --git a/drivers/media/common/tuners/mt2063.h 
b/drivers/media/common/tuners/mt2063.h
index 62d0e8e..46d6d30 100644
--- a/drivers/media/common/tuners/mt2063.h
+++ b/drivers/media/common/tuners/mt2063.h
@@ -1,3 +1,25 @@
+/*
+ * Driver for microtune mt2063 tuner
+ *
+ * Copyright (c) 2012 Stefan Ringel 
+ * Copyright (c) 2011 Mauro Carvalho Chehab 
+ *
+ * This driver came from a driver originally written by:
+ *  Henry Wang 
+ * 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()
+ *
+ * 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.
+ */
+
 #ifndef __MT2063_H__
 #define __MT2063_H__
 
@@ -10,27 +32,19 @@ struct mt2063_config {
 
 #if defined(CONFIG_MEDIA_TUNER_MT2063) || 
(defined(CONFIG_MEDIA_TUNER_MT2063_MODULE) && defined(MODULE))
 struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
-  struct mt2063_config *config,
-  struct i2c_adapter *i2c);
+   struct mt2063_config *config,
+   struct i2c_adapter *i2c);
 
 #else
 
 static inline struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
-  struct mt2063_config *config,
-  struct i2c_adapter *i2c)
+   struct mt2063_config *config,
+   struct i2c_adapter *i2c)
 {
printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
return NULL;
 }
 
-int mt2063_setTune(struct dvb_frontend *fe, u32 f_in,
-  u32 bw_in,
-  enum MTTune_atv_standard tv_type);
-
-/* FIXME: Should use the standard DVB attachment interfaces */
-unsigned int tuner_MT2063_SoftwareShutdown(struct dvb_frontend *fe);
-unsigned int tuner_MT2063_ClearPowerMaskBits(struct dvb_frontend *fe);
-
-#endif /* CONFIG_DVB_MT2063 */
+#endif /* CONFIG_MEDIA_TUNER_MT2063 */
 
 #endif /* __MT2063_H__ */
-- 
1.7.7.6

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


[PATCH 01/22] mt2063: trivial change

2012-02-14 Thread linuxtv
From: Stefan Ringel 

Signed-off-by: Stefan Ringel 
---
 drivers/media/common/tuners/mt2063.c |   23 +++
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/media/common/tuners/mt2063.c 
b/drivers/media/common/tuners/mt2063.c
index 0ed9091..872e9c0 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -1,12 +1,13 @@
 /*
- * Driver for mt2063 Micronas tuner
+ * Driver for microtune mt2063 tuner
  *
  * Copyright (c) 2011 Mauro Carvalho Chehab 
+ * Copyright (c) 2012 Stefan Ringel 
  *
  * This driver came from a driver originally written by:
- * Henry Wang 
+ * Henry Wang 
  * Made publicly available by Terratec, at:
- * 
http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
+ * 
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()
  *
  * This program is free software; you can redistribute it and/or modify
@@ -29,13 +30,14 @@
 
 static unsigned int debug;
 module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Set Verbosity level");
+MODULE_PARM_DESC(debug, "Set debug level");
 
-#define dprintk(level, fmt, arg...) do {   \
-if (debug >= level)\
-   printk(KERN_DEBUG "mt2063 %s: " fmt, __func__, ## arg); \
-} while (0)
 
+/* debug level
+ * 0 don't debug
+ * 1 called functions without i2c comunications
+ * 2 additional calculating, result etc.
+ * 3 maximum debug information
 
 /* positive error codes used internally */
 
@@ -60,6 +62,10 @@ if (debug >= level)  
\
  *  check against this version number to make sure that
  *  it matches the version that the tuner driver knows about.
  */
+#define dprintk(level, fmt, arg...) do {   \
+if (debug >= level)\
+   printk(KERN_DEBUG "mt2063 %s: " fmt, __func__, ##arg);  \
+} while (0)
 
 /* DECT Frequency Avoidance */
 #define MT2063_DECT_AVOID_US_FREQS  0x0001
@@ -2305,3 +2311,4 @@ EXPORT_SYMBOL_GPL(tuner_MT2063_ClearPowerMaskBits);
 MODULE_AUTHOR("Mauro Carvalho Chehab ");
 MODULE_DESCRIPTION("MT2063 Silicon tuner");
 MODULE_LICENSE("GPL");
+MODULE_VERSION("0.2");
-- 
1.7.7.6

--
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] hdpvr: update picture controls to support firmware versions > 0.15

2012-02-14 Thread Devin Heitmueller
On Tue, Feb 14, 2012 at 3:43 PM, Jarod Wilson  wrote:
> Looks sane to me, and really needs to get in ASAP. I'd even suggest we
> get it sent to stable, as these newer firmware HDPVR are pretty wonky
> with any current kernel.
>
> Acked-by: Jarod Wilson 
> Reviewed-by: Jarod Wilson 
> CC: sta...@vger.kernel.org

Where did the process break down here?  Taylor did this patch *months*
ago, and there has been absolutely no comment with why it wouldn't go
upstream.  If he hadn't been diligent in pinging the ML repeatedly, it
would have been lost.

Are there other patches that have hit the ML that aren't getting upstream?

Devin

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


[PATCH] Make the USB Video Class debug filesystem support compile time optional.

2012-02-14 Thread Hans Petter Selasky
The following patch makes the recently added DEBUGFS for UVC optional.

--HPS

Signed-off-by: Hans Petter Selasky 
---
 drivers/media/video/uvc/Kconfig  |9 +
 drivers/media/video/uvc/Makefile |5 -
 drivers/media/video/uvc/uvc_driver.c |   12 ++--
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/uvc/Kconfig b/drivers/media/video/uvc/Kconfig
index 6c197da..45e89a9 100644
--- a/drivers/media/video/uvc/Kconfig
+++ b/drivers/media/video/uvc/Kconfig
@@ -7,6 +7,15 @@ config USB_VIDEO_CLASS
 
  For more information see: 
 
+config USB_VIDEO_CLASS_DEBUGFS
+   bool "UVC debugfs support"
+   default y
+   ---help---
+ This option makes the USB Video Class driver build with
+ debugfs support.
+
+ If you are in doubt, say Y.
+
 config USB_VIDEO_CLASS_INPUT_EVDEV
bool "UVC input events device support"
default y
diff --git a/drivers/media/video/uvc/Makefile b/drivers/media/video/uvc/Makefile
index c26d12f..a152a2a 100644
--- a/drivers/media/video/uvc/Makefile
+++ b/drivers/media/video/uvc/Makefile
@@ -1,5 +1,8 @@
 uvcvideo-objs  := uvc_driver.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_ctrl.o \
- uvc_status.o uvc_isight.o uvc_debugfs.o
+ uvc_status.o uvc_isight.o
+ifeq ($(CONFIG_USB_VIDEO_CLASS_DEBUGFS),y)
+uvcvideo-objs  += uvc_debugfs.o
+endif
 ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
 uvcvideo-objs  += uvc_entity.o
 endif
diff --git a/drivers/media/video/uvc/uvc_driver.c 
b/drivers/media/video/uvc/uvc_driver.c
index a240d43..291f77b 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -1676,7 +1676,9 @@ static void uvc_unregister_video(struct uvc_device *dev)
video_unregister_device(stream->vdev);
stream->vdev = NULL;
 
+#ifdef CONFIG_USB_VIDEO_CLASS_DEBUGFS
uvc_debugfs_cleanup_stream(stream);
+#endif
}
 
/* Decrement the stream count and call uvc_delete explicitly if there
@@ -1702,8 +1704,9 @@ static int uvc_register_video(struct uvc_device *dev,
return ret;
}
 
+#ifdef CONFIG_USB_VIDEO_CLASS_DEBUGFS
uvc_debugfs_init_stream(stream);
-
+#endif
/* Register the device with V4L. */
vdev = video_device_alloc();
if (vdev == NULL) {
@@ -2411,11 +2414,14 @@ static int __init uvc_init(void)
 {
int ret;
 
+#ifdef CONFIG_USB_VIDEO_CLASS_DEBUGFS
uvc_debugfs_init();
-
+#endif
ret = usb_register(&uvc_driver.driver);
if (ret < 0) {
+#ifdef CONFIG_USB_VIDEO_CLASS_DEBUGFS
uvc_debugfs_cleanup();
+#endif
return ret;
}
 
@@ -2426,7 +2432,9 @@ static int __init uvc_init(void)
 static void __exit uvc_cleanup(void)
 {
usb_deregister(&uvc_driver.driver);
+#ifdef CONFIG_USB_VIDEO_CLASS_DEBUGFS
uvc_debugfs_cleanup();
+#endif
 }
 
 module_init(uvc_init);
-- 
1.7.6
--
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] hdpvr: update picture controls to support firmware versions > 0.15

2012-02-14 Thread Jarod Wilson
On Mon, Nov 7, 2011 at 7:54 PM, Taylor Ralph  wrote:
> On Mon, Nov 7, 2011 at 7:21 AM, Mauro Carvalho Chehab
>  wrote:
>> Em 21-10-2011 01:33, Taylor Ralph escreveu:
>>> On Thu, Oct 20, 2011 at 3:26 PM, Taylor Ralph  
>>> wrote:
 On Thu, Oct 20, 2011 at 2:14 PM, Devin Heitmueller
  wrote:
> On Thu, Oct 20, 2011 at 1:08 PM, Janne Grunau  wrote:
>> I think such scenario is unlikely but I don't know it for sure and
>> I don't want to force anyone to test every firmware version.
>> Ignoring them for firmware version < 16 should be safe since we assume
>> they had no effect. Returning -EINVAL might break API-ignoring
>> applications written with the HD PVR in mind but I think it's a better
>> approach than silently ignoring those controls.
>
> At this point, let's just make it so that the old behavior is
> unchanged for old firmwares, meaning from both an API standpoint as
> well as what the values are.  At some point if somebody cares enough
> to go back and fix the support so that the controls actually work with
> old firmwares, they can take that up as a separate task.  In reality,
> it is likely that nobody will ever do that, as the "easy answer" is
> just to upgrade to firmware 16.
>
> Taylor, could you please tweak your patch to that effect and resubmit?
>

 Sure, I'll try to get to it tonight and have it tested.

Looks sane to me, and really needs to get in ASAP. I'd even suggest we
get it sent to stable, as these newer firmware HDPVR are pretty wonky
with any current kernel.

Acked-by: Jarod Wilson 
Reviewed-by: Jarod Wilson 
CC: sta...@vger.kernel.org

-- 
Jarod Wilson
ja...@wilsonet.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


[GIT PULL] git://linuxtv.org/mkrufky/tuners.git tveeprom

2012-02-14 Thread Michael Krufky
Mauro,

Please also pull in this change to tveeprom.c:

The following changes since commit a3db60bcf7671cc011ab4f848cbc40ff7ab52c1e:
  Michael Krufky (1):
[media] xc5000: declare firmware configuration structures as
static const

are available in the git repository at:

  git://linuxtv.org/mkrufky/tuners.git tveeprom

Michael Krufky (1):
  tveeprom: update hauppauge tuner list thru 181

 drivers/media/video/tveeprom.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

Cheers,

Mike
--
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: Fintek driver linux

2012-02-14 Thread Jarod Wilson

On 02/14/2012 02:47 PM, W R wrote:

Thanks again Jarod. I have emailed Jetway asking about the specs for the
CIR header on the motheboard. (JNC64-LF - nvidia chipset, *not* Atom/Ion
though...) which they have replied is the Fintek F71809 I/O chipset, and
I believe the same chipset on many of their Atom boards.
According to Fintek this had linux support since kernel 2.6.36? Not sure
about that.


Looks like it went in upstream after 2.6.39, so the first release that 
carried it was actually 3.0.


If it really is the F71809, then the fix I had in mind shouldn't matter, 
but I'd have to question if its really that and not an F71869A, which is 
nearly identical, but needs to use a different logical device for the IR 
input, lest you lock up the system -- sounds familiar, eh? :)


However, its also possible its something else going on here, some sort 
of bad interaction between multiple different drivers all poking at the 
super i/o chip without any coordinated locking.


Now, I *think* that if you get evdev installed and run it against the 
input device that fintek-cir exposes, you should be able to see the chip 
ID to confirm if its really the F71809 or not. If you see Product and 
Version of 0x08 and 0x04 (or vice versa), then its indeed one of the 
older chips that use logical device 5. Anything else, and it should be 
logical device 8, and a patch that just went into the for-v3.4 media 
tree branch is necessary.


-j



Since my previous email I have left my IR device plugged in to the
header on the motherboard and I have added fintek-cir to the blacklist.
After boot if I modprobe ir-rc6-decoder (which triggers rc-core and
lirc_dev and all the other protocols etc.) then fairly quickly after
that modprobe fintek-cir then 1 in 10 times it actually works. The other
9 times it freezes. It freezes everytime if I try to start fintek-cir
first.
I have already added my remotes config with the help of ir-keytable to
/etc/rc_keymaps/ and pointed /etc/rc_maps.cfg towards it. It gets loaded
automatically. I have uninstalled LIRC. A copy of my logs when it hasn't
crashed is here: http://pastebin.com/MqETvBsz
Not sure if any of this helps anyone, and to anyone reading this please
feel free to point out any of my stupid errors!


 > Date: Fri, 10 Feb 2012 13:56:38 -0500
 > From: ja...@redhat.com
 > To: gridmunc...@hotmail.com
 > Subject: Re: Fintek driver linux
 >
 > On 02/05/2012 10:48 AM, W R wrote:
 > > Tried various kernels, including 3.0.0 and 3.2 and kernel panic is
 > > almost always caused when ir receiver plugged into cir header on
 > > motherboard. If device plugged in after boot then it works fine.
Can use
 > > remote and configure buttons etc.
 > >
 > > Where's a good forum to discuss this openly so others with perhaps the
 > > same issues can read it?
 >
 > linux-media@vger.kernel.org is the relevant upstream mailing list.
 >
 >
 > > Any ideas off-hand why this is? I have various cir header options in
 > > bios: Disabled, 3F8/IRQ4, 2F8/IRQ3, 3E8/IRQ4, 2E8/IRQ3 and have tried
 > > all of these without luck, although I have once or twice been able to
 > > boot into mythbuntu and its worked. But out of 50 odd boot attempts it
 > > worked twice. I also have the choice to enable wake from CIR which
 > > obviously I need to have on to be able to wake my HTPC with remote. Any
 > > help would be greatly appreciated.
 >
 > According to my fintek contact, the CIR logical device on a number of
 > shipped systems is actually different than the devel board I was
 > provided, so there's a patch coming to account for that. Its possible
 > what you're seeing is due to the incorrect logical device number, but
 > I'm just shooting in the dark.
 >
 >
 > --
 > Jarod Wilson
 > ja...@redhat.com



--
Jarod Wilson
ja...@redhat.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: mx3_camera: dmaengine: failed to get dma1chan

2012-02-14 Thread Fabio Estevam
On 2/14/12, Fabio Estevam  wrote:

> Then I start the following Gstreamer pipeline:
>
> $ gst-launch v4l2src ! fbdevsink
> Setting pipeline to PAUSED ...
> mx3-camera mx3-camera.0: MX3 Camera driver attached to camera 0
> Pipeline is live and does not need PREROLL ...
> WARNING: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not
> get
> parameters on device '/dev/video0'
> Additional debug info:
> v4l2src_calls.c(225): gst_v4l2src_set_capture ():
> /GstPipeline:pipeline0/GstV4l2
> Src:v4l2src0:
> system error: Invalid argument
> Setting pipeline to PLAYING ...
> New clock: GstSystemClock
>
> , and I start to see the captured image in the LCD, but after about
> 10-15 seconds I get:
>
>
> dma dma0chan7: NFB4EOF on channel 7, ready 0, 0, cur 80

Ok, looks like if I adjust the resolution and framerate properly I no
longer get this error.

With this pipeline I don`t get this error:

gst-launch -v v4l2src device=/dev/video0 !
video/x-raw-yuv,width=320,height=240,framerate=25/1 ! ffmpegcolorspace
! fbdevsink

Now this leads to a new issue: the board resets after about 3 minutes.

Then I started to investigate if this issue was in the capture side or
in the display side:

Capture only pipeline:

gst-launch -v v4l2src  ! video/x-raw-yuv,width=320,height=240,
framerate=25/1 ! fakesink  (works fine)


Display only pipeline:

gst-launch videotestsrc ! fbdevsink (resets the system after ~ 3 minutes)

I will start investigating this and any comments/suggestions are welcome.

Thanks,

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


Re: [PATCH 00/35] Add a driver for Terratec H7

2012-02-14 Thread Torfinn Ingolfsen
On Thu, Feb 9, 2012 at 10:12 PM, Torfinn Ingolfsen  wrote:
> Update:
>
> On Thu, Feb 9, 2012 at 12:04 AM, Torfinn Ingolfsen  wrote:
>> Never mind. after adding this patch:
>> http://patchwork.linuxtv.org/patch/9691/
>>
>> and rebuilding the media drivers, the device is now detected:
>> tingo@kg-f4:~$ dmesg | grep -i terratec
>> [   19.755806] dvb-usb: found a 'TerraTec DTV StarBox DVB-T/C USB2.0
>> (az6007)' in warm state.
>> [   20.949045] DVB: registering new adapter (TerraTec DTV StarBox
>> DVB-T/C USB2.0 (az6007))
>> [   23.732039] Registered IR keymap rc-nec-terratec-cinergy-xs
>> [   23.732442] dvb-usb: TerraTec DTV StarBox DVB-T/C USB2.0 (az6007)
>> successfully initialized and connected.
>
> I have now tested the TerraTec H7, both with w_scan and with Kaffeine.
> Neither of then is able to find any channels from the H7. (The device
> is connected to an external power supply). However, if I connect
> another device (a PCTV nanoStick T2 290e) to the same cable, both
> w_scan and Kaffeine find all the channels for my provider, and I can
> watch the clear (unencrypted) ones in Kaffeine.
>
> How can I debug the H7 further?

For anyone using the H7 on DVB-C with success; which firmware are you
using? The one included with the experimental "media build" drivers,
or ?
And what is the device id of your H7?
(from lsusb)
mine is:
tingo@kg-f4:~$ lsusb -s 1:3
Bus 001 Device 003: ID 0ccd:10a3 TerraTec Electronic GmbH
-- 
Regards,
Torfinn Ingolfsen
--
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: linux-next: Tree for Jan 20 (drivers/media/radio/wl128x/)

2012-02-14 Thread Fabio Estevam
On 2/14/12, Geert Uytterhoeven  wrote:

> Ping?
>
> Build breakage in mainline since at least 3 weeks.

>From what I recall Randy proposed a patch for fixing this issue:
http://patchwork.linuxtv.org/patch/9750/
--
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: linux-next: Tree for Jan 20 (drivers/media/radio/wl128x/)

2012-02-14 Thread Geert Uytterhoeven
On Tue, Jan 24, 2012 at 22:33, Geert Uytterhoeven  wrote:
> On Sat, Jan 21, 2012 at 01:32, Randy Dunlap  wrote:
>> On 01/19/2012 06:12 PM, Stephen Rothwell wrote:
>>> Changes since 20120119:
>>
>> on x86_64:
>>
>> ERROR: "st_register" [drivers/media/radio/wl128x/fm_drv.ko] undefined!
>> ERROR: "st_unregister" [drivers/media/radio/wl128x/fm_drv.ko] undefined!
>
> Also in m68k allmodconfig since a while:
> http://kisskb.ellerman.id.au/kisskb/buildresult/5427875/
>
> config RADIO_WL128X
>        tristate "Texas Instruments WL128x FM Radio"
>        depends on VIDEO_V4L2 && RFKILL
>        select TI_ST if NET && GPIOLIB
>
> config TI_ST
>        tristate "Shared transport core driver"
>        depends on NET && GPIOLIB
>        select FW_LOADER
>
> On m68k allmodconfig, GPIOLIB is not enabled, hence TI_ST
> will not be selected, and st_{,un}register() won't be there.
> Shouldn't the whole RADIO_WL128X depend on NET && GPIOLIB?
> Or depend on TI_ST, instead of selecting it?
>
> BTW, shouldn't it be called ti_st_un{,un}register()?
> At first I thought the link error was related to SCSI tape drives ;-)

Ping?

Build breakage in mainline since at least 3 weeks.

Gr{oetje,eeting}s,

                        Geert

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

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cron job: media_tree daily build: WARNINGS

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

Results of the daily build of media_tree:

date:Tue Feb 14 19:02:22 CET 2012
git hash:6e82a6a2a0e895b787f22d28311232cc94fda4b9
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: WARNINGS
linux-git-armv5-ixp: WARNINGS
linux-git-i686: WARNINGS
linux-git-m32r: WARNINGS
linux-git-mips: WARNINGS
linux-git-powerpc64: WARNINGS
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-3.3-rc1-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
linux-3.3-rc1-x86_64: WARNINGS
apps: WARNINGS
spec-git: WARNINGS
sparse: ERRORS

Detailed results are available here:

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

Full logs are available here:

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


[PATCH] [media] fintek-cir: add support for newer chip version

2012-02-14 Thread Mauro Carvalho Chehab
Acked-by: Jarod Wilson 
Reviewed-by: Jarod Wilson 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/media/rc/fintek-cir.c |   26 ++
 drivers/media/rc/fintek-cir.h |4 +++-
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index 7f7079b..392d4be 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -117,7 +117,7 @@ static u8 fintek_cir_reg_read(struct fintek_dev *fintek, u8 
offset)
 static void cir_dump_regs(struct fintek_dev *fintek)
 {
fintek_config_mode_enable(fintek);
-   fintek_select_logical_dev(fintek, LOGICAL_DEV_CIR);
+   fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
 
pr_reg("%s: Dump CIR logical device registers:\n", FINTEK_DRIVER_NAME);
pr_reg(" * CR CIR BASE ADDR: 0x%x\n",
@@ -143,7 +143,7 @@ static int fintek_hw_detect(struct fintek_dev *fintek)
u8 chip_major, chip_minor;
u8 vendor_major, vendor_minor;
u8 portsel, ir_class;
-   u16 vendor;
+   u16 vendor, chip;
int ret = 0;
 
fintek_config_mode_enable(fintek);
@@ -176,6 +176,7 @@ static int fintek_hw_detect(struct fintek_dev *fintek)
 
chip_major = fintek_cr_read(fintek, GCR_CHIP_ID_HI);
chip_minor = fintek_cr_read(fintek, GCR_CHIP_ID_LO);
+   chip  = chip_major << 8 | chip_minor;
 
vendor_major = fintek_cr_read(fintek, GCR_VENDOR_ID_HI);
vendor_minor = fintek_cr_read(fintek, GCR_VENDOR_ID_LO);
@@ -192,6 +193,15 @@ static int fintek_hw_detect(struct fintek_dev *fintek)
fintek->chip_major  = chip_major;
fintek->chip_minor  = chip_minor;
fintek->chip_vendor = vendor;
+
+   /*
+* Newer reviews of this chipset uses port 8 instead of 5
+*/
+   if ((chip != 0x0408) || (chip != 0x0804))
+   fintek->logical_dev_cir = LOGICAL_DEV_CIR_REV2;
+   else
+   fintek->logical_dev_cir = LOGICAL_DEV_CIR_REV1;
+
spin_unlock_irqrestore(&fintek->fintek_lock, flags);
 
return ret;
@@ -200,7 +210,7 @@ static int fintek_hw_detect(struct fintek_dev *fintek)
 static void fintek_cir_ldev_init(struct fintek_dev *fintek)
 {
/* Select CIR logical device and enable */
-   fintek_select_logical_dev(fintek, LOGICAL_DEV_CIR);
+   fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN);
 
/* Write allocated CIR address and IRQ information to hardware */
@@ -381,7 +391,7 @@ static irqreturn_t fintek_cir_isr(int irq, void *data)
fit_dbg_verbose("%s firing", __func__);
 
fintek_config_mode_enable(fintek);
-   fintek_select_logical_dev(fintek, LOGICAL_DEV_CIR);
+   fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
fintek_config_mode_disable(fintek);
 
/*
@@ -422,7 +432,7 @@ static void fintek_enable_cir(struct fintek_dev *fintek)
fintek_config_mode_enable(fintek);
 
/* enable the CIR logical device */
-   fintek_select_logical_dev(fintek, LOGICAL_DEV_CIR);
+   fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN);
 
fintek_config_mode_disable(fintek);
@@ -439,7 +449,7 @@ static void fintek_disable_cir(struct fintek_dev *fintek)
fintek_config_mode_enable(fintek);
 
/* disable the CIR logical device */
-   fintek_select_logical_dev(fintek, LOGICAL_DEV_CIR);
+   fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
fintek_cr_write(fintek, LOGICAL_DEV_DISABLE, CIR_CR_DEV_EN);
 
fintek_config_mode_disable(fintek);
@@ -611,7 +621,7 @@ static int fintek_suspend(struct pnp_dev *pdev, 
pm_message_t state)
fintek_config_mode_enable(fintek);
 
/* disable cir logical dev */
-   fintek_select_logical_dev(fintek, LOGICAL_DEV_CIR);
+   fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
fintek_cr_write(fintek, LOGICAL_DEV_DISABLE, CIR_CR_DEV_EN);
 
fintek_config_mode_disable(fintek);
@@ -634,7 +644,7 @@ static int fintek_resume(struct pnp_dev *pdev)
 
/* Enable CIR logical device */
fintek_config_mode_enable(fintek);
-   fintek_select_logical_dev(fintek, LOGICAL_DEV_CIR);
+   fintek_select_logical_dev(fintek, fintek->logical_dev_cir);
fintek_cr_write(fintek, LOGICAL_DEV_ENABLE, CIR_CR_DEV_EN);
 
fintek_config_mode_disable(fintek);
diff --git a/drivers/media/rc/fintek-cir.h b/drivers/media/rc/fintek-cir.h
index 1b10b20..82516a1 100644
--- a/drivers/media/rc/fintek-cir.h
+++ b/drivers/media/rc/fintek-cir.h
@@ -88,6 +88,7 @@ struct fintek_dev {
u8 chip_major;
u8 chip_minor;
u16 chip_vendor;
+   u8 logical_dev_cir;
 
/* hardware features */
bool hw_learning_capable;
@@ -172,7 +173,8 @@ struct fintek_dev {
 #define LOGICAL_DEV_ENABL

[PATCH] lgdt330x: fix signedness error in i2c_read_demod_bytes()

2012-02-14 Thread Xi Wang
The error handling in lgdt3303_read_status() and lgdt330x_read_ucblocks()
doesn't work, because i2c_read_demod_bytes() returns a u8 and (err < 0)
is always false.

err = i2c_read_demod_bytes(state, 0x58, buf, 1);
if (err < 0)
return err;

Change the return type of i2c_read_demod_bytes() to int.  Also change
the return value on error to -EIO to make (err < 0) work.

Signed-off-by: Xi Wang 
Cc: sta...@vger.kernel.org
---
 drivers/media/dvb/frontends/lgdt330x.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/frontends/lgdt330x.c 
b/drivers/media/dvb/frontends/lgdt330x.c
index c990d35..e046622 100644
--- a/drivers/media/dvb/frontends/lgdt330x.c
+++ b/drivers/media/dvb/frontends/lgdt330x.c
@@ -104,8 +104,8 @@ static int i2c_write_demod_bytes (struct lgdt330x_state* 
state,
  * then reads the data returned for (len) bytes.
  */
 
-static u8 i2c_read_demod_bytes (struct lgdt330x_state* state,
-  enum I2C_REG reg, u8* buf, int len)
+static int i2c_read_demod_bytes(struct lgdt330x_state *state,
+   enum I2C_REG reg, u8 *buf, int len)
 {
u8 wr [] = { reg };
struct i2c_msg msg [] = {
@@ -118,6 +118,8 @@ static u8 i2c_read_demod_bytes (struct lgdt330x_state* 
state,
ret = i2c_transfer(state->i2c, msg, 2);
if (ret != 2) {
printk(KERN_WARNING "lgdt330x: %s: addr 0x%02x select 0x%02x 
error (ret == %i)\n", __func__, state->config->demod_address, reg, ret);
+   if (ret >= 0)
+   ret = -EIO;
} else {
ret = 0;
}
-- 
1.7.5.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


[git:v4l-dvb/for_v3.4] [media] davinci: vpif: remove machine specific header file includes

2012-02-14 Thread Mauro Carvalho Chehab
This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/media_tree.git tree:

Subject: [media] davinci: vpif: remove machine specific header file includes
Author:  Manjunath Hadli 
Date:Fri Dec 23 03:28:44 2011 -0300

remove unnecessary inclusion of machine specific header files mach/dm646x.h,
mach/hardware.h from vpif.h  and aslo mach/dm646x.h from vpif_display.c
driver which comes in the way of platform code consolidation.
Add linux/i2c.h header file in vpif_types.h which is required for
building.

Signed-off-by: Manjunath Hadli 
Cc: Mauro Carvalho Chehab 
Cc: LMML 
Signed-off-by: Mauro Carvalho Chehab 

 drivers/media/video/davinci/vpif.h |2 --
 drivers/media/video/davinci/vpif_display.c |2 --
 include/media/davinci/vpif_types.h |2 ++
 3 files changed, 2 insertions(+), 4 deletions(-)

---

http://git.linuxtv.org/media_tree.git?a=commitdiff;h=db38951cce88eae36909143291545a59db4efa59

diff --git a/drivers/media/video/davinci/vpif.h 
b/drivers/media/video/davinci/vpif.h
index 25036cb..8bcac65 100644
--- a/drivers/media/video/davinci/vpif.h
+++ b/drivers/media/video/davinci/vpif.h
@@ -18,8 +18,6 @@
 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 /* Maximum channel allowed */
diff --git a/drivers/media/video/davinci/vpif_display.c 
b/drivers/media/video/davinci/vpif_display.c
index 286f029..7fa34b4 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -39,8 +39,6 @@
 #include 
 #include 
 
-#include 
-
 #include "vpif_display.h"
 #include "vpif.h"
 
diff --git a/include/media/davinci/vpif_types.h 
b/include/media/davinci/vpif_types.h
index 9929b05..bd8217c 100644
--- a/include/media/davinci/vpif_types.h
+++ b/include/media/davinci/vpif_types.h
@@ -17,6 +17,8 @@
 #ifndef _VPIF_TYPES_H
 #define _VPIF_TYPES_H
 
+#include 
+
 #define VPIF_CAPTURE_MAX_CHANNELS  2
 
 enum vpif_if_type {
--
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


mx3_camera: dmaengine: failed to get dma1chan

2012-02-14 Thread Fabio Estevam
Hi,

I am testing mx3_camera on a mx31pdk board running linux-next and this
is what I get during kernel boot:


soc-camera-pdrv soc-camera-pdrv.0: Probing soc-camera-pdrv.0
mx3-camera mx3-camera.0: MX3 Camera driver attached to camera 0
ov2640 0-0030: ov2640 Product ID 26:42 Manufacturer ID 7f:a2
i2c i2c-0: OV2640 Probed
mx3-camera mx3-camera.0: MX3 Camera driver detached from camera 0
dmaengine: failed to get dma1chan0: (-22)
dmaengine: failed to get dma1chan1: (-22)
dmaengine: failed to get dma1chan2: (-22)
dmaengine: failed to get dma1chan3: (-22)
dmaengine: failed to get dma1chan4: (-22)
dmaengine: failed to get dma1chan5: (-22)
dmaengine: failed to get dma1chan6: (-22)
dmaengine: failed to get dma1chan7: (-22)
dmaengine: failed to get dma1chan8: (-22)
dmaengine: failed to get dma1chan9: (-22)
dmaengine: failed to get dma1chan10: (-22)
dmaengine: failed to get dma1chan11: (-22)
dmaengine: failed to get dma1chan12: (-22)
dmaengine: failed to get dma1chan13: (-22)
dmaengine: failed to get dma1chan14: (-22)
dmaengine: failed to get dma1chan15: (-22)
dmaengine: failed to get dma1chan16: (-22)
dmaengine: failed to get dma1chan17: (-22)
dmaengine: failed to get dma1chan18: (-22)
dmaengine: failed to get dma1chan19: (-22)
dmaengine: failed to get dma1chan20: (-22)
dmaengine: failed to get dma1chan21: (-22)
dmaengine: failed to get dma1chan22: (-22)
dmaengine: failed to get dma1chan23: (-22)
dmaengine: failed to get dma1chan24: (-22)
dmaengine: failed to get dma1chan25: (-22)
dmaengine: failed to get dma1chan26: (-22)
dmaengine: failed to get dma1chan27: (-22)
dmaengine: failed to get dma1chan28: (-22)
dmaengine: failed to get dma1chan29: (-22)
dmaengine: failed to get dma1chan30: (-22)
...

Then I start the following Gstreamer pipeline:

$ gst-launch v4l2src ! fbdevsink
Setting pipeline to PAUSED ...
mx3-camera mx3-camera.0: MX3 Camera driver attached to camera 0
Pipeline is live and does not need PREROLL ...
WARNING: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not get
parameters on device '/dev/video0'
Additional debug info:
v4l2src_calls.c(225): gst_v4l2src_set_capture (): /GstPipeline:pipeline0/GstV4l2
Src:v4l2src0:
system error: Invalid argument
Setting pipeline to PLAYING ...
New clock: GstSystemClock

, and I start to see the captured image in the LCD, but after about
10-15 seconds I get:


dma dma0chan7: NFB4EOF on channel 7, ready 0, 0, cur 80

,and the display gets frozen with the last captured frame from the camera.

Are there known patches that fix this issue?

Thanks,

Fabio Estevam
--
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] [trivial] media: Fix typo in radio-sf16fmr2.c

2012-02-14 Thread Masanari Iida
Correct spelling "contrls" to "controls" in
drivers/media/radio/radio-sf16fmr2.c

Signed-off-by: Masanari Iida 
---
 drivers/media/radio/radio-sf16fmr2.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/media/radio/radio-sf16fmr2.c 
b/drivers/media/radio/radio-sf16fmr2.c
index 2dd4859..7ab9afa 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -172,7 +172,7 @@ static int fmr2_tea_ext_init(struct snd_tea575x *tea)
fmr2->volume = v4l2_ctrl_new_std(&tea->ctrl_handler, 
&fmr2_ctrl_ops, V4L2_CID_AUDIO_VOLUME, 0, 68, 2, 56);
fmr2->balance = v4l2_ctrl_new_std(&tea->ctrl_handler, 
&fmr2_ctrl_ops, V4L2_CID_AUDIO_BALANCE, -68, 68, 2, 0);
if (tea->ctrl_handler.error) {
-   printk(KERN_ERR "radio-sf16fmr2: can't initialize 
contrls\n");
+   printk(KERN_ERR "radio-sf16fmr2: can't initialize 
controls\n");
return tea->ctrl_handler.error;
}
}
-- 
1.7.6.5

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


[PATCH] as102: map URB DMA addresses in the driver

2012-02-14 Thread Gianluca Gennari
On a set-top-box based on the Broadcom 7405 SoC (MIPS), the Abilis as102 driver
causes a kernel oops while trying to map the URB stream buffers DMA addresses:

CPU 0 Unable to handle kernel paging request at virtual address 007b9900,
epc == 80010cc4, ra == 8039d108

Call Trace:
[<80010cc4>] mips_dma_map_page+0x14/0x108
[<8039d108>] usb_hcd_map_urb_for_dma+0x338/0x4a8
[<8039d540>] usb_hcd_submit_urb+0x2c8/0x8cc
[] as102_submit_urb_stream+0x64/0xc8 [dvb_as102]
[] as102_usb_start_stream+0x44/0x80 [dvb_as102]
[] as102_dvb_dmx_start_feed+0xb4/0x17c [dvb_as102]
[<803e20f4>] dmx_ts_feed_start_filtering+0x5c/0x134
[<803de454>] dvb_dmxdev_start_feed+0xd4/0x158
[<803dff28>] dvb_dmxdev_filter_start+0x2b8/0x448
[<803e07ac>] dvb_demux_do_ioctl+0x2a0/0x654
[<803ddc8c>] dvb_usercopy+0x124/0x204
[<800d5284>] do_vfs_ioctl+0xa0/0x6c0
[<800d58e8>] sys_ioctl+0x44/0xa8
[<8000ecfc>] stack_done+0x20/0x40

On other boxes based on older SoCs (7401) this doesn't happen, so it looks like
a bug in the kernel specific to MIPS SMP. This issue has been reproduced on
several kernel versions from 2.6.18 to 3.1.0.

Since the base DMA address and the offsets are known, it is possible to map
the DMA addresses of the URB buffers directly in the driver. This workaround
fixes the problem and has been tested on both MIPS and x86 CPUs with success.

By the way, with this fix the driver works perfectly fine on the set-top-box:
both UHF and VHF frequencies are tuned without problems, and zapping is quite
fast. SNR and signal strength reports seems to work fine, too.

The only remaining problem (on both the PC and the set-top-box) is that after
a soft reboot the device is not recognized again by the kernel. It requires
a power cycle (or a manual unplug/replug) to be recognized again. So probably
the device state is not reset properly at shut-down.

Signed-off-by: Gianluca Gennari 
---
 drivers/staging/media/as102/as102_drv.c 
b/drivers/staging/media/as102/as102_usb_drv.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/media/as102/as102_drv.c 
b/drivers/staging/media/as102/as102_usb_drv.c
index d775be0..8d2c84c 100644
--- a/drivers/staging/media/as102/as102_usb_drv.c
+++ b/drivers/staging/media/as102/as102_usb_drv.c
@@ -270,6 +270,8 @@ static int as102_alloc_usb_stream_buffer(struct as102_dev_t 
*dev)
}
 
urb->transfer_buffer = dev->stream + (i * AS102_USB_BUF_SIZE);
+   urb->transfer_dma = dev->dma_addr + (i * AS102_USB_BUF_SIZE);
+   urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
urb->transfer_buffer_length = AS102_USB_BUF_SIZE;
 
dev->stream_urb[i] = urb;
-- 
1.7.0.4

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


[PATCH] media: i.MX27 camera: Add resizing support.

2012-02-14 Thread Javier Martin
If the attached video sensor cannot provide the
requested image size, try to use resizing engine
included in the eMMa-PrP IP.

This patch supports both averaging and bilinear
algorithms.

Signed-off-by: Javier Martin 
---
 drivers/media/video/mx2_camera.c |  251 +-
 1 files changed, 249 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 9e84368..6516ee4 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -204,10 +205,25 @@
 #define PRP_INTR_LBOVF (1 << 7)
 #define PRP_INTR_CH2OVF(1 << 8)
 
+/* Resizing registers */
+#define PRP_RZ_VALID_TBL_LEN(x)((x) << 24)
+#define PRP_RZ_VALID_BILINEAR  (1 << 31)
+
 #define mx27_camera_emma(pcdev)(cpu_is_mx27() && pcdev->use_emma)
 
 #define MAX_VIDEO_MEM  16
 
+#define RESIZE_NUM_MIN 1
+#define RESIZE_NUM_MAX 20
+#define BC_COEF3
+#define SZ_COEF(1 << BC_COEF)
+
+#define RESIZE_DIR_H   0
+#define RESIZE_DIR_V   1
+
+#define RESIZE_ALGO_BILINEAR 0
+#define RESIZE_ALGO_AVERAGING 1
+
 struct mx2_prp_cfg {
int channel;
u32 in_fmt;
@@ -217,6 +233,13 @@ struct mx2_prp_cfg {
u32 irq_flags;
 };
 
+/* prp resizing parameters */
+struct emma_prp_resize {
+   int algo; /* type of algorithm used */
+   int len; /* number of coefficients */
+   unsigned char   s[RESIZE_NUM_MAX]; /* table of coefficients */
+};
+
 /* prp configuration for a client-host fmt pair */
 struct mx2_fmt_cfg {
enum v4l2_mbus_pixelcodein_fmt;
@@ -278,6 +301,8 @@ struct mx2_camera_dev {
dma_addr_t  discard_buffer_dma;
size_t  discard_size;
struct mx2_fmt_cfg  *emma_prp;
+   struct emma_prp_resize  resizing[2];
+   unsigned ints_width, s_height;
u32 frame_count;
struct vb2_alloc_ctx*alloc_ctx;
 };
@@ -687,7 +712,7 @@ static void mx27_camera_emma_buf_init(struct 
soc_camera_device *icd,
struct mx2_camera_dev *pcdev = ici->priv;
struct mx2_fmt_cfg *prp = pcdev->emma_prp;
 
-   writel((icd->user_width << 16) | icd->user_height,
+   writel((pcdev->s_width << 16) | pcdev->s_height,
   pcdev->base_emma + PRP_SRC_FRAME_SIZE);
writel(prp->cfg.src_pixel,
   pcdev->base_emma + PRP_SRC_PIXEL_FORMAT_CNTL);
@@ -707,6 +732,74 @@ static void mx27_camera_emma_buf_init(struct 
soc_camera_device *icd,
writel(prp->cfg.irq_flags, pcdev->base_emma + PRP_INTR_CNTL);
 }
 
+static void mx2_prp_resize_commit(struct mx2_camera_dev *pcdev)
+{
+   int dir;
+
+   for (dir = RESIZE_DIR_H; dir <= RESIZE_DIR_V; dir++) {
+   unsigned char *s = pcdev->resizing[dir].s;
+   int len = pcdev->resizing[dir].len;
+   unsigned int coeff[2] = {0, 0};
+   unsigned int valid  = 0;
+   int i;
+
+   if (len == 0)
+   continue;
+
+   for (i = RESIZE_NUM_MAX - 1; i >= 0; i--) {
+   int j;
+
+   j = i > 9 ? 1 : 0;
+   coeff[j] = (coeff[j] << BC_COEF) |
+   (s[i] & (SZ_COEF - 1));
+
+   if (i == 5 || i == 15)
+   coeff[j] <<= 1;
+
+   valid = (valid << 1) | (s[i] >> BC_COEF);
+   }
+
+   valid |= PRP_RZ_VALID_TBL_LEN(len);
+
+   if (pcdev->resizing[dir].algo == RESIZE_ALGO_BILINEAR)
+   valid |= PRP_RZ_VALID_BILINEAR;
+
+   if (pcdev->emma_prp->cfg.channel == 1) {
+   if (dir == RESIZE_DIR_H) {
+   writel(coeff[0], pcdev->base_emma +
+   PRP_CH1_RZ_HORI_COEF1);
+   writel(coeff[1], pcdev->base_emma +
+   PRP_CH1_RZ_HORI_COEF2);
+   writel(valid, pcdev->base_emma +
+   PRP_CH1_RZ_HORI_VALID);
+   } else {
+   writel(coeff[0], pcdev->base_emma +
+   PRP_CH1_RZ_VERT_COEF1);
+   writel(coeff[1], pcdev->base_emma +
+   PRP_CH1_RZ_VERT_COEF2);
+   writel(valid, pcdev->base_emma +
+   PRP_CH1_RZ_VERT_VALID);
+   }
+   } else {
+   if (dir == RESIZE_DIR_H) {
+   writel(coeff[0], pcdev->base_emma +
+   

[PATCH] msm: rc: Add support for MSM GPIO based IR Receiver driver.

2012-02-14 Thread Ravi Kumar V
Adds GPIO based IR Receiver driver. It decodes signals using decoders
available in rc framework.

Change-Id: Ic8b6bf5f3e7b9ad8fc68f7940cdb00749016f53b
Signed-off-by: Ravi Kumar V 
---
 drivers/media/rc/Kconfig|9 ++
 drivers/media/rc/Makefile   |1 +
 drivers/media/rc/gpio-ir-recv.c |  189 +++
 include/media/gpio-ir-recv.h|   23 +
 4 files changed, 222 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/rc/gpio-ir-recv.c
 create mode 100644 include/media/gpio-ir-recv.h

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index aeb7f43..6f63ded 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -256,4 +256,13 @@ config RC_LOOPBACK
   To compile this driver as a module, choose M here: the module will
   be called rc_loopback.
 
+config IR_GPIO_CIR
+   tristate "GPIO IR remote control"
+   depends on RC_CORE
+   ---help---
+  Say Y if you want to use GPIO based IR Receiver.
+
+  To compile this driver as a module, choose M here: the module will
+  be called gpio-ir-recv.
+
 endif #RC_CORE
diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile
index 2156e78..9b3568e 100644
--- a/drivers/media/rc/Makefile
+++ b/drivers/media/rc/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_IR_REDRAT3) += redrat3.o
 obj-$(CONFIG_IR_STREAMZAP) += streamzap.o
 obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o
 obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o
+obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c
new file mode 100644
index 000..cf6e7f6
--- /dev/null
+++ b/drivers/media/rc/gpio-ir-recv.c
@@ -0,0 +1,189 @@
+/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GPIO_IR_DRIVER_NAME"gpio-rc-recv"
+#define GPIO_IR_DEVICE_NAME"gpio_ir_recv"
+
+struct gpio_rc_dev {
+   struct rc_dev *rcdev;
+   struct mutex lock;
+   unsigned int gpio_nr;
+   bool active_low;
+   bool can_wakeup;
+};
+
+static irqreturn_t gpio_ir_recv_irq(int irq, void *dev_id)
+{
+   struct gpio_rc_dev *gpio_dev = dev_id;
+   unsigned int gval;
+   int rc = 0;
+   enum raw_event_type type = IR_SPACE;
+
+   mutex_lock(&gpio_dev->lock);
+   gval = gpio_get_value_cansleep(gpio_dev->gpio_nr);
+
+   if (gval < 0)
+   goto err_get_value;
+
+   if (gpio_dev->active_low)
+   gval = !gval;
+
+   if (gval == 1)
+   type = IR_PULSE;
+
+   rc = ir_raw_event_store_edge(gpio_dev->rcdev, type);
+   if (rc < 0)
+   goto err_get_value;
+
+   ir_raw_event_handle(gpio_dev->rcdev);
+
+err_get_value:
+   mutex_unlock(&gpio_dev->lock);
+
+   return IRQ_HANDLED;
+}
+
+static int __devinit gpio_ir_recv_probe(struct platform_device *pdev)
+{
+   struct gpio_rc_dev *gpio_dev;
+   struct rc_dev *rcdev;
+   const struct gpio_ir_recv_platform_data *pdata =
+   pdev->dev.platform_data;
+   int rc;
+
+   if (!pdata)
+   return -EINVAL;
+
+   if (pdata->gpio_nr < 0)
+   return -EINVAL;
+
+   gpio_dev = kzalloc(sizeof(struct gpio_rc_dev), GFP_KERNEL);
+   if (!gpio_dev)
+   return -ENOMEM;
+
+   mutex_init(&gpio_dev->lock);
+
+   rcdev = rc_allocate_device();
+   if (!rcdev) {
+   rc = -ENOMEM;
+   goto err_allocate_device;
+   }
+
+   rcdev->driver_type = RC_DRIVER_IR_RAW;
+   rcdev->allowed_protos = RC_TYPE_NEC;
+   rcdev->input_name = GPIO_IR_DEVICE_NAME;
+   rcdev->input_id.bustype = BUS_HOST;
+   rcdev->driver_name = GPIO_IR_DRIVER_NAME;
+   rcdev->map_name = RC_MAP_EMPTY;
+
+   gpio_dev->rcdev = rcdev;
+   gpio_dev->gpio_nr = pdata->gpio_nr;
+   gpio_dev->active_low = pdata->active_low;
+   gpio_dev->can_wakeup = pdata->can_wakeup;
+
+
+   rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv");
+   if (rc < 0)
+   goto err_gpio_request;
+   rc  = gpio_direction_input(pdata->gpio_nr);
+   if (rc < 0)
+   goto err_gpio_direction_input;
+
+   rc = rc_register_device(rcdev);
+   if (rc < 0) {
+   dev_err(&pdev->dev, "failed to register rc device\n");
+   goto err_register_rc_device;
+   }

[PATCH] Add support for MSM GPIO IR receiver driver

2012-02-14 Thread Ravi Kumar V
This driver is for GPIO based IR receivers, it can listen only to IR receiver 
modules which gives demodulated signal as output, this driver only passes the 
interrupt events to rc framework where pulse and space widths are calculated 
and input to decoders avaliable.

Ravi Kumar V (1):
  msm: rc: Add support for MSM GPIO based IR Receiver driver.

 drivers/media/rc/Kconfig|9 ++
 drivers/media/rc/Makefile   |1 +
 drivers/media/rc/gpio-ir-recv.c |  189 +++
 include/media/gpio-ir-recv.h|   23 +
 4 files changed, 222 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/rc/gpio-ir-recv.c
 create mode 100644 include/media/gpio-ir-recv.h

-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
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: [PATCHv21 10/16] mm: Serialize access to min_free_kbytes

2012-02-14 Thread KAMEZAWA Hiroyuki
On Fri, 10 Feb 2012 18:32:25 +0100
Marek Szyprowski  wrote:

> From: Mel Gorman 
> 
> There is a race between the min_free_kbytes sysctl, memory hotplug
> and transparent hugepage support enablement.  Memory hotplug uses a
> zonelists_mutex to avoid a race when building zonelists. Reuse it to
> serialise watermark updates.
> 
> [a.p.zijls...@chello.nl: Older patch fixed the race with spinlock]
> Signed-off-by: Mel Gorman 
> Signed-off-by: Marek Szyprowski 

At linux-next, conflicted with "mm: add extra free kbytes tunable"

To the logic,
Reviewed-by: KAMEZAWA Hiroyuki 

--
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: [PATCHv21 09/16] mm: page_isolation: MIGRATE_CMA isolation functions added

2012-02-14 Thread KAMEZAWA Hiroyuki
On Fri, 10 Feb 2012 18:32:24 +0100
Marek Szyprowski  wrote:

> From: Michal Nazarewicz 
> 
> This commit changes various functions that change pages and
> pageblocks migrate type between MIGRATE_ISOLATE and
> MIGRATE_MOVABLE in such a way as to allow to work with
> MIGRATE_CMA migrate type.
> 
> Signed-off-by: Michal Nazarewicz 
> Signed-off-by: Marek Szyprowski 
> Tested-by: Rob Clark 
> Tested-by: Ohad Ben-Cohen 
> Tested-by: Benjamin Gaignard 

Reviewed-by: KAMEZAWA Hiroyuki 

--
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: [PATCHv21 08/16] mm: mmzone: MIGRATE_CMA migration type added

2012-02-14 Thread KAMEZAWA Hiroyuki
On Fri, 10 Feb 2012 18:32:23 +0100
Marek Szyprowski  wrote:

> From: Michal Nazarewicz 
> 
> The MIGRATE_CMA migration type has two main characteristics:
> (i) only movable pages can be allocated from MIGRATE_CMA
> pageblocks and (ii) page allocator will never change migration
> type of MIGRATE_CMA pageblocks.
> 
> This guarantees (to some degree) that page in a MIGRATE_CMA page
> block can always be migrated somewhere else (unless there's no
> memory left in the system).
> 
> It is designed to be used for allocating big chunks (eg. 10MiB)
> of physically contiguous memory.  Once driver requests
> contiguous memory, pages from MIGRATE_CMA pageblocks may be
> migrated away to create a contiguous block.
> 
> To minimise number of migrations, MIGRATE_CMA migration type
> is the last type tried when page allocator falls back to other
> migration types when requested.
> 
> Signed-off-by: Michal Nazarewicz 
> Signed-off-by: Marek Szyprowski 
> Signed-off-by: Kyungmin Park 
> Acked-by: Mel Gorman 
> Tested-by: Rob Clark 
> Tested-by: Ohad Ben-Cohen 
> Tested-by: Benjamin Gaignard 

Reviewed-by: KAMEZAWA Hiroyuki 

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