Skip to contentSkip to conversation

cx23885

DISCUSSION Michael 5 participants 19 messages Feb 15, 2010 – Feb 16, 2010

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
Quoted 3 lines · Michael

Hello

Does anybody know whether this card is currently supported

Likely no. I have not checked the source to be sure.

Quoted 6 lines

and if yes, is it
by cx88 or by cx23885?

http://www.commell.com.tw/Product/Surveillance/MPX-885.htm

It is based on the Connexant 23885 chip but uses an Mini-PCIe interface.

cx88 handles PCI bridge chips: CX2388[0123]

cx23885 handles PCIe bridge chips: CX2388[578]

Quoted 1 line

From the picture of the card from the datasheet it has a CX23885 chip.

Regards,
Andy

Quoted 3 lines

Thanks

Michael

author
#2 lore raw

Hi Andy

Quoted 4 lines
Quoted 1 line

Does anybody know whether this card is currently supported

Likely no. I have not checked the source to be sure.

Is this because the driver does not have the right capabilities or is it "just" a PCI-id missing in the driver?

The latter would be quite easy to add, I guess.

Quoted 4 lines
Quoted 4 lines

and if yes, is it
by cx88 or by cx23885?

Quoted 10 lines
Quoted 3 lines

http://www.commell.com.tw/Product/Surveillance/MPX-885.htm

It is based on the Connexant 23885 chip but uses an Mini-PCIe interface.

cx88 handles PCI bridge chips: CX2388[0123]

cx23885 handles PCIe bridge chips: CX2388[578]

Quoted 1 line

From the picture of the card from the datasheet it has a CX23885 chip.

That means, if a driver might support it, then the cx23885 driver not the cx88, correct?

Thanks

Michael

Quoted 6 lines

Regards,
Andy

Quoted 3 lines

Thanks

Michael

#3 lore raw
Quoted 8 lines · Michael

Hi Andy

Quoted 4 lines
Quoted 1 line

Does anybody know whether this card is currently supported

Likely no. I have not checked the source to be sure.

Is this because the driver does not have the right capabilities or is it "just" a PCI-id missing in the driver?

A mixture of both, analog support in the 885 driver is limited. Generally, yes - start by adding the PCI id.

Quoted 12 lines

The latter would be quite easy to add, I guess.

Quoted 10 lines
Quoted 7 lines

and if yes, is it
by cx88 or by cx23885?

http://www.commell.com.tw/Product/Surveillance/MPX-885.htm

It is based on the Connexant 23885 chip but uses an Mini-PCIe interface.

cx88 handles PCI bridge chips: CX2388[0123]

Quoted 7 lines
Quoted 4 lines

cx23885 handles PCIe bridge chips: CX2388[578]

Quoted 1 line

From the picture of the card from the datasheet it has a CX23885 chip.

That means, if a driver might support it, then the cx23885 driver not the cx88, correct?

Correct.

Signature · 3 lines
Steven Toth - Kernel Labs
http://www.kernellabs.com
+1.646.355.8490
author
#4 lore raw
Quoted 6 lines · Steven Toth
Quoted 2 lines

Is this because the driver does not have the right capabilities or is it "just" a PCI-id missing in the driver?

A mixture of both, analog support in the 885 driver is limited. Generally, yes - start by adding the PCI id.

So, does this imply that you see a chance to get this card running? :-)

If so, I will order one card and try. There is not much I want to do with the card. It should simply digitize an external camera signal. I want to display it with mplayer. It should, however, be reliable and not crash the system or drop the stream or whatever.

So far, it seems that this is the only mini-pcie video digitizer card that exists. I would have taken a bttv based one instead, but as there is none...

Thanks

Michael

#5 lore raw
Quoted 11 lines · Michael
Quoted 6 lines · Steven Toth
Quoted 2 lines

Is this because the driver does not have the right capabilities or is it "just" a PCI-id missing in the driver?

A mixture of both, analog support in the 885 driver is limited. Generally, yes - start by adding the PCI id.

So, does this imply that you see a chance to get this card running? :-)

Quoted 7 lines

If so, I will order one card and try. There is not much I want to do with the card. It should simply digitize an external camera signal. I want to display it with mplayer. It should, however, be reliable and not crash the system or drop the stream or whatever.

So far, it seems that this is the only mini-pcie video digitizer card that exists. I would have taken a bttv based one instead, but as there is none...

The hardware has no mpeg encoder, so if by digitizer you mean raw high bitrate video frames then yes, and if mplayer is capable of supporting the v4l mmap interfaces then yes. (I've have zero experience of mplayer with raw video - not sure if this works).

It feels like a reach, the design looks like a 'same-old' cx23885/7/8 which you could potentially use in tvtime - with some work.

Signature · 3 lines
Steven Toth - Kernel Labs
http://www.kernellabs.com
+1.646.355.8490
author
#6 lore raw
Quoted 4 lines · Steven Toth

The hardware has no mpeg encoder, so if by digitizer you mean raw high bitrate video frames then yes, and if mplayer is capable of supporting the v4l mmap interfaces then yes. (I've have zero experience of mplayer with raw video - not sure if this works).

Well, I have mplayer working with a bttv based card sending rawyuv2, if I remember correctly. But this is on a different computer.

The board that I want to use has only mini-pci-express and the only card I found so far is this MPX-885.

Quoted 4 lines

It feels like a reach, the design looks like a 'same-old' cx23885/7/8 which you could potentially use in tvtime - with some work.

Well if tvtime runs then mplayer will most probably, too. The question is, what means "with some work" :-)

Michael

#7 lore raw
Quoted 3 lines

Well if tvtime runs then mplayer will most probably, too. The question is, what means "with some work" :-)

If you haven't worked on the cx23885 driver in the past, and you're not accustomed to developing tv/video drivers then you're going to struggle, massively.

Not that I'm trying to discourage, on the contrary, the more driver developers the better. In reality this isn't something you can fix with an evenings work.

However, if you would like to take a shot then look at the existing support for the HVR1800 board in the cx23885 tree. Specifically look at the raw video support in the cx23885-video.c file and you'll also want to investigate the cx25840 driver for configuring the A/V subsystem.

Feel free to submit patches.

Regards,

- Steve

Signature · 3 lines
Steven Toth - Kernel Labs
http://www.kernellabs.com
+1.646.355.8490
author
#8 lore raw

Now comes the best part:

I found a linux driver on the producers web page. And it is written by ... Steven Toth :-)

http://www.commell.com.tw/Product/Surveillance/MPX-885/mpx-885.rar

I am looking at the files to see what they have changed (if anything at all).

One thing I found pretty fast is that they added in cx23885-card.c:

[CX23885_BOARD_MPX885] = {
	    .name       = "MPX-885",
        .porta      = CX23885_ANALOG_VIDEO,
        .portb      = CX23885_MPEG_ENCODER,
        .portc      = CX23885_MPEG_DVB,
        .input          = {{
            .type   = CX23885_VMUX_COMPOSITE1,
            .vmux   = CX25840_VIN1_CH1,
            .gpio0  = 0,
        }, {
            .type   = CX23885_VMUX_COMPOSITE2,
            .vmux   = CX25840_VIN2_CH1,
            .gpio0  = 0,
        }, {
            .type   = CX23885_VMUX_COMPOSITE3,
            .vmux   = CX25840_VIN3_CH1,
            .gpio0  = 0,
        }, {
            .type   = CX23885_VMUX_COMPOSITE4,
            .vmux   = CX25840_VIN4_CH1,
            .gpio0  = 0,
        } }

Now, concerning the rest of the code, I'm afraid my knowledge is far below what is needed to understand just a little bit of it. I can try to compile the code, but they state it is for kernel 2.6.21, so I don't know whether it compiles for 2.6.31 (or newer).

I can try to make a diff, but I guess there will be lots of changes between this rather old code and an actual cx23885 version.

But maybe it is a start. What do you think?

Michael

Quoted 23 lines · Steven Toth
Quoted 3 lines

Well if tvtime runs then mplayer will most probably, too. The question is, what means "with some work" :-)

If you haven't worked on the cx23885 driver in the past, and you're not accustomed to developing tv/video drivers then you're going to struggle, massively.

Not that I'm trying to discourage, on the contrary, the more driver developers the better. In reality this isn't something you can fix with an evenings work.

However, if you would like to take a shot then look at the existing support for the HVR1800 board in the cx23885 tree. Specifically look at the raw video support in the cx23885-video.c file and you'll also want to investigate the cx25840 driver for configuring the A/V subsystem.

Feel free to submit patches.

Regards,

- Steve

#9 lore raw
Quoted 1 line

One thing I found pretty fast is that they added in cx23885-card.c:

This looks promising.

Quoted 1 line

But maybe it is a start. What do you think?

I repeat I my original comment below.

Quoted 1 line
Quoted 1 line

Feel free to submit patches.

^^^ indeed, good luck.

Regards,

Signature · 3 lines
Steven Toth - Kernel Labs
http://www.kernellabs.com
+1.646.355.8490
author
#10 lore raw

O.K. I ordered the card now. Can take one or two weeks for it to arrive. Gonna come back to the list then.

Michael

Quoted 14 lines · Steven Toth
Quoted 1 line

One thing I found pretty fast is that they added in cx23885-card.c:

This looks promising.

Quoted 1 line

But maybe it is a start. What do you think?

I repeat I my original comment below.

Quoted 1 line
Quoted 1 line

Feel free to submit patches.

^^^ indeed, good luck.

Regards,

author
#11 lore raw
In reply to Michael

I've done a diff against 2.6.31, but there are too many differences, so I can't easily tell what they have added and what was changed in the development between 2.6.21 and 2.6.31.

One thing is clear: They added several "case" instructions with code for the MPX-885. So I guess, they really got it working.

I'm downloading kernel 2.6.21 now and make a diff with these drivers.

Michael

Quoted 72 lines · Michael

Now comes the best part:

I found a linux driver on the producers web page. And it is written by ... Steven Toth :-)

http://www.commell.com.tw/Product/Surveillance/MPX-885/mpx-885.rar

I am looking at the files to see what they have changed (if anything at all).

One thing I found pretty fast is that they added in cx23885-card.c:

[CX23885_BOARD_MPX885] = {
.name = "MPX-885",

        .porta      = CX23885_ANALOG_VIDEO,
        .portb      = CX23885_MPEG_ENCODER,
        .portc      = CX23885_MPEG_DVB,
        .input          = {{
            .type   = CX23885_VMUX_COMPOSITE1,
            .vmux   = CX25840_VIN1_CH1,
            .gpio0  = 0,
        }, {
            .type   = CX23885_VMUX_COMPOSITE2,
            .vmux   = CX25840_VIN2_CH1,
            .gpio0  = 0,
        }, {
            .type   = CX23885_VMUX_COMPOSITE3,
            .vmux   = CX25840_VIN3_CH1,
            .gpio0  = 0,
        }, {
            .type   = CX23885_VMUX_COMPOSITE4,
            .vmux   = CX25840_VIN4_CH1,
            .gpio0  = 0,
        } }

Now, concerning the rest of the code, I'm afraid my knowledge is far below what is needed to understand just a little bit of it. I can try to compile the code, but they state it is for kernel 2.6.21, so I don't know whether it compiles for 2.6.31 (or newer).

I can try to make a diff, but I guess there will be lots of changes between this rather old code and an actual cx23885 version.

But maybe it is a start. What do you think?

Michael

Quoted 23 lines · Steven Toth
Quoted 3 lines

Well if tvtime runs then mplayer will most probably, too. The question is, what means "with some work" :-)

If you haven't worked on the cx23885 driver in the past, and you're not accustomed to developing tv/video drivers then you're going to struggle, massively.

Not that I'm trying to discourage, on the contrary, the more driver developers the better. In reality this isn't something you can fix with an evenings work.

However, if you would like to take a shot then look at the existing support for the HVR1800 board in the cx23885 tree. Specifically look at the raw video support in the cx23885-video.c file and you'll also want to investigate the cx25840 driver for configuring the A/V subsystem.

Feel free to submit patches.

Regards,

- Steve

author
#12 lore raw

Well, this did not work. The cx23885 driver was not included in kernel 2.6.21, so no diff. The diff of the 2.6.21 cx25840 is twice as big as the 2.6.31 diff. :-(

If anybody can give me a hint, what to include in a patch and what was old stuff that has jsut changed in 2.6.31, I'd be grateful.

Attached is the diff of cx23885, the commell version against kernel 2.6.31.4.

Quoted 3 lines

I'm downloading kernel 2.6.21 now and make a diff with these drivers.

cimax2.c +19 -6
diff -u cx23885/cimax2.c cx23885-commell/cimax2.c
@@ -75,7 +75,6 @@
 	void *priv;
 };
 
-struct mutex gpio_mutex;/* Two CiMax's uses same GPIO lines */
 
 int netup_read_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
 						u8 *buf, int len)
@@ -183,10 +182,11 @@
 	if (ret != 0)
 		return ret;
 
-	mutex_lock(&gpio_mutex);
+	mutex_lock(&dev->gpio_lock);
 
 	/* write addr */
 	cx_write(MC417_OEN, NETUP_EN_ALL);
+	msleep(2);
 	cx_write(MC417_RWD, NETUP_CTRL_OFF |
 				NETUP_ADLO | (0xff & addr));
 	cx_clear(MC417_RWD, NETUP_ADLO);
@@ -194,9 +194,10 @@
 				NETUP_ADHI | (0xff & (addr >> 8)));
 	cx_clear(MC417_RWD, NETUP_ADHI);
 
-	if (read) /* data in */
+	if (read) { /* data in */
 		cx_write(MC417_OEN, NETUP_EN_ALL | NETUP_DATA);
-	else /* data out */
+		msleep(2);
+	} else /* data out */
 		cx_write(MC417_RWD, NETUP_CTRL_OFF | data);
 
 	/* choose chip */
@@ -206,7 +207,7 @@
 	cx_clear(MC417_RWD, (read) ? NETUP_RD : NETUP_WR);
 	mem = netup_ci_get_mem(dev);
 
-	mutex_unlock(&gpio_mutex);
+	mutex_unlock(&dev->gpio_lock);
 
 	if (!read)
 		if (mem < 0)
@@ -295,10 +296,18 @@
 }
 
 /* work handler */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static void netup_read_ci_status(void *_state)
+#else
 static void netup_read_ci_status(struct work_struct *work)
+#endif
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+	struct netup_ci_state *state = _state;
+#else
 	struct netup_ci_state *state =
 			container_of(work, struct netup_ci_state, work);
+#endif
 	u8 buf[33];
 	int ret;
 
@@ -403,7 +412,6 @@
 	switch (port->nr) {
 	case 1:
 		state->ci_i2c_addr = 0x40;
-		mutex_init(&gpio_mutex);
 		break;
 	case 2:
 		state->ci_i2c_addr = 0x41;
@@ -442,7 +450,12 @@
 	if (0 != ret)
 		goto err;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+	INIT_WORK(&state->work, netup_read_ci_status, state);
+#else
 	INIT_WORK(&state->work, netup_read_ci_status);
+#endif
+	schedule_work(&state->work);
 
 	ci_dbg_print("%s: CI initialized!\n", __func__);
 
cx23885-417.c +50 -24

122 lines not on this page · raw message

cx23885-cards.c +207 -8

329 lines not on this page · raw message

cx23885-core.c +127 -15

251 lines not on this page · raw message

cx23885-dvb.c +113 -14

208 lines not on this page · raw message

cx23885.h +40 -5

111 lines not on this page · raw message

cx23885-i2c.c +11 -0
diff -u cx23885/cx23885-i2c.c cx23885-commell/cx23885-i2c.c
@@ -25,6 +25,7 @@
 #include <linux/delay.h>
 #include <asm/io.h>
 
+#include "compat.h"
 #include "cx23885.h"
 
 #include <media/v4l2-common.h>
@@ -276,6 +277,9 @@
 static struct i2c_algorithm cx23885_i2c_algo_template = {
 	.master_xfer	= i2c_xfer,
 	.functionality	= cx23885_functionality,
+#ifdef NEED_ALGO_CONTROL
+	.algo_control = dummy_algo_control,
+#endif
 };
 
 /* ----------------------------------------------------------------------- */
@@ -283,8 +287,13 @@
 static struct i2c_adapter cx23885_i2c_adap_template = {
 	.name              = "cx23885",
 	.owner             = THIS_MODULE,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
 	.id                = I2C_HW_B_CX23885,
+#endif
 	.algo              = &cx23885_i2c_algo_template,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
+	.class             = I2C_CLASS_TV_ANALOG,
+#endif
 };
 
 static struct i2c_client cx23885_i2c_client_template = {
@@ -357,6 +366,7 @@
 		printk(KERN_WARNING "%s: i2c bus %d register FAILED\n",
 			dev->name, bus->nr);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
 	/* Instantiate the IR receiver device, if present */
 	if (0 == bus->i2c_rc) {
 		struct i2c_board_info info;
@@ -369,6 +379,7 @@
 		i2c_new_probed_device(&bus->i2c_adap, &info, addr_list);
 	}
 
+#endif
 	return bus->i2c_rc;
 }
 

Nur in cx23885-commell: cx23885-input.c.
Nur in cx23885-commell: cx23885-input.h.
Nur in cx23885-commell: cx23885-ioctl.c.
Nur in cx23885-commell: cx23885-ioctl.h.
Nur in cx23885-commell: cx23885-ir.c.
Nur in cx23885-commell: cx23885-ir.h.
Nur in cx23885: cx23885.mod.c.

cx23885-reg.h +3 -2
diff -u cx23885/cx23885-reg.h cx23885-commell/cx23885-reg.h
@@ -212,8 +212,9 @@
 
 #define DEV_CNTRL2	0x00040000
 
-#define PCI_MSK_GPIO1   (1 << 24)
-#define PCI_MSK_GPIO0   (1 << 23)
+#define PCI_MSK_IR        (1 << 28)
+#define PCI_MSK_GPIO1     (1 << 24)
+#define PCI_MSK_GPIO0     (1 << 23)
 #define PCI_MSK_APB_DMA   (1 << 12)
 #define PCI_MSK_AL_WR     (1 << 11)
 #define PCI_MSK_AL_RD     (1 << 10)
cx23885-vbi.c +14 -0
diff -u cx23885/cx23885-vbi.c cx23885-commell/cx23885-vbi.c
@@ -25,6 +25,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 
+#include "compat.h"
 #include "cx23885.h"
 
 static unsigned int vbibufs = 4;
@@ -85,6 +86,19 @@
 	return 0;
 }
 
+#if 0
+/* not (yet) used */
+static int cx23885_stop_vbi_dma(struct cx23885_dev *dev)
+{
+	/* stop dma */
+	cx_clear(VID_A_DMA_CTL, 0x00000022);
+
+	/* disable irqs */
+	cx_clear(PCI_INT_MSK, 0x000001);
+	cx_clear(VID_A_INT_MSK, 0x00000022);
+	return 0;
+}
+#endif
 
 static int cx23885_restart_vbi_queue(struct cx23885_dev    *dev,
 			     struct cx23885_dmaqueue *q)
cx23885-video.c +280 -17

499 lines not on this page · raw message

Nur in cx23885-commell: cx23888-ir.c.
Nur in cx23885-commell: cx23888-ir.h.

Makefile +1 -0
diff -u cx23885/Makefile cx23885-commell/Makefile
@@ -1,5 +1,6 @@
 cx23885-objs	:= cx23885-cards.o cx23885-video.o cx23885-vbi.o \
 		    cx23885-core.o cx23885-i2c.o cx23885-dvb.o cx23885-417.o \
+		    cx23885-ioctl.o cx23885-ir.o cx23885-input.o cx23888-ir.o \
 		    netup-init.o cimax2.o netup-eeprom.o
 
 obj-$(CONFIG_VIDEO_CX23885) += cx23885.o

Nur in cx23885: modules.order.

netup-eeprom.c +13 -3
diff -u cx23885/netup-eeprom.c cx23885-commell/netup-eeprom.c
@@ -97,11 +97,21 @@
 {
 	int i, j;
 
-	cinfo->rev =  netup_eeprom_read(i2c_adap, 13);
+	cinfo->rev =  netup_eeprom_read(i2c_adap, 63);
 
-	for (i = 0, j = 0; i < 6; i++, j++)
+	for (i = 64, j = 0; i < 70; i++, j++)
 		cinfo->port[0].mac[j] =  netup_eeprom_read(i2c_adap, i);
 
-	for (i = 6, j = 0; i < 12; i++, j++)
+	for (i = 70, j = 0; i < 76; i++, j++)
 		cinfo->port[1].mac[j] =  netup_eeprom_read(i2c_adap, i);
+#if 0
+	printk(KERN_INFO "NetUP Dual DVB-S2 CI card rev=0x%x MAC1=%02X:%02X:"
+	"%02X:%02X:%02X:%02X MAC2=%02X:%02X:%02X:%02X:%02X:%02X\n", cinfo->rev,
+		cinfo->port[0].mac[0], cinfo->port[0].mac[1],
+		cinfo->port[0].mac[2], cinfo->port[0].mac[3],
+		cinfo->port[0].mac[4], cinfo->port[0].mac[5],
+		cinfo->port[1].mac[0], cinfo->port[1].mac[1],
+		cinfo->port[1].mac[2], cinfo->port[1].mac[3],
+		cinfo->port[1].mac[4], cinfo->port[1].mac[5]);
+#endif
 };
#13 lore raw
Quoted 4 lines · Michael

Well, this did not work. The cx23885 driver was not included in kernel 2.6.21, so no diff. The diff of the 2.6.21 cx25840 is twice as big as the 2.6.31 diff. :-(

Quoted 9 lines

If anybody can give me a hint, what to include in a patch and what was old stuff that has jsut changed in 2.6.31, I'd be grateful.

Attached is the diff of cx23885, the commell version against kernel 2.6.31.4.

Quoted 3 lines

I'm downloading kernel 2.6.21 now and make a diff with these drivers.

Start by patching the current cx23885 driver with all of the switch statements related to the new board CX23885_BOARD_MPX885.

-cards.c -core.c etc.

I already see some issues in their MPX885 additions, driving wrong gpios and assuming the encoder is attached - but it's a good start.

Signature · 3 lines
Steven Toth - Kernel Labs
http://www.kernellabs.com
+1.646.355.8490
#14 lore raw
In reply to Michael
Quoted 3 lines · Michael

If anybody can give me a hint, what to include in a patch and what was old stuff that has jsut changed in 2.6.31, I'd be grateful.

Their source tree contains a .hg_archival.txt file which looks like it can be used to identify the original v4l-dvb tree they used.

Attached is a diff from that v4l version to the MPX-885 tree.

 cx23885/cx23885-cards.c    |   90 ++++++++++++++++
 cx23885/cx23885-dvb.c      |   30 +++++
 cx23885/cx23885-video.c    |    2 
 cx23885/cx23885.h          |    1 
 cx25840/cx25840-core.c     |  248 +++++++++++++++++++++++++++++++++++++++------
 cx25840/cx25840-firmware.c |    4 
 6 files changed, 338 insertions(+), 37 deletions(-)

Hope it helps...
-R

linux/v4l-dvb/linux/drivers/media/video/cx23885/cx23885-cards.c renamed from linux/drivers/media/video/cx23885/cx23885-cards.c +89 -1
diff -uNr v4l-dvb/linux/drivers/media/video/cx23885/cx23885-cards.c MPX-885/linux/v4l-dvb/linux/drivers/media/video/cx23885/cx23885-cards.c
@@ -216,6 +216,29 @@
 		.name		= "Compro VideoMate E800",
 		.portc		= CX23885_MPEG_DVB,
 	},
+	[CX23885_BOARD_MPX885] = {
+	    .name       = "MPX-885",
+        .porta      = CX23885_ANALOG_VIDEO,
+        .portb      = CX23885_MPEG_ENCODER,
+        .portc      = CX23885_MPEG_DVB,
+        .input          = {{
+            .type   = CX23885_VMUX_COMPOSITE1,
+            .vmux   = CX25840_VIN1_CH1,
+            .gpio0  = 0,
+        }, {
+            .type   = CX23885_VMUX_COMPOSITE2,
+            .vmux   = CX25840_VIN2_CH1,
+            .gpio0  = 0,
+        }, {
+            .type   = CX23885_VMUX_COMPOSITE3,
+            .vmux   = CX25840_VIN3_CH1,
+            .gpio0  = 0,
+        }, {
+            .type   = CX23885_VMUX_COMPOSITE4,
+            .vmux   = CX25840_VIN4_CH1,
+            .gpio0  = 0,
+        } },
+    },
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -351,7 +374,11 @@
 		.subvendor = 0x1858,
 		.subdevice = 0xe800,
 		.card      = CX23885_BOARD_COMPRO_VIDEOMATE_E800,
-	},
+	}, {
+	    .subvendor = 0x0,
+        .subdevice = 0x0,
+        .card      = CX23885_BOARD_MPX885,
+    },
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
 
@@ -798,6 +825,37 @@
 		/* CX24228 GPIO */
 		/* Connected to IF / Mux */
 		break;
+    case CX23885_BOARD_MPX885:
+		/* GPIO-0 656_CLK */
+		/* GPIO-1 656_D0 */
+		/* GPIO-2 8295A Reset */
+		/* GPIO-3-10 cx23417 data0-7 */
+		/* GPIO-11-14 cx23417 addr0-3 */
+		/* GPIO-15-18 cx23417 READY, CS, RD, WR */
+		/* GPIO-19 IR_RX */
+
+		/* CX23417 GPIO's */
+		/* EIO15 Zilog Reset */
+		/* EIO14 S5H1409/CX24227 Reset */
+		mc417_gpio_enable(dev, GPIO_15 | GPIO_14, 1);
+
+		/* Put the demod into reset and protect the eeprom */
+		mc417_gpio_clear(dev, GPIO_15 | GPIO_14);
+		mdelay(100);
+
+		/* Bring the demod and blaster out of reset */
+		mc417_gpio_set(dev, GPIO_15 | GPIO_14);
+		mdelay(100);
+
+		/* Force the TDA8295A into reset and back */
+		cx23885_gpio_enable(dev, GPIO_2, 1);
+		cx23885_gpio_set(dev, GPIO_2);
+		mdelay(20);
+		cx23885_gpio_clear(dev, GPIO_2);
+		mdelay(20);
+		cx23885_gpio_set(dev, GPIO_2);
+		mdelay(20);
+		break;
 	}
 }
 
@@ -827,6 +885,8 @@
 	case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
 		request_module("ir-kbd-i2c");
 		break;
+    case CX23885_BOARD_MPX885:
+        break;
 	}
 
 	return ret;
@@ -887,6 +947,10 @@
 		if (dev->i2c_bus[0].i2c_rc == 0)
 			hauppauge_eeprom(dev, eeprom+0xc0);
 		break;
+    case CX23885_BOARD_MPX885:
+		if (dev->i2c_bus[0].i2c_rc == 0)
+			hauppauge_eeprom(dev, eeprom+0xc0);
+        break;
 	}
 
 	switch (dev->board) {
@@ -938,6 +1002,22 @@
 		ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
 		ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
 		break;
+    case CX23885_BOARD_MPX885:
+		/* Defaults for VID B - Analog encoder */
+		/* DREQ_POL, SMODE, PUNC_CLK, MCLK_POL Serial bus + punc clk */
+		ts1->gen_ctrl_val    = 0x10e;
+		ts1->ts_clk_en_val   = 0x1; /* Enable TS_CLK */
+		ts1->src_sel_val     = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+
+		/* APB_TSVALERR_POL (active low)*/
+		ts1->vld_misc_val    = 0x2000;
+		ts1->hw_sop_ctrl_val = (0x47 << 16 | 188 << 4 | 0xc);
+
+		/* Defaults for VID C */
+		ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
+		ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
+		ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+        break;
 	case CX23885_BOARD_HAUPPAUGE_HVR1250:
 	case CX23885_BOARD_HAUPPAUGE_HVR1500:
 	case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
@@ -976,6 +1056,14 @@
 				"cx25840", "cx25840", 0x88 >> 1, NULL);
 		v4l2_subdev_call(dev->sd_cx25840, core, load_fw);
 		break;
+    case CX23885_BOARD_MPX885:
+        
+		dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
+				&dev->i2c_bus[2].i2c_adap,
+				"cx25840", "cx25840", 0x88 >> 1, NULL);
+		v4l2_subdev_call(dev->sd_cx25840, core, load_fw);
+		
+        break;
 	}
 
 	/* AUX-PLL 27MHz CLK */
linux/v4l-dvb/linux/drivers/media/video/cx23885/cx23885-dvb.c renamed from linux/drivers/media/video/cx23885/cx23885-dvb.c +30 -0
diff -uNr v4l-dvb/linux/drivers/media/video/cx23885/cx23885-dvb.c MPX-885/linux/v4l-dvb/linux/drivers/media/video/cx23885/cx23885-dvb.c
@@ -617,6 +617,36 @@
 			break;
 		}
 		break;
+    case CX23885_BOARD_MPX885:
+		i2c_bus = &dev->i2c_bus[0];
+		switch (alt_tuner) {
+		case 1:
+			fe0->dvb.frontend =
+				dvb_attach(s5h1409_attach,
+					   &hauppauge_ezqam_config,
+					   &i2c_bus->i2c_adap);
+			if (fe0->dvb.frontend != NULL) {
+				dvb_attach(tda829x_attach, fe0->dvb.frontend,
+					   &dev->i2c_bus[1].i2c_adap, 0x42,
+					   &tda829x_no_probe);
+				dvb_attach(tda18271_attach, fe0->dvb.frontend,
+					   0x60, &dev->i2c_bus[1].i2c_adap,
+					   &hauppauge_tda18271_config);
+			}
+			break;
+		case 0:
+		default:
+			fe0->dvb.frontend =
+				dvb_attach(s5h1409_attach,
+					   &hauppauge_generic_config,
+					   &i2c_bus->i2c_adap);
+			if (fe0->dvb.frontend != NULL)
+				dvb_attach(mt2131_attach, fe0->dvb.frontend,
+					   &i2c_bus->i2c_adap,
+					   &hauppauge_generic_tunerconfig, 0);
+			break;
+		}
+        break;
 	case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
 		i2c_bus = &dev->i2c_bus[0];
 		fe0->dvb.frontend = dvb_attach(s5h1409_attach,
linux/v4l-dvb/linux/drivers/media/video/cx23885/cx23885.h renamed from linux/drivers/media/video/cx23885/cx23885.h +1 -0
diff -uNr v4l-dvb/linux/drivers/media/video/cx23885/cx23885.h MPX-885/linux/v4l-dvb/linux/drivers/media/video/cx23885/cx23885.h
@@ -80,6 +80,7 @@
 #define CX23885_BOARD_MAGICPRO_PROHDTVE2       23
 #define CX23885_BOARD_HAUPPAUGE_HVR1850        24
 #define CX23885_BOARD_COMPRO_VIDEOMATE_E800    25
+#define CX23885_BOARD_MPX885                26
 
 #define GPIO_0 0x00000001
 #define GPIO_1 0x00000002
linux/v4l-dvb/linux/drivers/media/video/cx23885/cx23885-video.c renamed from linux/drivers/media/video/cx23885/cx23885-video.c +1 -1
diff -uNr v4l-dvb/linux/drivers/media/video/cx23885/cx23885-video.c MPX-885/linux/v4l-dvb/linux/drivers/media/video/cx23885/cx23885-video.c
@@ -970,7 +970,7 @@
 {
 	dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)"
 		" (disabled - no action)\n", __func__);
-#if 0
+#if 1
 	call_all(dev, core, s_ctrl, ctl);
 #endif
 	return 0;
linux/v4l-dvb/linux/drivers/media/video/cx25840/cx25840-core.c renamed from linux/drivers/media/video/cx25840/cx25840-core.c +215 -33

373 lines not on this page · raw message

linux/v4l-dvb/linux/drivers/media/video/cx25840/cx25840-firmware.c renamed from linux/drivers/media/video/cx25840/cx25840-firmware.c +2 -2
diff -uNr v4l-dvb/linux/drivers/media/video/cx25840/cx25840-firmware.c MPX-885/linux/v4l-dvb/linux/drivers/media/video/cx25840/cx25840-firmware.c
@@ -130,7 +130,7 @@
 	}
 
 	start_fw_load(client);
-
+#if 0
 	buffer[0] = 0x08;
 	buffer[1] = 0x02;
 
@@ -151,7 +151,7 @@
 		size -= len;
 		ptr += len;
 	}
-
+#endif
 	end_fw_load(client);
 
 	size = fw->size;
#15 lore raw
Quoted 17 lines · Ralph Siemsen
Quoted 3 lines · Michael

If anybody can give me a hint, what to include in a patch and what was old stuff that has jsut changed in 2.6.31, I'd be grateful.

Their source tree contains a .hg_archival.txt file which looks like it can be used to identify the original v4l-dvb tree they used.

Attached is a diff from that v4l version to the MPX-885 tree.

 cx23885/cx23885-cards.c    |   90 ++++++++++++++++
 cx23885/cx23885-dvb.c      |   30 +++++
 cx23885/cx23885-video.c    |    2 
 cx23885/cx23885.h          |    1 
 cx25840/cx25840-core.c     |  248 +++++++++++++++++++++++++++++++++++++++------
 cx25840/cx25840-firmware.c |    4 
 6 files changed, 338 insertions(+), 37 deletions(-)
Quoted 2 lines

Hope it helps...
-R

That is very helpful.

However, changes to the CX25840 module, since their MPX885 changes were developed, are extenesive when it comes to initialization of the CX23885/7/8 A/V decoder. Their changes will be difficult to port.

I also see changes which will at least break existing drivers and apps. For example, this one will violate a key assumption made by the ivtv driver:

- state->vid_input = CX25840_COMPOSITE7;
+ state->vid_input = CX25840_COMPOSITE1;

This sort of thing is typical of many vendor driver developments: get it working for this part as fast as possible so the product can ship - don't worry about anything else.

It is still decent of them to provide a linux driver and the source changes without a hassle. RAR format is inconvenient on linux though.

Regards,
Andy

author
#16 lore raw
In reply to Michael

And here the cx25840 diff, again commell versus 2.6.31.4.

P.S.: I will order a card now. Otherwise I can't test any patches...

cx25840-audio.c +344 -116
diff -u cx25840/cx25840-audio.c cx25840-commell/cx25840-audio.c
@@ -20,90 +20,141 @@
 #include <linux/i2c.h>
 #include <media/v4l2-common.h>
 #include <media/cx25840.h>
+#include "compat.h"
 
 #include "cx25840-core.h"
 
-static int set_audclk_freq(struct i2c_client *client, u32 freq)
+/*
+ * Note: The PLL and SRC parameters are based on a reference frequency that
+ * would ideally be:
+ *
+ * NTSC Color subcarrier freq * 8 = 4.5 MHz/286 * 455/2 * 8 = 28.63636363... MHz
+ *
+ * However, it's not the exact reference frequency that matters, only that the
+ * firmware and modules that comprise the driver for a particular board all
+ * use the same value (close to the ideal value).
+ *
+ * Comments below will note which reference frequency is assumed for various
+ * parameters.  They will usually be one of
+ *
+ *	ref_freq = 28.636360 MHz
+ *		or
+ *	ref_freq = 28.636363 MHz
+ */
+
+static int cx25840_set_audclk_freq(struct i2c_client *client, u32 freq)
 {
 	struct cx25840_state *state = to_state(i2c_get_clientdata(client));
 
-	if (freq != 32000 && freq != 44100 && freq != 48000)
-		return -EINVAL;
-
-	/* common for all inputs and rates */
-	/* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
-	if (!state->is_cx23885 && !state->is_cx231xx)
-		cx25840_write(client, 0x127, 0x50);
-
 	if (state->aud_input != CX25840_AUDIO_SERIAL) {
 		switch (freq) {
 		case 32000:
-			if (state->is_cx23885) {
-				/* We don't have register values
-				 * so avoid destroying registers. */
-				break;
-			}
-
-			if (!state->is_cx231xx) {
-				/* VID_PLL and AUX_PLL */
-				cx25840_write4(client, 0x108, 0x1006040f);
+			/*
+			 * VID_PLL Integer = 0x0f, VID_PLL Post Divider = 0x04
+			 * AUX_PLL Integer = 0x06, AUX PLL Post Divider = 0x10
+			 */
+			cx25840_write4(client, 0x108, 0x1006040f);
+
+			/*
+			 * VID_PLL Fraction (register 0x10c) = 0x2be2fe
+			 * 28636360 * 0xf.15f17f0/4 = 108 MHz
+			 * 432 MHz pre-postdivide
+			 */
+
+			/*
+			 * AUX_PLL Fraction = 0x1bb39ee
+			 * 28636363 * 0x6.dd9cf70/0x10 = 32000 * 384
+			 * 196.6 MHz pre-postdivide
+			 * FIXME < 200 MHz is out of specified valid range
+			 * FIXME 28636363 ref_freq doesn't match VID PLL ref
+			 */
+			cx25840_write4(client, 0x110, 0x01bb39ee);
+
+			/*
+			 * SA_MCLK_SEL = 1
+			 * SA_MCLK_DIV = 0x10 = 384/384 * AUX_PLL post dvivider
+			 */
+			cx25840_write(client, 0x127, 0x50);
 
-				/* AUX_PLL_FRAC */
-				cx25840_write4(client, 0x110, 0x01bb39ee);
-			}
-
-			if (state->is_cx25836)
+			if (is_cx2583x(state))
 				break;
 
-			/* src3/4/6_ctl = 0x0801f77f */
+			/* src3/4/6_ctl */
+			/* 0x1.f77f = (4 * 28636360/8 * 2/455) / 32000 */
 			cx25840_write4(client, 0x900, 0x0801f77f);
 			cx25840_write4(client, 0x904, 0x0801f77f);
 			cx25840_write4(client, 0x90c, 0x0801f77f);
 			break;
 
 		case 44100:
-			if (state->is_cx23885) {
-				/* We don't have register values
-				 * so avoid destroying registers. */
-				break;
-			}
-
-			if (!state->is_cx231xx) {
-				/* VID_PLL and AUX_PLL */
-				cx25840_write4(client, 0x108, 0x1009040f);
-
-				/* AUX_PLL_FRAC */
-				cx25840_write4(client, 0x110, 0x00ec6bd6);
-			}
+			/*
+			 * VID_PLL Integer = 0x0f, VID_PLL Post Divider = 0x04
+			 * AUX_PLL Integer = 0x09, AUX PLL Post Divider = 0x10
+			 */
+			cx25840_write4(client, 0x108, 0x1009040f);
+
+			/*
+			 * VID_PLL Fraction (register 0x10c) = 0x2be2fe
+			 * 28636360 * 0xf.15f17f0/4 = 108 MHz
+			 * 432 MHz pre-postdivide
+			 */
+
+			/*
+			 * AUX_PLL Fraction = 0x0ec6bd6
+			 * 28636363 * 0x9.7635eb0/0x10 = 44100 * 384
+			 * 271 MHz pre-postdivide
+			 * FIXME 28636363 ref_freq doesn't match VID PLL ref
+			 */
+			cx25840_write4(client, 0x110, 0x00ec6bd6);
+
+			/*
+			 * SA_MCLK_SEL = 1
+			 * SA_MCLK_DIV = 0x10 = 384/384 * AUX_PLL post dvivider
+			 */
+			cx25840_write(client, 0x127, 0x50);
 
-			if (state->is_cx25836)
+			if (is_cx2583x(state))
 				break;
 
-			/* src3/4/6_ctl = 0x08016d59 */
+			/* src3/4/6_ctl */
+			/* 0x1.6d59 = (4 * 28636360/8 * 2/455) / 44100 */
 			cx25840_write4(client, 0x900, 0x08016d59);
 			cx25840_write4(client, 0x904, 0x08016d59);
 			cx25840_write4(client, 0x90c, 0x08016d59);
 			break;
 
 		case 48000:
-			if (state->is_cx23885) {
-				/* We don't have register values
-				 * so avoid destroying registers. */
-				break;
-			}
-
-			if (!state->is_cx231xx) {
-				/* VID_PLL and AUX_PLL */
-				cx25840_write4(client, 0x108, 0x100a040f);
-
-				/* AUX_PLL_FRAC */
-				cx25840_write4(client, 0x110, 0x0098d6e5);
-			}
+			/*
+			 * VID_PLL Integer = 0x0f, VID_PLL Post Divider = 0x04
+			 * AUX_PLL Integer = 0x0a, AUX PLL Post Divider = 0x10
+			 */
+			cx25840_write4(client, 0x108, 0x100a040f);
+
+			/*
+			 * VID_PLL Fraction (register 0x10c) = 0x2be2fe
+			 * 28636360 * 0xf.15f17f0/4 = 108 MHz
+			 * 432 MHz pre-postdivide
+			 */
+
+			/*
+			 * AUX_PLL Fraction = 0x098d6e5
+			 * 28636363 * 0xa.4c6b728/0x10 = 48000 * 384
+			 * 295 MHz pre-postdivide
+			 * FIXME 28636363 ref_freq doesn't match VID PLL ref
+			 */
+			cx25840_write4(client, 0x110, 0x0098d6e5);
+
+			/*
+			 * SA_MCLK_SEL = 1
+			 * SA_MCLK_DIV = 0x10 = 384/384 * AUX_PLL post dvivider
+			 */
+			cx25840_write(client, 0x127, 0x50);
 
-			if (state->is_cx25836)
+			if (is_cx2583x(state))
 				break;
 
-			/* src3/4/6_ctl = 0x08014faa */
+			/* src3/4/6_ctl */
+			/* 0x1.4faa = (4 * 28636360/8 * 2/455) / 48000 */
 			cx25840_write4(client, 0x900, 0x08014faa);
 			cx25840_write4(client, 0x904, 0x08014faa);
 			cx25840_write4(client, 0x90c, 0x08014faa);
@@ -112,91 +163,249 @@
 	} else {
 		switch (freq) {
 		case 32000:
-			if (state->is_cx23885) {
-				/* We don't have register values
-				 * so avoid destroying registers. */
-				break;
-			}
-
-			if (!state->is_cx231xx) {
-				/* VID_PLL and AUX_PLL */
-				cx25840_write4(client, 0x108, 0x1e08040f);
-
-				/* AUX_PLL_FRAC */
-				cx25840_write4(client, 0x110, 0x012a0869);
-			}
+			/*
+			 * VID_PLL Integer = 0x0f, VID_PLL Post Divider = 0x04
+			 * AUX_PLL Integer = 0x08, AUX PLL Post Divider = 0x1e
+			 */
+			cx25840_write4(client, 0x108, 0x1e08040f);
+
+			/*
+			 * VID_PLL Fraction (register 0x10c) = 0x2be2fe
+			 * 28636360 * 0xf.15f17f0/4 = 108 MHz
+			 * 432 MHz pre-postdivide
+			 */
+
+			/*
+			 * AUX_PLL Fraction = 0x12a0869
+			 * 28636363 * 0x8.9504348/0x1e = 32000 * 256
+			 * 246 MHz pre-postdivide
+			 * FIXME 28636363 ref_freq doesn't match VID PLL ref
+			 */
+			cx25840_write4(client, 0x110, 0x012a0869);
+
+			/*
+			 * SA_MCLK_SEL = 1
+			 * SA_MCLK_DIV = 0x14 = 256/384 * AUX_PLL post dvivider
+			 */
+			cx25840_write(client, 0x127, 0x54);
 
-			if (state->is_cx25836)
+			if (is_cx2583x(state))
 				break;
 
-			/* src1_ctl = 0x08010000 */
+			/* src1_ctl */
+			/* 0x1.0000 = 32000/32000 */
 			cx25840_write4(client, 0x8f8, 0x08010000);
 
-			/* src3/4/6_ctl = 0x08020000 */
+			/* src3/4/6_ctl */
+			/* 0x2.0000 = 2 * (32000/32000) */
 			cx25840_write4(client, 0x900, 0x08020000);
 			cx25840_write4(client, 0x904, 0x08020000);
 			cx25840_write4(client, 0x90c, 0x08020000);
-
-			/* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
-			cx25840_write(client, 0x127, 0x54);
 			break;
 
 		case 44100:
-			if (state->is_cx23885) {
-				/* We don't have register values
-				 * so avoid destroying registers. */
+			/*
+			 * VID_PLL Integer = 0x0f, VID_PLL Post Divider = 0x04
+			 * AUX_PLL Integer = 0x09, AUX PLL Post Divider = 0x18
+			 */
+			cx25840_write4(client, 0x108, 0x1809040f);
+
+			/*
+			 * VID_PLL Fraction (register 0x10c) = 0x2be2fe
+			 * 28636360 * 0xf.15f17f0/4 = 108 MHz
+			 * 432 MHz pre-postdivide
+			 */
+
+			/*
+			 * AUX_PLL Fraction = 0x0ec6bd6
+			 * 28636363 * 0x9.7635eb0/0x18 = 44100 * 256
+			 * 271 MHz pre-postdivide
+			 * FIXME 28636363 ref_freq doesn't match VID PLL ref
+			 */
+			cx25840_write4(client, 0x110, 0x00ec6bd6);
+
+			/*
+			 * SA_MCLK_SEL = 1
+			 * SA_MCLK_DIV = 0x10 = 256/384 * AUX_PLL post dvivider
+			 */
+			cx25840_write(client, 0x127, 0x50);
+
+			if (is_cx2583x(state))
 				break;
-			}
 
+			/* src1_ctl */
+			/* 0x1.60cd = 44100/32000 */
+			cx25840_write4(client, 0x8f8, 0x080160cd);
+
+			/* src3/4/6_ctl */
+			/* 0x1.7385 = 2 * (32000/44100) */
+			cx25840_write4(client, 0x900, 0x08017385);
+			cx25840_write4(client, 0x904, 0x08017385);
+			cx25840_write4(client, 0x90c, 0x08017385);
+			break;
+
+		case 48000:
+			/*
+			 * VID_PLL Integer = 0x0f, VID_PLL Post Divider = 0x04
+			 * AUX_PLL Integer = 0x0a, AUX PLL Post Divider = 0x18
+			 */
+			cx25840_write4(client, 0x108, 0x180a040f);
+
+			/*
+			 * VID_PLL Fraction (register 0x10c) = 0x2be2fe
+			 * 28636360 * 0xf.15f17f0/4 = 108 MHz
+			 * 432 MHz pre-postdivide
+			 */
+
+			/*
+			 * AUX_PLL Fraction = 0x098d6e5
+			 * 28636363 * 0xa.4c6b728/0x18 = 48000 * 256
+			 * 295 MHz pre-postdivide
+			 * FIXME 28636363 ref_freq doesn't match VID PLL ref
+			 */
+			cx25840_write4(client, 0x110, 0x0098d6e5);
+
+			/*
+			 * SA_MCLK_SEL = 1
+			 * SA_MCLK_DIV = 0x10 = 256/384 * AUX_PLL post dvivider
+			 */
+			cx25840_write(client, 0x127, 0x50);
+
+			if (is_cx2583x(state))
+				break;
+
+			/* src1_ctl */
+			/* 0x1.8000 = 48000/32000 */
+			cx25840_write4(client, 0x8f8, 0x08018000);
+
+			/* src3/4/6_ctl */
+			/* 0x1.5555 = 2 * (32000/48000) */
+			cx25840_write4(client, 0x900, 0x08015555);
+			cx25840_write4(client, 0x904, 0x08015555);
+			cx25840_write4(client, 0x90c, 0x08015555);
+			break;
+		}
+	}
+
+	state->audclk_freq = freq;
 
-			if (!state->is_cx231xx) {
-				/* VID_PLL and AUX_PLL */
-				cx25840_write4(client, 0x108, 0x1809040f);
+	return 0;
+}
 
-				/* AUX_PLL_FRAC */
-				cx25840_write4(client, 0x110, 0x00ec6bd6);
-			}
+static inline int cx25836_set_audclk_freq(struct i2c_client *client, u32 freq)
+{
+	return cx25840_set_audclk_freq(client, freq);
+}
 
-			if (state->is_cx25836)
-				break;
+static int cx23885_set_audclk_freq(struct i2c_client *client, u32 freq)
+{
+	struct cx25840_state *state = to_state(i2c_get_clientdata(client));
+
+	if (state->aud_input != CX25840_AUDIO_SERIAL) {
+		switch (freq) {
+		case 32000:
+		case 44100:
+		case 48000:
+			/* We don't have register values
+			 * so avoid destroying registers. */
+			/* FIXME return -EINVAL; */
+			break;
+		}
+	} else {
+		switch (freq) {
+		case 32000:
+		case 44100:
+			/* We don't have register values
+			 * so avoid destroying registers. */
+			/* FIXME return -EINVAL; */
+			break;
+
+		case 48000:
+			/* src1_ctl */
+			/* 0x1.867c = 48000 / (2 * 28636360/8 * 2/455) */
+			cx25840_write4(client, 0x8f8, 0x0801867c);
+
+			/* src3/4/6_ctl */
+			/* 0x1.4faa = (4 * 28636360/8 * 2/455) / 48000 */
+			cx25840_write4(client, 0x900, 0x08014faa);
+			cx25840_write4(client, 0x904, 0x08014faa);
+			cx25840_write4(client, 0x90c, 0x08014faa);
+			break;
+		}
+	}
+
+	state->audclk_freq = freq;
+
+	return 0;
+}
+
+static int cx231xx_set_audclk_freq(struct i2c_client *client, u32 freq)
+{
+	struct cx25840_state *state = to_state(i2c_get_clientdata(client));
+
+	if (state->aud_input != CX25840_AUDIO_SERIAL) {
+		switch (freq) {
+		case 32000:
+			/* src3/4/6_ctl */
+			/* 0x1.f77f = (4 * 28636360/8 * 2/455) / 32000 */
+			cx25840_write4(client, 0x900, 0x0801f77f);
+			cx25840_write4(client, 0x904, 0x0801f77f);
+			cx25840_write4(client, 0x90c, 0x0801f77f);
+			break;
+
+		case 44100:
+			/* src3/4/6_ctl */
+			/* 0x1.6d59 = (4 * 28636360/8 * 2/455) / 44100 */
+			cx25840_write4(client, 0x900, 0x08016d59);
+			cx25840_write4(client, 0x904, 0x08016d59);
+			cx25840_write4(client, 0x90c, 0x08016d59);
+			break;
+
+		case 48000:
+			/* src3/4/6_ctl */
+			/* 0x1.4faa = (4 * 28636360/8 * 2/455) / 48000 */
+			cx25840_write4(client, 0x900, 0x08014faa);
+			cx25840_write4(client, 0x904, 0x08014faa);
+			cx25840_write4(client, 0x90c, 0x08014faa);
+			break;
+		}
+	} else {
+		switch (freq) {
+		/* FIXME These cases make different assumptions about audclk */
+		case 32000:
+			/* src1_ctl */
+			/* 0x1.0000 = 32000/32000 */
+			cx25840_write4(client, 0x8f8, 0x08010000);
 
-			/* src1_ctl = 0x08010000 */
+			/* src3/4/6_ctl */
+			/* 0x2.0000 = 2 * (32000/32000) */
+			cx25840_write4(client, 0x900, 0x08020000);
+			cx25840_write4(client, 0x904, 0x08020000);
+			cx25840_write4(client, 0x90c, 0x08020000);
+			break;
+
+		case 44100:
+			/* src1_ctl */
+			/* 0x1.60cd = 44100/32000 */
 			cx25840_write4(client, 0x8f8, 0x080160cd);
 
-			/* src3/4/6_ctl = 0x08020000 */
+			/* src3/4/6_ctl */
+			/* 0x1.7385 = 2 * (32000/44100) */
 			cx25840_write4(client, 0x900, 0x08017385);
 			cx25840_write4(client, 0x904, 0x08017385);
 			cx25840_write4(client, 0x90c, 0x08017385);
 			break;
 
 		case 48000:
-			if (!state->is_cx23885 && !state->is_cx231xx) {
-				/* VID_PLL and AUX_PLL */
-				cx25840_write4(client, 0x108, 0x180a040f);
-
-				/* AUX_PLL_FRAC */
-				cx25840_write4(client, 0x110, 0x0098d6e5);
-			}
-
-			if (state->is_cx25836)
-				break;
+			/* src1_ctl */
+			/* 0x1.867c = 48000 / (2 * 28636360/8 * 2/455) */
+			cx25840_write4(client, 0x8f8, 0x0801867c);
 
-			if (!state->is_cx23885 && !state->is_cx231xx) {
-				/* src1_ctl */
-				cx25840_write4(client, 0x8f8, 0x08018000);
-
-				/* src3/4/6_ctl */
-				cx25840_write4(client, 0x900, 0x08015555);
-				cx25840_write4(client, 0x904, 0x08015555);
-				cx25840_write4(client, 0x90c, 0x08015555);
-			} else {
-
-				cx25840_write4(client, 0x8f8, 0x0801867c);
-
-				cx25840_write4(client, 0x900, 0x08014faa);
-				cx25840_write4(client, 0x904, 0x08014faa);
-				cx25840_write4(client, 0x90c, 0x08014faa);
-			}
+			/* src3/4/6_ctl */
+			/* 0x1.4faa = (4 * 28636360/8 * 2/455) / 48000 */
+			cx25840_write4(client, 0x900, 0x08014faa);
+			cx25840_write4(client, 0x904, 0x08014faa);
+			cx25840_write4(client, 0x90c, 0x08014faa);
 			break;
 		}
 	}
@@ -206,6 +415,25 @@
 	return 0;
 }
 
+static int set_audclk_freq(struct i2c_client *client, u32 freq)
+{
+	struct cx25840_state *state = to_state(i2c_get_clientdata(client));
+
+	if (freq != 32000 && freq != 44100 && freq != 48000)
+		return -EINVAL;
+
+	if (is_cx231xx(state))
+		return cx231xx_set_audclk_freq(client, freq);
+
+	if (is_cx2388x(state))
+		return cx23885_set_audclk_freq(client, freq);
+
+	if (is_cx2583x(state))
+		return cx25836_set_audclk_freq(client, freq);
+
+	return cx25840_set_audclk_freq(client, freq);
+}
+
 void cx25840_audio_set_path(struct i2c_client *client)
 {
 	struct cx25840_state *state = to_state(i2c_get_clientdata(client));
@@ -243,7 +471,7 @@
 	cx25840_and_or(client, 0x810, ~0x1, 0x00);
 
 	/* Ensure the controller is running when we exit */
-	if (state->is_cx23885 || state->is_cx231xx)
+	if (is_cx2388x(state) || is_cx231xx(state))
 		cx25840_and_or(client, 0x803, ~0x10, 0x10);
 }
 
@@ -383,7 +611,7 @@
 	struct cx25840_state *state = to_state(sd);
 	int retval;
 
-	if (!state->is_cx25836)
+	if (!is_cx2583x(state))
 		cx25840_and_or(client, 0x810, ~0x1, 1);
 	if (state->aud_input != CX25840_AUDIO_SERIAL) {
 		cx25840_and_or(client, 0x803, ~0x10, 0);
@@ -392,7 +620,7 @@
 	retval = set_audclk_freq(client, freq);
 	if (state->aud_input != CX25840_AUDIO_SERIAL)
 		cx25840_and_or(client, 0x803, ~0x10, 0x10);
-	if (!state->is_cx25836)
+	if (!is_cx2583x(state))
 		cx25840_and_or(client, 0x810, ~0x1, 0);
 	return retval;
 }
cx25840-core.c +457 -95

859 lines not on this page · raw message

cx25840-core.h +20 -3
diff -u cx25840/cx25840-core.h cx25840-commell/cx25840-core.h
@@ -20,9 +20,11 @@
 #ifndef _CX25840_CORE_H_
 #define _CX25840_CORE_H_
 
+#include "compat.h"
 
 #include <linux/videodev2.h>
 #include <media/v4l2-device.h>
+#include <media/v4l2-chip-ident.h>
 #include <linux/i2c.h>
 
 /* ENABLE_PVR150_WORKAROUND activates a workaround for a hardware bug that is
@@ -48,9 +50,6 @@
 	int vbi_line_offset;
 	u32 id;
 	u32 rev;
-	int is_cx25836;
-	int is_cx23885;
-	int is_cx231xx;
 	int is_initialized;
 	wait_queue_head_t fw_wait;    /* wake up when the fw load is finished */
 	struct work_struct fw_work;   /* work entry for fw load */
@@ -61,6 +60,24 @@
 	return container_of(sd, struct cx25840_state, sd);
 }
 
+static inline bool is_cx2583x(struct cx25840_state *state)
+{
+	return state->id == V4L2_IDENT_CX25836 ||
+	       state->id == V4L2_IDENT_CX25837;
+}
+
+static inline bool is_cx231xx(struct cx25840_state *state)
+{
+	return state->id == V4L2_IDENT_CX2310X_AV;
+}
+
+static inline bool is_cx2388x(struct cx25840_state *state)
+{
+	return state->id == V4L2_IDENT_CX23885_AV ||
+	       state->id == V4L2_IDENT_CX23887_AV ||
+	       state->id == V4L2_IDENT_CX23888_AV;
+}
+
 /* ----------------------------------------------------------------------- */
 /* cx25850-core.c 							   */
 int cx25840_write(struct i2c_client *client, u16 addr, u8 value);
cx25840-firmware.c +38 -17

116 lines not on this page · raw message

Nur in cx25840: cx25840.mod.c.

cx25840-vbi.c +1 -0
diff -u cx25840/cx25840-vbi.c cx25840-commell/cx25840-vbi.c
@@ -20,6 +20,7 @@
 #include <linux/i2c.h>
 #include <media/v4l2-common.h>
 #include <media/cx25840.h>
+#include "compat.h"
 
 #include "cx25840-core.h"
 

Nur in cx25840: modules.order.

#17 lore raw
In reply to Michael
Quoted 9 lines · Michael

So, does this imply that you see a chance to get this card running? :-)

If so, I will order one card and try. There is not much I want to do with the card. It should simply digitize an external camera signal. I want to display it with mplayer. It should, however, be reliable and not crash the system or drop the stream or whatever.

So far, it seems that this is the only mini-pcie video digitizer card that exists. I would have taken a bttv based one instead, but as there is none...

I would probably advise against using a cx23885 based design for analog under Linux right now. There is *some* analog support in the driver, but it is not very mature and has a host of issues/bugs. Also, there is currently no analog audio support in the driver, so if you do not have an encoder then it will not work.

In other words, even if all you did need was to add another PCI ID, you would still be very likely to run into problems.

We (KernelLabs) have a handful of patches that can eventually get into the upstream driver, although right now progress is slow on that front and you certainly shouldn't buy hardware based on the expectation that the patches are forthcoming.

Devin

Signature · 2 lines
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
author
#18 lore raw
Quoted 6 lines · Devin Heitmueller

I would probably advise against using a cx23885 based design for analog under Linux right now. There is *some* analog support in the driver, but it is not very mature and has a host of issues/bugs. Also, there is currently no analog audio support in the driver, so if you do not have an encoder then it will not work.

Well, I don't need audio, just video. A raw stream is everything I need, as it is displayed by mplayer directly.

But you mean that this most probably wouldn't work as the analog support is not good enough for the time being?

Quoted 8 lines

In other words, even if all you did need was to add another PCI ID, you would still be very likely to run into problems.

We (KernelLabs) have a handful of patches that can eventually get into the upstream driver, although right now progress is slow on that front and you certainly shouldn't buy hardware based on the expectation that the patches are forthcoming.

Well, would these patches help me to get the card working for my purpose (raw video stream)? I don't mind patching the driver. I am no developer, but applying a patch and compiling the driver I should manage.

Otherwise do you know another mini-pci-express video capture card that is supported by the linux kernel?

Thanks for your help

Michael

Quoted 2 lines

Devin