diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2006-01-09 12:25:11 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2006-01-09 12:25:11 -0500 |
commit | 2aeb49b6884c3719eedaa96f0752b9d5e0609fe3 (patch) | |
tree | f3ff6df1f68bb1d1fceac0e44295404083956b06 /drivers/media/video/msp3400.c | |
parent | 14725165dd2e25a54315a2350d332b49635ed6c1 (diff) |
V4L/DVB (3065): Fix gcc-4.0.2 compile error in msp3400.c
- Fix gcc-4.0.2 compile error in msp3400.c.
- msp_attach moved to reduce a prototype.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'drivers/media/video/msp3400.c')
-rw-r--r-- | drivers/media/video/msp3400.c | 292 |
1 files changed, 165 insertions, 127 deletions
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 64691d553a96..fc2896bc42c0 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c | |||
@@ -157,9 +157,6 @@ struct msp3400c { | |||
157 | #define HAVE_SIMPLER(msp) ((msp->rev1 & 0xff) >= 'G'-'@') | 157 | #define HAVE_SIMPLER(msp) ((msp->rev1 & 0xff) >= 'G'-'@') |
158 | #define HAVE_RADIO(msp) ((msp->rev1 & 0xff) >= 'G'-'@') | 158 | #define HAVE_RADIO(msp) ((msp->rev1 & 0xff) >= 'G'-'@') |
159 | 159 | ||
160 | /* defined at the end of the source */ | ||
161 | extern struct i2c_client client_template; | ||
162 | |||
163 | #define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ | 160 | #define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ |
164 | 161 | ||
165 | /* ---------------------------------------------------------------------- */ | 162 | /* ---------------------------------------------------------------------- */ |
@@ -1568,130 +1565,6 @@ static void msp_wake_thread(struct i2c_client *client) | |||
1568 | wake_up_interruptible(&msp->wq); | 1565 | wake_up_interruptible(&msp->wq); |
1569 | } | 1566 | } |
1570 | 1567 | ||
1571 | static int msp_attach(struct i2c_adapter *adap, int addr, int kind) | ||
1572 | { | ||
1573 | struct msp3400c *msp; | ||
1574 | struct i2c_client *client = &client_template; | ||
1575 | int (*thread_func)(void *data) = NULL; | ||
1576 | int i; | ||
1577 | |||
1578 | client_template.adapter = adap; | ||
1579 | client_template.addr = addr; | ||
1580 | |||
1581 | if (-1 == msp3400c_reset(&client_template)) { | ||
1582 | msp3400_dbg("no chip found\n"); | ||
1583 | return -1; | ||
1584 | } | ||
1585 | |||
1586 | if (NULL == (client = kmalloc(sizeof(struct i2c_client),GFP_KERNEL))) | ||
1587 | return -ENOMEM; | ||
1588 | memcpy(client,&client_template,sizeof(struct i2c_client)); | ||
1589 | if (NULL == (msp = kmalloc(sizeof(struct msp3400c),GFP_KERNEL))) { | ||
1590 | kfree(client); | ||
1591 | return -ENOMEM; | ||
1592 | } | ||
1593 | |||
1594 | memset(msp,0,sizeof(struct msp3400c)); | ||
1595 | msp->norm = VIDEO_MODE_NTSC; | ||
1596 | msp->left = 58880; /* 0db gain */ | ||
1597 | msp->right = 58880; /* 0db gain */ | ||
1598 | msp->bass = 32768; | ||
1599 | msp->treble = 32768; | ||
1600 | msp->input = -1; | ||
1601 | msp->muted = 0; | ||
1602 | msp->i2s_mode = 0; | ||
1603 | for (i = 0; i < DFP_COUNT; i++) | ||
1604 | msp->dfp_regs[i] = -1; | ||
1605 | |||
1606 | i2c_set_clientdata(client, msp); | ||
1607 | init_waitqueue_head(&msp->wq); | ||
1608 | |||
1609 | if (-1 == msp3400c_reset(client)) { | ||
1610 | kfree(msp); | ||
1611 | kfree(client); | ||
1612 | msp3400_dbg("no chip found\n"); | ||
1613 | return -1; | ||
1614 | } | ||
1615 | |||
1616 | msp->rev1 = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1e); | ||
1617 | if (-1 != msp->rev1) | ||
1618 | msp->rev2 = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1f); | ||
1619 | if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) { | ||
1620 | kfree(msp); | ||
1621 | kfree(client); | ||
1622 | msp3400_dbg("error while reading chip version\n"); | ||
1623 | return -1; | ||
1624 | } | ||
1625 | msp3400_dbg("rev1=0x%04x, rev2=0x%04x\n", msp->rev1, msp->rev2); | ||
1626 | |||
1627 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); | ||
1628 | |||
1629 | snprintf(client->name, sizeof(client->name), "MSP%c4%02d%c-%c%d", | ||
1630 | ((msp->rev1>>4)&0x0f) + '3', | ||
1631 | (msp->rev2>>8)&0xff, (msp->rev1&0x0f)+'@', | ||
1632 | ((msp->rev1>>8)&0xff)+'@', msp->rev2&0x1f); | ||
1633 | |||
1634 | msp->opmode = opmode; | ||
1635 | if (OPMODE_AUTO == msp->opmode) { | ||
1636 | if (HAVE_SIMPLER(msp)) | ||
1637 | msp->opmode = OPMODE_SIMPLER; | ||
1638 | else if (HAVE_SIMPLE(msp)) | ||
1639 | msp->opmode = OPMODE_SIMPLE; | ||
1640 | else | ||
1641 | msp->opmode = OPMODE_MANUAL; | ||
1642 | } | ||
1643 | |||
1644 | /* hello world :-) */ | ||
1645 | msp3400_info("chip=%s", client->name); | ||
1646 | if (HAVE_NICAM(msp)) | ||
1647 | printk(" +nicam"); | ||
1648 | if (HAVE_SIMPLE(msp)) | ||
1649 | printk(" +simple"); | ||
1650 | if (HAVE_SIMPLER(msp)) | ||
1651 | printk(" +simpler"); | ||
1652 | if (HAVE_RADIO(msp)) | ||
1653 | printk(" +radio"); | ||
1654 | |||
1655 | /* version-specific initialization */ | ||
1656 | switch (msp->opmode) { | ||
1657 | case OPMODE_MANUAL: | ||
1658 | printk(" mode=manual"); | ||
1659 | thread_func = msp3400c_thread; | ||
1660 | break; | ||
1661 | case OPMODE_SIMPLE: | ||
1662 | printk(" mode=simple"); | ||
1663 | thread_func = msp3410d_thread; | ||
1664 | break; | ||
1665 | case OPMODE_SIMPLER: | ||
1666 | printk(" mode=simpler"); | ||
1667 | thread_func = msp34xxg_thread; | ||
1668 | break; | ||
1669 | } | ||
1670 | printk("\n"); | ||
1671 | |||
1672 | /* startup control thread if needed */ | ||
1673 | if (thread_func) { | ||
1674 | msp->kthread = kthread_run(thread_func, client, "msp34xx"); | ||
1675 | |||
1676 | if (NULL == msp->kthread) | ||
1677 | msp3400_warn("kernel_thread() failed\n"); | ||
1678 | msp_wake_thread(client); | ||
1679 | } | ||
1680 | |||
1681 | /* done */ | ||
1682 | i2c_attach_client(client); | ||
1683 | |||
1684 | /* update our own array */ | ||
1685 | for (i = 0; i < MSP3400_MAX; i++) { | ||
1686 | if (NULL == msps[i]) { | ||
1687 | msps[i] = client; | ||
1688 | break; | ||
1689 | } | ||
1690 | } | ||
1691 | |||
1692 | return 0; | ||
1693 | } | ||
1694 | |||
1695 | static int msp_detach(struct i2c_client *client) | 1568 | static int msp_detach(struct i2c_client *client) |
1696 | { | 1569 | { |
1697 | struct msp3400c *msp = i2c_get_clientdata(client); | 1570 | struct msp3400c *msp = i2c_get_clientdata(client); |
@@ -2182,6 +2055,9 @@ static int msp_resume(struct device * dev) | |||
2182 | 2055 | ||
2183 | /* ----------------------------------------------------------------------- */ | 2056 | /* ----------------------------------------------------------------------- */ |
2184 | 2057 | ||
2058 | static int msp_probe(struct i2c_adapter *adap); | ||
2059 | static int msp_detach(struct i2c_client *client); | ||
2060 | |||
2185 | static struct i2c_driver driver = { | 2061 | static struct i2c_driver driver = { |
2186 | .owner = THIS_MODULE, | 2062 | .owner = THIS_MODULE, |
2187 | .name = "msp3400", | 2063 | .name = "msp3400", |
@@ -2203,6 +2079,168 @@ static struct i2c_client client_template = | |||
2203 | .driver = &driver, | 2079 | .driver = &driver, |
2204 | }; | 2080 | }; |
2205 | 2081 | ||
2082 | static int msp_attach(struct i2c_adapter *adap, int addr, int kind) | ||
2083 | { | ||
2084 | struct msp3400c *msp; | ||
2085 | struct i2c_client *client = &client_template; | ||
2086 | int (*thread_func)(void *data) = NULL; | ||
2087 | int i; | ||
2088 | |||
2089 | client_template.adapter = adap; | ||
2090 | client_template.addr = addr; | ||
2091 | |||
2092 | if (-1 == msp3400c_reset(&client_template)) { | ||
2093 | msp3400_dbg("no chip found\n"); | ||
2094 | return -1; | ||
2095 | } | ||
2096 | |||
2097 | if (NULL == (client = kmalloc(sizeof(struct i2c_client),GFP_KERNEL))) | ||
2098 | return -ENOMEM; | ||
2099 | memcpy(client,&client_template,sizeof(struct i2c_client)); | ||
2100 | if (NULL == (msp = kmalloc(sizeof(struct msp3400c),GFP_KERNEL))) { | ||
2101 | kfree(client); | ||
2102 | return -ENOMEM; | ||
2103 | } | ||
2104 | |||
2105 | memset(msp,0,sizeof(struct msp3400c)); | ||
2106 | msp->norm = VIDEO_MODE_NTSC; | ||
2107 | msp->left = 58880; /* 0db gain */ | ||
2108 | msp->right = 58880; /* 0db gain */ | ||
2109 | msp->bass = 32768; | ||
2110 | msp->treble = 32768; | ||
2111 | msp->input = -1; | ||
2112 | msp->muted = 0; | ||
2113 | msp->i2s_mode = 0; | ||
2114 | for (i = 0; i < DFP_COUNT; i++) | ||
2115 | msp->dfp_regs[i] = -1; | ||
2116 | |||
2117 | i2c_set_clientdata(client, msp); | ||
2118 | init_waitqueue_head(&msp->wq); | ||
2119 | |||
2120 | if (-1 == msp3400c_reset(client)) { | ||
2121 | kfree(msp); | ||
2122 | kfree(client); | ||
2123 | msp3400_dbg("no chip found\n"); | ||
2124 | return -1; | ||
2125 | } | ||
2126 | |||
2127 | msp->rev1 = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1e); | ||
2128 | if (-1 != msp->rev1) | ||
2129 | msp->rev2 = msp3400c_read(client, I2C_MSP3400C_DFP, 0x1f); | ||
2130 | if ((-1 == msp->rev1) || (0 == msp->rev1 && 0 == msp->rev2)) { | ||
2131 | kfree(msp); | ||
2132 | kfree(client); | ||
2133 | msp3400_dbg("error while reading chip version\n"); | ||
2134 | return -1; | ||
2135 | } | ||
2136 | msp3400_dbg("rev1=0x%04x, rev2=0x%04x\n", msp->rev1, msp->rev2); | ||
2137 | |||
2138 | msp3400c_setvolume(client, msp->muted, msp->left, msp->right); | ||
2139 | |||
2140 | snprintf(client->name, sizeof(client->name), "MSP%c4%02d%c-%c%d", | ||
2141 | ((msp->rev1>>4)&0x0f) + '3', | ||
2142 | (msp->rev2>>8)&0xff, (msp->rev1&0x0f)+'@', | ||
2143 | ((msp->rev1>>8)&0xff)+'@', msp->rev2&0x1f); | ||
2144 | |||
2145 | msp->opmode = opmode; | ||
2146 | if (OPMODE_AUTO == msp->opmode) { | ||
2147 | if (HAVE_SIMPLER(msp)) | ||
2148 | msp->opmode = OPMODE_SIMPLER; | ||
2149 | else if (HAVE_SIMPLE(msp)) | ||
2150 | msp->opmode = OPMODE_SIMPLE; | ||
2151 | else | ||
2152 | msp->opmode = OPMODE_MANUAL; | ||
2153 | } | ||
2154 | |||
2155 | /* hello world :-) */ | ||
2156 | msp3400_info("chip=%s", client->name); | ||
2157 | if (HAVE_NICAM(msp)) | ||
2158 | printk(" +nicam"); | ||
2159 | if (HAVE_SIMPLE(msp)) | ||
2160 | printk(" +simple"); | ||
2161 | if (HAVE_SIMPLER(msp)) | ||
2162 | printk(" +simpler"); | ||
2163 | if (HAVE_RADIO(msp)) | ||
2164 | printk(" +radio"); | ||
2165 | |||
2166 | /* version-specific initialization */ | ||
2167 | switch (msp->opmode) { | ||
2168 | case OPMODE_MANUAL: | ||
2169 | printk(" mode=manual"); | ||
2170 | thread_func = msp3400c_thread; | ||
2171 | break; | ||
2172 | case OPMODE_SIMPLE: | ||
2173 | printk(" mode=simple"); | ||
2174 | thread_func = msp3410d_thread; | ||
2175 | break; | ||
2176 | case OPMODE_SIMPLER: | ||
2177 | printk(" mode=simpler"); | ||
2178 | thread_func = msp34xxg_thread; | ||
2179 | break; | ||
2180 | } | ||
2181 | printk("\n"); | ||
2182 | |||
2183 | /* startup control thread if needed */ | ||
2184 | if (thread_func) { | ||
2185 | msp->kthread = kthread_run(thread_func, client, "msp34xx"); | ||
2186 | |||
2187 | if (NULL == msp->kthread) | ||
2188 | msp3400_warn("kernel_thread() failed\n"); | ||
2189 | msp_wake_thread(client); | ||
2190 | } | ||
2191 | |||
2192 | /* done */ | ||
2193 | i2c_attach_client(client); | ||
2194 | |||
2195 | /* update our own array */ | ||
2196 | for (i = 0; i < MSP3400_MAX; i++) { | ||
2197 | if (NULL == msps[i]) { | ||
2198 | msps[i] = client; | ||
2199 | break; | ||
2200 | } | ||
2201 | } | ||
2202 | |||
2203 | return 0; | ||
2204 | } | ||
2205 | |||
2206 | static int msp_detach(struct i2c_client *client) | ||
2207 | { | ||
2208 | struct msp3400c *msp = i2c_get_clientdata(client); | ||
2209 | int i; | ||
2210 | |||
2211 | /* shutdown control thread */ | ||
2212 | if (msp->kthread) { | ||
2213 | msp->restart = 1; | ||
2214 | kthread_stop(msp->kthread); | ||
2215 | } | ||
2216 | msp3400c_reset(client); | ||
2217 | |||
2218 | /* update our own array */ | ||
2219 | for (i = 0; i < MSP3400_MAX; i++) { | ||
2220 | if (client == msps[i]) { | ||
2221 | msps[i] = NULL; | ||
2222 | break; | ||
2223 | } | ||
2224 | } | ||
2225 | |||
2226 | i2c_detach_client(client); | ||
2227 | |||
2228 | kfree(msp); | ||
2229 | kfree(client); | ||
2230 | return 0; | ||
2231 | } | ||
2232 | |||
2233 | static int msp_probe(struct i2c_adapter *adap) | ||
2234 | { | ||
2235 | #ifdef I2C_CLASS_TV_ANALOG | ||
2236 | if (adap->class & I2C_CLASS_TV_ANALOG) | ||
2237 | return i2c_probe(adap, &addr_data, msp_attach); | ||
2238 | return 0; | ||
2239 | #else | ||
2240 | return i2c_probe(adap, &addr_data, msp_attach); | ||
2241 | #endif | ||
2242 | } | ||
2243 | |||
2206 | static int __init msp3400_init_module(void) | 2244 | static int __init msp3400_init_module(void) |
2207 | { | 2245 | { |
2208 | return i2c_add_driver(&driver); | 2246 | return i2c_add_driver(&driver); |