The patch number 8070 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://linuxtv.org/hg/~awalls/v4l-dvb




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


---

 linux/drivers/media/video/cx18/cx18-cards.c |   57 ++++++++++++--------
 linux/drivers/media/video/cx18/cx18-cards.h |   10 +++
 linux/drivers/media/video/cx18/cx18-dvb.c   |   17 +++++
 linux/drivers/media/video/cx18/cx18-gpio.c  |   26 ++++++++-
 linux/drivers/media/video/cx18/cx18-gpio.h  |    1 
 linux/drivers/media/video/cx18/cx18-i2c.c   |    2 
 6 files changed, 88 insertions(+), 25 deletions(-)

diff -r 37ba071544d9 -r b988afd327fc linux/drivers/media/video/cx18/cx18-cards.c
--- a/linux/drivers/media/video/cx18/cx18-cards.c       Wed Jun 18 13:23:52 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-cards.c       Sun Jun 22 06:32:03 
2008 -0300
@@ -67,10 +67,10 @@ static const struct cx18_card cx18_card_
                { CX18_CARD_INPUT_LINE_IN1,
                  CX18_AV_AUDIO_SERIAL, CS5345_IN_2 },
                { CX18_CARD_INPUT_LINE_IN2,
-                 CX18_AV_AUDIO_SERIAL, CS5345_IN_2 },
-       },
-       .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
-                        CX18_AV_AUDIO_SERIAL, 0 },
+                 CX18_AV_AUDIO_SERIAL, CS5345_IN_3 },
+       },
+       .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
+                        CX18_AV_AUDIO_SERIAL, CS5345_IN_4 },
        .ddr = {
                /* ESMT M13S128324A-5B memory */
                .chip_config = 0x003,
@@ -82,6 +82,11 @@ static const struct cx18_card cx18_card_
        },
        .gpio_init.initial_value = 0x3001,
        .gpio_init.direction = 0x3001,
+       .gpio_i2c_slave_reset = {
+               .active_lo_mask = 0x3001,
+               .msecs_asserted = 10,
+               .msecs_recovery = 40,
+       },
        .i2c = &cx18_i2c_std,
 };
 
@@ -107,10 +112,10 @@ static const struct cx18_card cx18_card_
                { CX18_CARD_INPUT_LINE_IN1,
                  CX18_AV_AUDIO_SERIAL, CS5345_IN_2 },
                { CX18_CARD_INPUT_LINE_IN2,
-                 CX18_AV_AUDIO_SERIAL, CS5345_IN_2 },
-       },
-       .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
-                        CX18_AV_AUDIO_SERIAL, 0 },
+                 CX18_AV_AUDIO_SERIAL, CS5345_IN_3 },
+       },
+       .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
+                        CX18_AV_AUDIO_SERIAL, CS5345_IN_4 },
        .ddr = {
                /* Samsung K4D263238G-VC33 memory */
                .chip_config = 0x003,
@@ -122,6 +127,11 @@ static const struct cx18_card cx18_card_
        },
        .gpio_init.initial_value = 0x3001,
        .gpio_init.direction = 0x3001,
+       .gpio_i2c_slave_reset = {
+               .active_lo_mask = 0x3001,
+               .msecs_asserted = 10,
+               .msecs_recovery = 40,
+       },
        .i2c = &cx18_i2c_std,
 };
 
@@ -184,23 +194,26 @@ static const struct cx18_card cx18_card_
 static const struct cx18_card cx18_card_mpc718 = {
        .type = CX18_CARD_YUAN_MPC718,
        .name = "Yuan MPC718",
-       .comment = "Not yet supported!\n",
-       .v4l2_capabilities = 0,
+       .comment = "Some Composite and S-Video inputs are currently working.\n",
+       .v4l2_capabilities = CX18_CAP_ENCODER,
        .hw_audio_ctrl = CX18_HW_CX23418,
        .hw_all = CX18_HW_TUNER,
        .video_inputs = {
-               { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE7 },
-               { CX18_CARD_INPUT_SVIDEO1,    1, CX18_AV_SVIDEO1    },
-               { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE3 },
-       },
-       .audio_inputs = {
-               { CX18_CARD_INPUT_AUD_TUNER,
-                 CX18_AV_AUDIO8, 0 },
-               { CX18_CARD_INPUT_LINE_IN1,
-                 CX18_AV_AUDIO_SERIAL, 0 },
-       },
-       .radio_input = { CX18_CARD_INPUT_AUD_TUNER,
-                        CX18_AV_AUDIO_SERIAL, 0 },
+               { CX18_CARD_INPUT_VID_TUNER,  0, CX18_AV_COMPOSITE2 },
+               { CX18_CARD_INPUT_SVIDEO1,    1,
+                               CX18_AV_SVIDEO_LUMA3 | CX18_AV_SVIDEO_CHROMA4 },
+               { CX18_CARD_INPUT_COMPOSITE1, 1, CX18_AV_COMPOSITE1 },
+               { CX18_CARD_INPUT_SVIDEO2,    2,
+                               CX18_AV_SVIDEO_LUMA7 | CX18_AV_SVIDEO_CHROMA8 },
+               { CX18_CARD_INPUT_COMPOSITE2, 2, CX18_AV_COMPOSITE6 },
+               { 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 },
        .tuners = {
                /* XC3028 tuner */
                { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
diff -r 37ba071544d9 -r b988afd327fc linux/drivers/media/video/cx18/cx18-cards.h
--- a/linux/drivers/media/video/cx18/cx18-cards.h       Wed Jun 18 13:23:52 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-cards.h       Sun Jun 22 06:32:03 
2008 -0300
@@ -78,6 +78,13 @@ struct cx18_gpio_init { /* set initial G
        u32 initial_value;
 };
 
+struct cx18_gpio_i2c_slave_reset {
+       u32 active_lo_mask; /* GPIO outputs that reset i2c chips when low */
+       u32 active_hi_mask; /* GPIO outputs that reset i2c chips when high */
+       int msecs_asserted; /* time period reset must remain asserted */
+       int msecs_recovery; /* time after deassert for chips to be ready */
+};
+
 struct cx18_card_tuner {
        v4l2_std_id std;        /* standard for which the tuner is suitable */
        int         tuner;      /* tuner ID (from tuner.h) */
@@ -114,7 +121,8 @@ struct cx18_card {
 
        /* GPIO card-specific settings */
        u8 xceive_pin;          /* XCeive tuner GPIO reset pin */
-       struct cx18_gpio_init           gpio_init;
+       struct cx18_gpio_init            gpio_init;
+       struct cx18_gpio_i2c_slave_reset gpio_i2c_slave_reset;
 
        struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS];
        struct cx18_card_tuner_i2c *i2c;
diff -r 37ba071544d9 -r b988afd327fc linux/drivers/media/video/cx18/cx18-dvb.c
--- a/linux/drivers/media/video/cx18/cx18-dvb.c Wed Jun 18 13:23:52 2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-dvb.c Sun Jun 22 06:32:03 2008 -0300
@@ -69,11 +69,21 @@ static int cx18_dvb_start_feed(struct dv
        struct dvb_demux *demux = feed->demux;
        struct cx18_stream *stream = (struct cx18_stream *) demux->priv;
        struct cx18 *cx = stream->cx;
-       int ret = -EINVAL;
+       int ret;
        u32 v;
 
        CX18_DEBUG_INFO("Start feed: pid = 0x%x index = %d\n",
                        feed->pid, feed->index);
+
+       mutex_lock(&cx->serialize_lock);
+       ret = cx18_init_on_first_open(cx);
+       mutex_unlock(&cx->serialize_lock);
+       if (ret) {
+               CX18_ERR("Failed to initialize firmware starting DVB feed\n");
+               return ret;
+       }
+       ret = -EINVAL;
+
        switch (cx->card->type) {
        case CX18_CARD_HVR_1600_ESMT:
        case CX18_CARD_HVR_1600_SAMSUNG:
@@ -101,6 +111,11 @@ static int cx18_dvb_start_feed(struct dv
                if (stream->dvb.feeding++ == 0) {
                        CX18_DEBUG_INFO("Starting Transport DMA\n");
                        ret = cx18_start_v4l2_encode_stream(stream);
+                       if (ret < 0) {
+                               CX18_DEBUG_INFO(
+                                       "Failed to start Transport DMA\n");
+                               stream->dvb.feeding--;
+                       }
                } else
                        ret = 0;
                mutex_unlock(&stream->dvb.feedlock);
diff -r 37ba071544d9 -r b988afd327fc linux/drivers/media/video/cx18/cx18-gpio.c
--- a/linux/drivers/media/video/cx18/cx18-gpio.c        Wed Jun 18 13:23:52 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-gpio.c        Sun Jun 22 06:32:03 
2008 -0300
@@ -53,8 +53,32 @@ static void gpio_write(struct cx18 *cx)
        write_reg(((dir & 0xffff) << 16) | (val & 0xffff),
                        CX18_REG_GPIO_OUT1);
        write_reg(dir & 0xffff0000, CX18_REG_GPIO_DIR2);
-       write_reg((dir & 0xffff0000) | ((val & 0xffff0000) >> 16),
+       write_reg_sync((dir & 0xffff0000) | ((val & 0xffff0000) >> 16),
                        CX18_REG_GPIO_OUT2);
+}
+
+void cx18_reset_i2c_slaves_gpio(struct cx18 *cx)
+{
+       const struct cx18_gpio_i2c_slave_reset *p;
+
+       p = &cx->card->gpio_i2c_slave_reset;
+
+       if ((p->active_lo_mask | p->active_hi_mask) == 0)
+               return;
+
+       /* Assuming that the masks are a subset of the bits in gpio_dir */
+
+       /* Assert */
+       cx->gpio_val =
+               (cx->gpio_val | p->active_hi_mask) & ~(p->active_lo_mask);
+       gpio_write(cx);
+       schedule_timeout_uninterruptible(msecs_to_jiffies(p->msecs_asserted));
+
+       /* Deassert */
+       cx->gpio_val =
+               (cx->gpio_val | p->active_lo_mask) & ~(p->active_hi_mask);
+       gpio_write(cx);
+       schedule_timeout_uninterruptible(msecs_to_jiffies(p->msecs_recovery));
 }
 
 void cx18_gpio_init(struct cx18 *cx)
diff -r 37ba071544d9 -r b988afd327fc linux/drivers/media/video/cx18/cx18-gpio.h
--- a/linux/drivers/media/video/cx18/cx18-gpio.h        Wed Jun 18 13:23:52 
2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-gpio.h        Sun Jun 22 06:32:03 
2008 -0300
@@ -21,4 +21,5 @@
  */
 
 void cx18_gpio_init(struct cx18 *cx);
+void cx18_reset_i2c_slaves_gpio(struct cx18 *cx);
 int cx18_reset_tuner_gpio(void *dev, int cmd, int value);
diff -r 37ba071544d9 -r b988afd327fc linux/drivers/media/video/cx18/cx18-i2c.c
--- a/linux/drivers/media/video/cx18/cx18-i2c.c Wed Jun 18 13:23:52 2008 -0300
+++ b/linux/drivers/media/video/cx18/cx18-i2c.c Sun Jun 22 06:32:03 2008 -0300
@@ -435,6 +435,8 @@ int init_cx18_i2c(struct cx18 *cx)
        cx18_setscl(&cx->i2c_algo_cb_data[1], 1);
        cx18_setsda(&cx->i2c_algo_cb_data[1], 1);
 
+       cx18_reset_i2c_slaves_gpio(cx);
+
        return i2c_bit_add_bus(&cx->i2c_adap[0]) ||
                i2c_bit_add_bus(&cx->i2c_adap[1]);
 }


---

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

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

Reply via email to