Commit 4971461f authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] Fix mxb.c stack usage

This does the following:
 - make initialization data for helper chipsets (saa7111 and saa7740)
   static and with file scope

Additionally fixes:
 - don't use irq driven i2c transfer when saa7740 is present (this screws
   up the i2c bus and may hang the computer)
 - add MODULE_DEVICE_TABLE to allow /sbin/hotplug to handle the device
parent ad6d2e6d
...@@ -177,6 +177,9 @@ struct mxb ...@@ -177,6 +177,9 @@ struct mxb
int cur_mute; /* current mute status */ int cur_mute; /* current mute status */
}; };
static
struct saa7146_extension extension;
static int mxb_vbi_bypass(struct saa7146_dev* dev) static int mxb_vbi_bypass(struct saa7146_dev* dev)
{ {
struct mxb* mxb = (struct mxb*)dev->ext_priv; struct mxb* mxb = (struct mxb*)dev->ext_priv;
...@@ -269,18 +272,12 @@ static int mxb_probe(struct saa7146_dev* dev) ...@@ -269,18 +272,12 @@ static int mxb_probe(struct saa7146_dev* dev)
return 0; return 0;
} }
/* bring hardware to a sane state. this has to be done, just in case someone /* some init data for the saa7740, the so-called 'sound arena module'.
wants to capture from this device before it has been properly initialized. there are no specs available, so we simply use some init values */
the capture engine would badly fail, because no valid signal arrives on the static struct {
saa7146, thus leading to timeouts and stuff. */
static int mxb_init_done(struct saa7146_dev* dev)
{
struct mxb* mxb = (struct mxb*)dev->ext_priv;
struct {
int length; int length;
char data[9]; char data[9];
} saa7740_init[] = { } mxb_saa7740_init[] = {
{ 3, { 0x80, 0x00, 0x00 } },{ 3, { 0x80, 0x89, 0x00 } }, { 3, { 0x80, 0x00, 0x00 } },{ 3, { 0x80, 0x89, 0x00 } },
{ 3, { 0x80, 0xb0, 0x0a } },{ 3, { 0x00, 0x00, 0x00 } }, { 3, { 0x80, 0xb0, 0x0a } },{ 3, { 0x00, 0x00, 0x00 } },
{ 3, { 0x49, 0x00, 0x00 } },{ 3, { 0x4a, 0x00, 0x00 } }, { 3, { 0x49, 0x00, 0x00 } },{ 3, { 0x4a, 0x00, 0x00 } },
...@@ -329,9 +326,9 @@ static int mxb_init_done(struct saa7146_dev* dev) ...@@ -329,9 +326,9 @@ static int mxb_init_done(struct saa7146_dev* dev)
{ 9, { 0x3d, 0xed, 0xd0, 0x68, 0x29, 0xb4, 0xe1, 0x00, 0xb8 } }, { 9, { 0x3d, 0xed, 0xd0, 0x68, 0x29, 0xb4, 0xe1, 0x00, 0xb8 } },
{ 3, { 0x80, 0xb3, 0x0a } }, { 3, { 0x80, 0xb3, 0x0a } },
{-1, { 0} } {-1, { 0} }
}; };
unsigned char init[25] = { static unsigned char mxb_saa7111_init[25] = {
0x00, 0x00,
0x00, /* 00 - ID byte */ 0x00, /* 00 - ID byte */
...@@ -362,7 +359,15 @@ static int mxb_init_done(struct saa7146_dev* dev) ...@@ -362,7 +359,15 @@ static int mxb_init_done(struct saa7146_dev* dev)
0x15, /* 15 - VBI */ 0x15, /* 15 - VBI */
0x04, /* 16 - VBI */ 0x04, /* 16 - VBI */
0x00, /* 17 - VBI */ 0x00, /* 17 - VBI */
}; };
/* bring hardware to a sane state. this has to be done, just in case someone
wants to capture from this device before it has been properly initialized.
the capture engine would badly fail, because no valid signal arrives on the
saa7146, thus leading to timeouts and stuff. */
static int mxb_init_done(struct saa7146_dev* dev)
{
struct mxb* mxb = (struct mxb*)dev->ext_priv;
struct i2c_msg msg; struct i2c_msg msg;
...@@ -370,7 +375,7 @@ static int mxb_init_done(struct saa7146_dev* dev) ...@@ -370,7 +375,7 @@ static int mxb_init_done(struct saa7146_dev* dev)
struct tea6415c_multiplex vm; struct tea6415c_multiplex vm;
/* write configuration to saa7111a */ /* write configuration to saa7111a */
i = i2c_master_send(mxb->saa7111a, init, sizeof(init)); i = i2c_master_send(mxb->saa7111a, mxb_saa7111_init, sizeof(mxb_saa7111_init));
if (i < 0) { if (i < 0) {
printk("failed to initialize saa7111a. this should never happen.\n"); printk("failed to initialize saa7111a. this should never happen.\n");
} }
...@@ -420,16 +425,22 @@ static int mxb_init_done(struct saa7146_dev* dev) ...@@ -420,16 +425,22 @@ static int mxb_init_done(struct saa7146_dev* dev)
engineered. */ engineered. */
msg.addr = 0x1b; msg.addr = 0x1b;
msg.flags = 0; msg.flags = 0;
msg.len = saa7740_init[0].length; msg.len = mxb_saa7740_init[0].length;
msg.buf = &saa7740_init[0].data[0]; msg.buf = &mxb_saa7740_init[0].data[0];
if( 1 == (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) { if( 1 == (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) {
/* the sound arena module is a pos, that's probably the reason
philips refuses to hand out a datasheet for the saa7740...
it seems to screw up the i2c bus, so we disable fast irq
based i2c transactions here and rely on the slow and safe
polling method ... */
extension.flags &= ~SAA7146_USE_I2C_IRQ;
for(i = 1;;i++) { for(i = 1;;i++) {
msg.len = saa7740_init[i].length; msg.len = mxb_saa7740_init[i].length;
if (msg.len == -1U) { if (msg.len == -1U) {
break; break;
} }
msg.buf = &saa7740_init[i].data[0]; msg.buf = &mxb_saa7740_init[i].data[0];
if( 1 != (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) { if( 1 != (err = i2c_transfer(&mxb->i2c_adapter, &msg, 1))) {
DEB_D(("failed to initialize 'sound arena module'.\n")); DEB_D(("failed to initialize 'sound arena module'.\n"));
goto err; goto err;
...@@ -1002,9 +1013,6 @@ static struct saa7146_standard standard[] = { ...@@ -1002,9 +1013,6 @@ static struct saa7146_standard standard[] = {
{ "SECAM", V4L2_STD_SECAM, SAA7146_SECAM_VALUES }, { "SECAM", V4L2_STD_SECAM, SAA7146_SECAM_VALUES },
}; };
static
struct saa7146_extension extension;
static static
struct saa7146_pci_extension_data mxb = { struct saa7146_pci_extension_data mxb = {
.ext_priv = "Multimedia eXtension Board", .ext_priv = "Multimedia eXtension Board",
...@@ -1024,6 +1032,8 @@ struct pci_device_id pci_tbl[] = { ...@@ -1024,6 +1032,8 @@ struct pci_device_id pci_tbl[] = {
} }
}; };
MODULE_DEVICE_TABLE(pci, pci_tbl);
static static
struct saa7146_ext_vv vv_data = { struct saa7146_ext_vv vv_data = {
.inputs = MXB_INPUTS, .inputs = MXB_INPUTS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment