The patch number 8172 was added via Mauro Carvalho Chehab <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [EMAIL PROTECTED]

------

From: Mauro Carvalho Chehab  <[EMAIL PROTECTED]>
merge: http://www.linuxtv.org/hg/~hverkuil/v4l-dvb




Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>


---

 linux/Documentation/video4linux/cx18.txt          |   36 ++----
 linux/drivers/media/video/cx18/cx18-audio.c       |   15 ++
 linux/drivers/media/video/cx18/cx18-av-audio.c    |   12 +-
 linux/drivers/media/video/cx18/cx18-av-core.c     |   77 +-------------
 linux/drivers/media/video/cx18/cx18-av-core.h     |   13 --
 linux/drivers/media/video/cx18/cx18-av-firmware.c |   62 +++++++----
 linux/drivers/media/video/cx18/cx18-av-vbi.c      |   27 ++--
 linux/drivers/media/video/cx18/cx18-cards.c       |   34 +++---
 linux/drivers/media/video/cx18/cx18-driver.c      |    8 +
 linux/drivers/media/video/cx18/cx18-firmware.c    |    5 
 linux/drivers/media/video/cx18/cx18-mailbox.c     |    1 
 linux/drivers/media/video/cx18/cx23418.h          |    5 
 linux/drivers/media/video/ivtv/ivtv-driver.c      |    6 +
 linux/drivers/media/video/ivtv/ivtv-streams.c     |    4 
 v4l2-apps/util/v4l2-ctl.cpp                       |   16 ++
 v4l2-apps/util/v4l2-dbg.cpp                       |    2 
 16 files changed, 149 insertions(+), 174 deletions(-)

diff -r 1022101ca34c -r 682760d4b111 linux/Documentation/video4linux/cx18.txt
--- a/linux/Documentation/video4linux/cx18.txt  Tue Jul 01 01:06:22 2008 -0300
+++ b/linux/Documentation/video4linux/cx18.txt  Tue Jul 01 17:16:09 2008 -0300
@@ -1,36 +1,30 @@ Some notes regarding the cx18 driver for
 Some notes regarding the cx18 driver for the Conexant CX23418 MPEG
 encoder chip:
 
-1) The only hardware currently supported is the Hauppauge HVR-1600
-   card and the Compro VideoMate H900 (note that this card only
-   supports analog input, it has no digital tuner!).
+1) Currently supported are:
 
-2) Some people have problems getting the i2c bus to work. Cause unknown.
+       - Hauppauge HVR-1600
+       - Compro VideoMate H900
+       - Yuan MPC718
+       - Conexant Raptor PAL/SECAM devkit
+
+2) Some people have problems getting the i2c bus to work.
    The symptom is that the eeprom cannot be read and the card is
-   unusable.
+   unusable. This is probably fixed, but if you have problems
+   then post to the video4linux or ivtv-users mailinglist.
 
-3) The audio from the analog tuner is mono only. Probably caused by
-   incorrect audio register information in the datasheet. We are
-   waiting for updated information from Conexant.
+3) VBI (raw or sliced) has not yet been implemented.
 
-4) VBI (raw or sliced) has not yet been implemented.
+4) MPEG indexing is not yet implemented.
 
-5) MPEG indexing is not yet implemented.
-
-6) The driver is still a bit rough around the edges, this should
+5) The driver is still a bit rough around the edges, this should
    improve over time.
 
 
 Firmware:
 
-The firmware needs to be extracted from the Windows Hauppauge HVR-1600
-driver, available here:
+You can obtain the firmware files here:
 
-http://hauppauge.lightpath.net/software/install_cd/hauppauge_cd_3.4d1.zip
+http://dl.ivtvdriver.org/ivtv/firmware/cx18-firmware.tar.gz
 
-Unzip, then copy the following files to the firmware directory
-and rename them as follows:
-
-Drivers/Driver18/hcw18apu.rom -> v4l-cx23418-apu.fw
-Drivers/Driver18/hcw18enc.rom -> v4l-cx23418-cpu.fw
-Drivers/Driver18/hcw18mlC.rom -> v4l-cx23418-dig.fw
+Untar and copy the .fw files to your firmware directory.
diff -r 1022101ca34c -r 682760d4b111 linux/drivers/media/video/cx18/cx18-audio.c
--- a/linux/drivers/media/video/cx18/cx18-audio.c       Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-audio.c       Tue Jul 01 17:16:09 
2008 -0300
@@ -26,13 +26,17 @@
 #include "cx18-cards.h"
 #include "cx18-audio.h"
 
+#define CX18_AUDIO_ENABLE 0xc72014
+
 /* Selects the audio input and output according to the current
    settings. */
 int cx18_audio_set_io(struct cx18 *cx)
 {
        struct v4l2_routing route;
        u32 audio_input;
+       u32 val;
        int mux_input;
+       int err;
 
        /* Determine which input to use */
        if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) {
@@ -51,8 +55,17 @@ int cx18_audio_set_io(struct cx18 *cx)
        cx18_i2c_hw(cx, cx->card->hw_muxer, VIDIOC_INT_S_AUDIO_ROUTING, &route);
 
        route.input = audio_input;
-       return cx18_i2c_hw(cx, cx->card->hw_audio_ctrl,
+       err = cx18_i2c_hw(cx, cx->card->hw_audio_ctrl,
                        VIDIOC_INT_S_AUDIO_ROUTING, &route);
+       if (err)
+               return err;
+
+       val = read_reg(CX18_AUDIO_ENABLE) & ~0x30;
+       val |= (audio_input > CX18_AV_AUDIO_SERIAL2) ? 0x20 :
+                                       (audio_input << 4);
+       write_reg(val | 0xb00, CX18_AUDIO_ENABLE);
+       cx18_vapi(cx, CX18_APU_RESETAI, 1, 0);
+       return 0;
 }
 
 void cx18_audio_set_route(struct cx18 *cx, struct v4l2_routing *route)
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/cx18/cx18-av-audio.c
--- a/linux/drivers/media/video/cx18/cx18-av-audio.c    Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-audio.c    Tue Jul 01 17:16:09 
2008 -0300
@@ -34,7 +34,7 @@ static int set_audclk_freq(struct cx18 *
        /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
        cx18_av_write(cx, 0x127, 0x50);
 
-       if (state->aud_input != CX18_AV_AUDIO_SERIAL) {
+       if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
                switch (freq) {
                case 32000:
                        /* VID_PLL and AUX_PLL */
@@ -148,7 +148,7 @@ void cx18_av_audio_set_path(struct cx18 
        /* Mute everything to prevent the PFFT! */
        cx18_av_write(cx, 0x8d3, 0x1f);
 
-       if (state->aud_input == CX18_AV_AUDIO_SERIAL) {
+       if (state->aud_input <= CX18_AV_AUDIO_SERIAL2) {
                /* Set Path1 to Serial Audio Input */
                cx18_av_write4(cx, 0x8d0, 0x01011012);
 
@@ -165,7 +165,7 @@ void cx18_av_audio_set_path(struct cx18 
        /* deassert soft reset */
        cx18_av_and_or(cx, 0x810, ~0x1, 0x00);
 
-       if (state->aud_input != CX18_AV_AUDIO_SERIAL) {
+       if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
                /* When the microcontroller detects the
                 * audio format, it will unmute the lines */
                cx18_av_and_or(cx, 0x803, ~0x10, 0x10);
@@ -271,7 +271,7 @@ static void set_mute(struct cx18 *cx, in
 {
        struct cx18_av_state *state = &cx->av_state;
 
-       if (state->aud_input != CX18_AV_AUDIO_SERIAL) {
+       if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
                /* Must turn off microcontroller in order to mute sound.
                 * Not sure if this is the best method, but it does work.
                 * If the microcontroller is running, then it will undo any
@@ -298,14 +298,14 @@ int cx18_av_audio(struct cx18 *cx, unsig
 
        switch (cmd) {
        case VIDIOC_INT_AUDIO_CLOCK_FREQ:
-               if (state->aud_input != CX18_AV_AUDIO_SERIAL) {
+               if (state->aud_input > CX18_AV_AUDIO_SERIAL2) {
                        cx18_av_and_or(cx, 0x803, ~0x10, 0);
                        cx18_av_write(cx, 0x8d3, 0x1f);
                }
                cx18_av_and_or(cx, 0x810, ~0x1, 1);
                retval = set_audclk_freq(cx, *(u32 *)arg);
                cx18_av_and_or(cx, 0x810, ~0x1, 0);
-               if (state->aud_input != CX18_AV_AUDIO_SERIAL)
+               if (state->aud_input > CX18_AV_AUDIO_SERIAL2)
                        cx18_av_and_or(cx, 0x803, ~0x10, 0x10);
                return retval;
 
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/cx18/cx18-av-core.c
--- a/linux/drivers/media/video/cx18/cx18-av-core.c     Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-core.c     Tue Jul 01 17:16:09 
2008 -0300
@@ -69,58 +69,6 @@ int cx18_av_and_or4(struct cx18 *cx, u16
                             or_value);
 }
 
-int cx18_av_write_no_acfg(struct cx18 *cx, u16 addr, u8 value, int 
no_acfg_mask)
-{
-       int retval;
-       u32 saved_reg[8] = {0};
-
-       if (no_acfg_mask & CXADEC_NO_ACFG_AFE) {
-               saved_reg[0] = cx18_av_read4(cx, CXADEC_CHIP_CTRL);
-               saved_reg[1] = cx18_av_read4(cx, CXADEC_AFE_CTRL);
-       }
-
-       if (no_acfg_mask & CXADEC_NO_ACFG_PLL) {
-               saved_reg[2] = cx18_av_read4(cx, CXADEC_PLL_CTRL1);
-               saved_reg[3] = cx18_av_read4(cx, CXADEC_VID_PLL_FRAC);
-       }
-
-       if (no_acfg_mask & CXADEC_NO_ACFG_VID) {
-               saved_reg[4] = cx18_av_read4(cx, CXADEC_HORIZ_TIM_CTRL);
-               saved_reg[5] = cx18_av_read4(cx, CXADEC_VERT_TIM_CTRL);
-               saved_reg[6] = cx18_av_read4(cx, CXADEC_SRC_COMB_CFG);
-               saved_reg[7] = cx18_av_read4(cx, CXADEC_CHROMA_VBIOFF_CFG);
-       }
-
-       retval = cx18_av_write(cx, addr, value);
-
-       if (no_acfg_mask & CXADEC_NO_ACFG_AFE) {
-               cx18_av_write4(cx, CXADEC_CHIP_CTRL, saved_reg[0]);
-               cx18_av_write4(cx, CXADEC_AFE_CTRL,  saved_reg[1]);
-       }
-
-       if (no_acfg_mask & CXADEC_NO_ACFG_PLL) {
-               cx18_av_write4(cx, CXADEC_PLL_CTRL1,    saved_reg[2]);
-               cx18_av_write4(cx, CXADEC_VID_PLL_FRAC, saved_reg[3]);
-       }
-
-       if (no_acfg_mask & CXADEC_NO_ACFG_VID) {
-               cx18_av_write4(cx, CXADEC_HORIZ_TIM_CTRL,    saved_reg[4]);
-               cx18_av_write4(cx, CXADEC_VERT_TIM_CTRL,     saved_reg[5]);
-               cx18_av_write4(cx, CXADEC_SRC_COMB_CFG,      saved_reg[6]);
-               cx18_av_write4(cx, CXADEC_CHROMA_VBIOFF_CFG, saved_reg[7]);
-       }
-
-       return retval;
-}
-
-int cx18_av_and_or_no_acfg(struct cx18 *cx, u16 addr, unsigned and_mask,
-                          u8 or_value, int no_acfg_mask)
-{
-       return cx18_av_write_no_acfg(cx, addr,
-                                    (cx18_av_read(cx, addr) & and_mask) |
-                                    or_value, no_acfg_mask);
-}
-
 /* ----------------------------------------------------------------------- */
 
 static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input,
@@ -221,16 +169,9 @@ static void input_change(struct cx18 *cx
        v4l2_std_id std = state->std;
 
        /* Follow step 8c and 8d of section 3.16 in the cx18_av datasheet */
-       if (std & V4L2_STD_SECAM)
-               cx18_av_write_no_acfg(cx, 0x402, 0, CXADEC_NO_ACFG_ALL);
-       else {
-               cx18_av_write_no_acfg(cx, 0x402, 0x04, CXADEC_NO_ACFG_ALL);
-               cx18_av_write(cx, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11);
-       }
-       cx18_av_and_or_no_acfg(cx, 0x401, ~0x60, 0,
-                               CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID);
-       cx18_av_and_or_no_acfg(cx, 0x401, ~0x60, 0x60,
-                               CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID);
+       cx18_av_write(cx, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11);
+       cx18_av_and_or(cx, 0x401, ~0x60, 0);
+       cx18_av_and_or(cx, 0x401, ~0x60, 0x60);
 
        if (std & V4L2_STD_525_60) {
                if (std == V4L2_STD_NTSC_M_JP) {
@@ -300,7 +241,8 @@ static int set_input(struct cx18 *cx, en
        }
 
        switch (aud_input) {
-       case CX18_AV_AUDIO_SERIAL:
+       case CX18_AV_AUDIO_SERIAL1:
+       case CX18_AV_AUDIO_SERIAL2:
                /* do nothing, use serial audio input */
                break;
        case CX18_AV_AUDIO4: reg &= ~0x30; break;
@@ -316,8 +258,7 @@ static int set_input(struct cx18 *cx, en
 
        cx18_av_write(cx, 0x103, reg);
        /* Set INPUT_MODE to Composite (0) or S-Video (1) */
-       cx18_av_and_or_no_acfg(cx, 0x401, ~0x6, is_composite ? 0 : 0x02,
-                               CXADEC_NO_ACFG_PLL | CXADEC_NO_ACFG_VID);
+       cx18_av_and_or(cx, 0x401, ~0x6, is_composite ? 0 : 0x02);
        /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */
        cx18_av_and_or(cx, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0);
        /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */
@@ -373,12 +314,12 @@ static int set_v4lstd(struct cx18 *cx)
           This happens for example with the Yuan MPC622. */
        if (fmt >= 4 && fmt < 8) {
                /* Set format to NTSC-M */
-               cx18_av_and_or_no_acfg(cx, 0x400, ~0xf, 1, CXADEC_NO_ACFG_AFE);
+               cx18_av_and_or(cx, 0x400, ~0xf, 1);
                /* Turn off LCOMB */
                cx18_av_and_or(cx, 0x47b, ~6, 0);
        }
-       cx18_av_and_or_no_acfg(cx, 0x400, ~0xf, fmt, CXADEC_NO_ACFG_AFE);
-       cx18_av_and_or_no_acfg(cx, 0x403, ~0x3, pal_m, CXADEC_NO_ACFG_ALL);
+       cx18_av_and_or(cx, 0x400, ~0x2f, fmt | 0x20);
+       cx18_av_and_or(cx, 0x403, ~0x3, pal_m);
        cx18_av_vbi_setup(cx);
        input_change(cx);
        return 0;
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/cx18/cx18-av-core.h
--- a/linux/drivers/media/video/cx18/cx18-av-core.h     Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-core.h     Tue Jul 01 17:16:09 
2008 -0300
@@ -62,7 +62,8 @@ enum cx18_av_video_input {
 
 enum cx18_av_audio_input {
        /* Audio inputs: serial or In4-In8 */
-       CX18_AV_AUDIO_SERIAL,
+       CX18_AV_AUDIO_SERIAL1,
+       CX18_AV_AUDIO_SERIAL2,
        CX18_AV_AUDIO4 = 4,
        CX18_AV_AUDIO5,
        CX18_AV_AUDIO6,
@@ -295,24 +296,14 @@ struct cx18_av_state {
 #define CXADEC_SELECT_AUDIO_STANDARD_FM    0xF9  /* FM radio */
 #define CXADEC_SELECT_AUDIO_STANDARD_AUTO  0xFF  /* Auto detect */
 
-/* Flags on what to preserve on write to 0x400-0x403 with 
cx18_av_.*_no_acfg()*/
-#define CXADEC_NO_ACFG_AFE     0x01 /* Preserve 0x100-0x107 */
-#define CXADEC_NO_ACFG_PLL     0x02 /* Preserve 0x108-0x10f */
-#define CXADEC_NO_ACFG_VID     0x04 /* Preserve 0x470-0x47f */
-#define CXADEC_NO_ACFG_ALL     0x07
-
 /* ----------------------------------------------------------------------- */
 /* cx18_av-core.c                                                         */
 int cx18_av_write(struct cx18 *cx, u16 addr, u8 value);
 int cx18_av_write4(struct cx18 *cx, u16 addr, u32 value);
-int cx18_av_write_no_acfg(struct cx18 *cx, u16 addr, u8 value,
-                               int no_acfg_mask);
 u8 cx18_av_read(struct cx18 *cx, u16 addr);
 u32 cx18_av_read4(struct cx18 *cx, u16 addr);
 int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value);
 int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value);
-int cx18_av_and_or_no_acfg(struct cx18 *cx, u16 addr, unsigned mask, u8 value,
-                               int no_acfg_mask);
 int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg);
 
 /* ----------------------------------------------------------------------- */
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/cx18/cx18-av-firmware.c
--- a/linux/drivers/media/video/cx18/cx18-av-firmware.c Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-firmware.c Tue Jul 01 17:16:09 
2008 -0300
@@ -22,6 +22,7 @@
 #include "cx18-driver.h"
 #include <linux/firmware.h>
 
+#define CX18_AUDIO_ENABLE 0xc72014
 #define FWFILE "v4l-cx23418-dig.fw"
 
 int cx18_av_loadfw(struct cx18 *cx)
@@ -31,40 +32,58 @@ int cx18_av_loadfw(struct cx18 *cx)
        u32 v;
        u8 *ptr;
        int i;
+       int retries = 0;
 
        if (request_firmware(&fw, FWFILE, &cx->dev->dev) != 0) {
                CX18_ERR("unable to open firmware %s\n", FWFILE);
                return -EINVAL;
        }
 
-       cx18_av_write4(cx, CXADEC_CHIP_CTRL, 0x00010000);
-       cx18_av_write(cx, CXADEC_STD_DET_CTL, 0xf6); /* Byte 0 */
+       /* The firmware load often has byte errors, so allow for several
+          retries, both at byte level and at the firmware load level. */
+       while (retries < 5) {
+               cx18_av_write4(cx, CXADEC_CHIP_CTRL, 0x00010000);
+               cx18_av_write(cx, CXADEC_STD_DET_CTL, 0xf6);
 
-       /* Reset the Mako core (Register is undocumented.) */
-       cx18_av_write4(cx, 0x8100, 0x00010000);
+               /* Reset the Mako core (Register is undocumented.) */
+               cx18_av_write4(cx, 0x8100, 0x00010000);
 
-       /* Put the 8051 in reset and enable firmware upload */
-       cx18_av_write4(cx, CXADEC_DL_CTL, 0x0F000000);
+               /* Put the 8051 in reset and enable firmware upload */
+               cx18_av_write4(cx, CXADEC_DL_CTL, 0x0F000000);
 
-       ptr = fw->data;
-       size = fw->size;
+               ptr = fw->data;
+               size = fw->size;
 
-       for (i = 0; i < size; i++) {
-               u32 dl_control = 0x0F000000 | ((u32)ptr[i] << 16);
-               u32 value = 0;
-               int retries;
+               for (i = 0; i < size; i++) {
+                       u32 dl_control = 0x0F000000 | i | ((u32)ptr[i] << 16);
+                       u32 value = 0;
+                       int retries;
 
-               for (retries = 0; retries < 5; retries++) {
-                       cx18_av_write4(cx, CXADEC_DL_CTL, dl_control);
-                       value = cx18_av_read4(cx, CXADEC_DL_CTL);
-                       if ((value & 0x3F00) == (dl_control & 0x3F00))
+                       for (retries = 0; retries < 5; retries++) {
+                               cx18_av_write4(cx, CXADEC_DL_CTL, dl_control);
+                               udelay(10);
+                               value = cx18_av_read4(cx, CXADEC_DL_CTL);
+                               if (value == dl_control)
+                                       break;
+                               /* Check if we can correct the byte by changing
+                                  the address.  We can only write the lower
+                                  address byte of the address. */
+                               if ((value & 0x3F00) != (dl_control & 0x3F00)) {
+                                       retries = 5;
+                                       break;
+                               }
+                       }
+                       if (retries >= 5)
                                break;
                }
-               if (retries >= 5) {
-                       CX18_ERR("unable to load firmware %s\n", FWFILE);
-                       release_firmware(fw);
-                       return -EIO;
-               }
+               if (i == size)
+                       break;
+               retries++;
+       }
+       if (retries >= 5) {
+               CX18_ERR("unable to load firmware %s\n", FWFILE);
+               release_firmware(fw);
+               return -EIO;
        }
 
        cx18_av_write4(cx, CXADEC_DL_CTL, 0x13000000 | fw->size);
@@ -100,7 +119,6 @@ int cx18_av_loadfw(struct cx18 *cx)
           have a name in the spec. */
        cx18_av_write4(cx, 0x09CC, 1);
 
-#define CX18_AUDIO_ENABLE              0xc72014
        v = read_reg(CX18_AUDIO_ENABLE);
        /* If bit 11 is 1 */
        if (v & 0x800)
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/cx18/cx18-av-vbi.c
--- a/linux/drivers/media/video/cx18/cx18-av-vbi.c      Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-vbi.c      Tue Jul 01 17:16:09 
2008 -0300
@@ -108,18 +108,18 @@ void cx18_av_vbi_setup(struct cx18 *cx)
                src_decimation = 0x21f;
 
                luma_lpf = 2;
-               if (std & V4L2_STD_SECAM) {
+               if (std & V4L2_STD_PAL) {
+                       uv_lpf = 1;
+                       comb = 0x20;
+                       sc = 0x0a8263;
+               } else if (std == V4L2_STD_PAL_Nc) {
+                       uv_lpf = 1;
+                       comb = 0x20;
+                       sc = 0x087da5;
+               } else { /* SECAM */
                        uv_lpf = 0;
                        comb = 0;
                        sc = 0x0a425f;
-               } else if (std == V4L2_STD_PAL_Nc) {
-                       uv_lpf = 1;
-                       comb = 0x20;
-                       sc = 556453;
-               } else {
-                       uv_lpf = 1;
-                       comb = 0x20;
-                       sc = 0x0a8263;
                }
        } else {
                hactive = 720;
@@ -127,25 +127,20 @@ void cx18_av_vbi_setup(struct cx18 *cx)
                vactive = 487;
                luma_lpf = 1;
                uv_lpf = 1;
+               vblank = 26;
+               vblank656 = 26;
 
                src_decimation = 0x21f;
                if (std == V4L2_STD_PAL_60) {
-                       vblank = 26;
-                       vblank656 = 26;
                        burst = 0x5b;
                        luma_lpf = 2;
                        comb = 0x20;
                        sc = 0x0a8263;
                } else if (std == V4L2_STD_PAL_M) {
-                       vblank = 20;
-                       vblank656 = 24;
                        burst = 0x61;
                        comb = 0x20;
-
                        sc = 555452;
                } else {
-                       vblank = 26;
-                       vblank656 = 26;
                        burst = 0x5b;
                        comb = 0x66;
                        sc = 556063;
diff -r 1022101ca34c -r 682760d4b111 linux/drivers/media/video/cx18/cx18-cards.c
--- a/linux/drivers/media/video/cx18/cx18-cards.c       Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-cards.c       Tue Jul 01 17:16:09 
2008 -0300
@@ -67,12 +67,12 @@ static const struct cx18_card cx18_card_
                { CX18_CARD_INPUT_AUD_TUNER,
                  CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
                { CX18_CARD_INPUT_LINE_IN1,
-                 CX18_AV_AUDIO_SERIAL, CS5345_IN_2 },
+                 CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
                { CX18_CARD_INPUT_LINE_IN2,
-                 CX18_AV_AUDIO_SERIAL, CS5345_IN_3 },
+                 CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
        },
        .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
-                        CX18_AV_AUDIO_SERIAL, CS5345_IN_4 },
+                        CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
        .ddr = {
                /* ESMT M13S128324A-5B memory */
                .chip_config = 0x003,
@@ -112,12 +112,12 @@ static const struct cx18_card cx18_card_
                { CX18_CARD_INPUT_AUD_TUNER,
                  CX18_AV_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 },
                { CX18_CARD_INPUT_LINE_IN1,
-                 CX18_AV_AUDIO_SERIAL, CS5345_IN_2 },
+                 CX18_AV_AUDIO_SERIAL1, CS5345_IN_2 },
                { CX18_CARD_INPUT_LINE_IN2,
-                 CX18_AV_AUDIO_SERIAL, CS5345_IN_3 },
+                 CX18_AV_AUDIO_SERIAL1, CS5345_IN_3 },
        },
        .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
-                        CX18_AV_AUDIO_SERIAL, CS5345_IN_4 },
+                        CX18_AV_AUDIO_SERIAL1, CS5345_IN_4 },
        .ddr = {
                /* Samsung K4D263238G-VC33 memory */
                .chip_config = 0x003,
@@ -163,10 +163,10 @@ static const struct cx18_card cx18_card_
                { CX18_CARD_INPUT_AUD_TUNER,
                  CX18_AV_AUDIO8, 0 },
                { CX18_CARD_INPUT_LINE_IN1,
-                 CX18_AV_AUDIO_SERIAL, 0 },
+                 CX18_AV_AUDIO_SERIAL1, 0 },
        },
        .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
-                        CX18_AV_AUDIO_SERIAL, 0 },
+                        CX18_AV_AUDIO_SERIAL1, 0 },
        .tuners = {
                { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
        },
@@ -211,11 +211,11 @@ static const struct cx18_card cx18_card_
                { CX18_CARD_INPUT_COMPOSITE3, 2, CX18_AV_COMPOSITE3 },
        },
        .audio_inputs = {
-               { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,       0 },
-               { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL, 0 },
-               { CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL, 0 },
-       },
-       .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL, 0 },
+               { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
+               { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 0 },
+               { CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL1, 0 },
+       },
+       .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 0 },
        .tuners = {
                /* XC3028 tuner */
                { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
@@ -261,14 +261,14 @@ static const struct cx18_card cx18_card_
                { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
        },
        .audio_inputs = {
-               { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL, 0 },
-               { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL, 1 },
-               { CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL, 1 },
+               { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO5,        0 },
+               { CX18_CARD_INPUT_LINE_IN1,  CX18_AV_AUDIO_SERIAL1, 1 },
+               { CX18_CARD_INPUT_LINE_IN2,  CX18_AV_AUDIO_SERIAL2, 1 },
        },
        .tuners = {
                { .std = V4L2_STD_PAL_SECAM, .tuner = 
TUNER_PHILIPS_FM1216ME_MK3 },
        },
-       .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL, 2 },
+       .radio_input = { CX18_CARD_INPUT_AUD_TUNER, CX18_AV_AUDIO_SERIAL1, 2 },
        .ddr = {
                /* MT 46V16M16 memory */
                .chip_config = 0x50306,
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/cx18/cx18-driver.c
--- a/linux/drivers/media/video/cx18/cx18-driver.c      Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-driver.c      Tue Jul 01 17:16:09 
2008 -0300
@@ -436,7 +436,7 @@ static int __devinit cx18_init_struct1(s
                (cx->params.video_temporal_filter_mode << 1) |
                (cx->params.video_median_filter_type << 2);
        cx->params.port = CX2341X_PORT_MEMORY;
-       cx->params.capabilities = 0;
+       cx->params.capabilities = CX2341X_CAP_HAS_TS;
        init_waitqueue_head(&cx->cap_w);
        init_waitqueue_head(&cx->mb_apu_waitq);
        init_waitqueue_head(&cx->mb_cpu_waitq);
@@ -722,6 +722,12 @@ static int __devinit cx18_probe(struct p
        /* if no tuner was found, then pick the first tuner in the card list */
        if (cx->options.tuner == -1 && cx->card->tuners[0].std) {
                cx->std = cx->card->tuners[0].std;
+               if (cx->std & V4L2_STD_PAL)
+                       cx->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H;
+               else if (cx->std & V4L2_STD_NTSC)
+                       cx->std = V4L2_STD_NTSC_M;
+               else if (cx->std & V4L2_STD_SECAM)
+                       cx->std = V4L2_STD_SECAM_L;
                cx->options.tuner = cx->card->tuners[0].tuner;
        }
        if (cx->options.radio == -1)
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/cx18/cx18-firmware.c
--- a/linux/drivers/media/video/cx18/cx18-firmware.c    Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-firmware.c    Tue Jul 01 17:16:09 
2008 -0300
@@ -41,9 +41,6 @@
 
 #define CX18_REG_BUS_TIMEOUT_EN        0xc72024
 
-#define CX18_AUDIO_ENABLE              0xc72014
-#define CX18_REG_BUS_TIMEOUT_EN        0xc72024
-
 #define CX18_FAST_CLOCK_PLL_INT        0xc78000
 #define CX18_FAST_CLOCK_PLL_FRAC       0xc78004
 #define CX18_FAST_CLOCK_PLL_POST       0xc78008
@@ -90,7 +87,7 @@
 #define CX18_DSP0_INTERRUPT_MASK       0xd0004C
 
 /* Encoder/decoder firmware sizes */
-#define CX18_FW_CPU_SIZE               (174716)
+#define CX18_FW_CPU_SIZE               (158332)
 #define CX18_FW_APU_SIZE               (141200)
 
 #define APU_ROM_SYNC1 0x6D676553 /* "mgeS" */
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/cx18/cx18-mailbox.c
--- a/linux/drivers/media/video/cx18/cx18-mailbox.c     Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-mailbox.c     Tue Jul 01 17:16:09 
2008 -0300
@@ -81,6 +81,7 @@ static const struct cx18_api_info api_in
        API_ENTRY(CPU, CX18_CPU_GET_ENC_PTS,                    0),
        API_ENTRY(CPU, CX18_CPU_DE_SET_MDL_ACK,                 0),
        API_ENTRY(CPU, CX18_CPU_DE_SET_MDL,                     API_FAST),
+       API_ENTRY(CPU, CX18_APU_RESETAI,                        API_FAST),
        API_ENTRY(0, 0,                                         0),
 };
 
diff -r 1022101ca34c -r 682760d4b111 linux/drivers/media/video/cx18/cx23418.h
--- a/linux/drivers/media/video/cx18/cx23418.h  Tue Jul 01 01:06:22 2008 -0300
+++ b/linux/drivers/media/video/cx18/cx23418.h  Tue Jul 01 17:16:09 2008 -0300
@@ -52,6 +52,11 @@
 #define EPU_CMD_MASK_DEBUG                     (EPU_CMD_MASK | 0x000000)
 #define EPU_CMD_MASK_DE                        (EPU_CMD_MASK | 0x040000)
 
+#define APU_CMD_MASK                           0x10000000
+#define APU_CMD_MASK_ACK                       (APU_CMD_MASK | 0x80000000)
+
+#define CX18_APU_RESETAI                       (APU_CMD_MASK | 0x05)
+
 /* Description: This command indicates that a Memory Descriptor List has been
    filled with the requested channel type
    IN[0] - Task handle. Handle of the task
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/ivtv/ivtv-driver.c
--- a/linux/drivers/media/video/ivtv/ivtv-driver.c      Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/ivtv/ivtv-driver.c      Tue Jul 01 17:16:09 
2008 -0300
@@ -1132,6 +1132,12 @@ static int __devinit ivtv_probe(struct p
        /* if no tuner was found, then pick the first tuner in the card list */
        if (itv->options.tuner == -1 && itv->card->tuners[0].std) {
                itv->std = itv->card->tuners[0].std;
+               if (itv->std & V4L2_STD_PAL)
+                       itv->std = V4L2_STD_PAL_BG | V4L2_STD_PAL_H;
+               else if (itv->std & V4L2_STD_NTSC)
+                       itv->std = V4L2_STD_NTSC_M;
+               else if (itv->std & V4L2_STD_SECAM)
+                       itv->std = V4L2_STD_SECAM_L;
                itv->options.tuner = itv->card->tuners[0].tuner;
        }
        if (itv->options.radio == -1)
diff -r 1022101ca34c -r 682760d4b111 
linux/drivers/media/video/ivtv/ivtv-streams.c
--- a/linux/drivers/media/video/ivtv/ivtv-streams.c     Tue Jul 01 01:06:22 
2008 -0300
+++ b/linux/drivers/media/video/ivtv/ivtv-streams.c     Tue Jul 01 17:16:09 
2008 -0300
@@ -217,8 +217,8 @@ static int ivtv_prep_dev(struct ivtv *it
        if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) {
                s->v4l2dev->type |= VID_TYPE_MPEG_DECODER;
        }
-       snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "ivtv%d",
-                       itv->num);
+       snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "ivtv%d %s",
+                       itv->num, s->name);
 
        s->v4l2dev->minor = minor;
        s->v4l2dev->dev = &itv->dev->dev;
diff -r 1022101ca34c -r 682760d4b111 v4l2-apps/util/v4l2-ctl.cpp
--- a/v4l2-apps/util/v4l2-ctl.cpp       Tue Jul 01 01:06:22 2008 -0300
+++ b/v4l2-apps/util/v4l2-ctl.cpp       Tue Jul 01 17:16:09 2008 -0300
@@ -485,10 +485,16 @@ static std::string name2var(unsigned cha
 static std::string name2var(unsigned char *name)
 {
        std::string s;
+       int add_underscore = 0;
 
        while (*name) {
-               if (*name == ' ') s += "_";
-               else s += std::string(1, tolower(*name));
+               if (isalnum(*name)) {
+                       if (add_underscore)
+                               s += '_';
+                       add_underscore = 0;
+                       s += std::string(1, tolower(*name));
+               }
+               else if (s.length()) add_underscore = 1;
                name++;
        }
        return s;
@@ -1365,7 +1371,7 @@ int main(int argc, char **argv)
                                        std = V4L2_STD_SECAM;
                        }
                        else {
-                               std = strtol(optarg, 0L, 0);
+                               std = strtol(optarg, 0L, 0) | (1ULL << 63);
                        }
                        break;
                case OptGetCtrl:
@@ -1562,8 +1568,8 @@ int main(int argc, char **argv)
        }
 
        if (options[OptSetStandard]) {
-               if (std < 16) {
-                       vs.index = std;
+               if (std & (1ULL << 63)) {
+                       vs.index = std & 0xffff;
                        if (ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) {
                                std = vs.id;
                        }
diff -r 1022101ca34c -r 682760d4b111 v4l2-apps/util/v4l2-dbg.cpp
--- a/v4l2-apps/util/v4l2-dbg.cpp       Tue Jul 01 01:06:22 2008 -0300
+++ b/v4l2-apps/util/v4l2-dbg.cpp       Tue Jul 01 17:16:09 2008 -0300
@@ -369,6 +369,8 @@ int main(int argc, char **argv)
                                        break;
                                case 2:
                                        reg_min = strtoull(value, 0L, 0);
+                                       if (reg_max == 0)
+                                               reg_max = reg_min + 0xff;
                                        break;
                                case 3:
                                        reg_max = strtoull(value, 0L, 0);


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/682760d4b111a1d8b5b54cde2a99d377034f5418

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to