summaryrefslogtreecommitdiffstats
path: root/drivers/media/video/msp3400-kthreads.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/msp3400-kthreads.c')
-rw-r--r--drivers/media/video/msp3400-kthreads.c166
1 files changed, 98 insertions, 68 deletions
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index d5ee2629121e..61ec794a737e 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -15,7 +15,8 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
*/
@@ -78,37 +79,37 @@ static struct msp3400c_init_data_dem {
{75, 19, 36, 35, 39, 40},
MSP_CARRIER(5.5), MSP_CARRIER(5.5),
0x00d0, 0x0500, 0x0020, 0x3000
- },{ /* AM (for carrier detect / msp3410) */
+ }, { /* AM (for carrier detect / msp3410) */
{-1, -1, -8, 2, 59, 126},
{-1, -1, -8, 2, 59, 126},
MSP_CARRIER(5.5), MSP_CARRIER(5.5),
0x00d0, 0x0100, 0x0020, 0x3000
- },{ /* FM Radio */
+ }, { /* FM Radio */
{-8, -8, 4, 6, 78, 107},
{-8, -8, 4, 6, 78, 107},
MSP_CARRIER(10.7), MSP_CARRIER(10.7),
0x00d0, 0x0480, 0x0020, 0x3000
- },{ /* Terrestial FM-mono + FM-stereo */
+ }, { /* Terrestial FM-mono + FM-stereo */
{3, 18, 27, 48, 66, 72},
{3, 18, 27, 48, 66, 72},
MSP_CARRIER(5.5), MSP_CARRIER(5.5),
0x00d0, 0x0480, 0x0030, 0x3000
- },{ /* Sat FM-mono */
+ }, { /* Sat FM-mono */
{ 1, 9, 14, 24, 33, 37},
{ 3, 18, 27, 48, 66, 72},
MSP_CARRIER(6.5), MSP_CARRIER(6.5),
0x00c6, 0x0480, 0x0000, 0x3000
- },{ /* NICAM/FM -- B/G (5.5/5.85), D/K (6.5/5.85) */
+ }, { /* NICAM/FM -- B/G (5.5/5.85), D/K (6.5/5.85) */
{-2, -8, -10, 10, 50, 86},
{3, 18, 27, 48, 66, 72},
MSP_CARRIER(5.5), MSP_CARRIER(5.5),
0x00d0, 0x0040, 0x0120, 0x3000
- },{ /* NICAM/FM -- I (6.0/6.552) */
+ }, { /* NICAM/FM -- I (6.0/6.552) */
{2, 4, -6, -4, 40, 94},
{3, 18, 27, 48, 66, 72},
MSP_CARRIER(6.0), MSP_CARRIER(6.0),
0x00d0, 0x0040, 0x0120, 0x3000
- },{ /* NICAM/AM -- L (6.5/5.85) */
+ }, { /* NICAM/AM -- L (6.5/5.85) */
{-2, -8, -10, 10, 50, 86},
{-4, -12, -9, 23, 79, 126},
MSP_CARRIER(6.5), MSP_CARRIER(6.5),
@@ -224,7 +225,9 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
nor do they support stereo BTSC. */
static void msp3400c_set_audmode(struct i2c_client *client)
{
- static char *strmode[] = { "mono", "stereo", "lang2", "lang1", "lang1+lang2" };
+ static char *strmode[] = {
+ "mono", "stereo", "lang2", "lang1", "lang1+lang2"
+ };
struct msp_state *state = i2c_get_clientdata(client);
char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
strmode[state->audmode] : "unknown";
@@ -298,19 +301,23 @@ static void msp3400c_set_audmode(struct i2c_client *client)
case MSP_MODE_FM_NICAM1:
case MSP_MODE_FM_NICAM2:
case MSP_MODE_AM_NICAM:
- v4l_dbg(1, msp_debug, client, "NICAM set_audmode: %s\n",modestr);
+ v4l_dbg(1, msp_debug, client,
+ "NICAM set_audmode: %s\n", modestr);
if (state->nicam_on)
src = 0x0100; /* NICAM */
break;
case MSP_MODE_BTSC:
- v4l_dbg(1, msp_debug, client, "BTSC set_audmode: %s\n",modestr);
+ v4l_dbg(1, msp_debug, client,
+ "BTSC set_audmode: %s\n", modestr);
break;
case MSP_MODE_EXTERN:
- v4l_dbg(1, msp_debug, client, "extern set_audmode: %s\n",modestr);
+ v4l_dbg(1, msp_debug, client,
+ "extern set_audmode: %s\n", modestr);
src = 0x0200; /* SCART */
break;
case MSP_MODE_FM_RADIO:
- v4l_dbg(1, msp_debug, client, "FM-Radio set_audmode: %s\n",modestr);
+ v4l_dbg(1, msp_debug, client,
+ "FM-Radio set_audmode: %s\n", modestr);
break;
default:
v4l_dbg(1, msp_debug, client, "mono set_audmode\n");
@@ -342,7 +349,8 @@ static void msp3400c_set_audmode(struct i2c_client *client)
src |= 0x0010;
break;
}
- v4l_dbg(1, msp_debug, client, "set_audmode final source/matrix = 0x%x\n", src);
+ v4l_dbg(1, msp_debug, client,
+ "set_audmode final source/matrix = 0x%x\n", src);
msp_set_source(client, src);
}
@@ -351,22 +359,26 @@ static void msp3400c_print_mode(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
- if (state->main == state->second) {
- v4l_dbg(1, msp_debug, client, "mono sound carrier: %d.%03d MHz\n",
- state->main / 910000, (state->main / 910) % 1000);
- } else {
- v4l_dbg(1, msp_debug, client, "main sound carrier: %d.%03d MHz\n",
- state->main / 910000, (state->main / 910) % 1000);
- }
+ if (state->main == state->second)
+ v4l_dbg(1, msp_debug, client,
+ "mono sound carrier: %d.%03d MHz\n",
+ state->main / 910000, (state->main / 910) % 1000);
+ else
+ v4l_dbg(1, msp_debug, client,
+ "main sound carrier: %d.%03d MHz\n",
+ state->main / 910000, (state->main / 910) % 1000);
if (state->mode == MSP_MODE_FM_NICAM1 || state->mode == MSP_MODE_FM_NICAM2)
- v4l_dbg(1, msp_debug, client, "NICAM/FM carrier : %d.%03d MHz\n",
- state->second / 910000, (state->second/910) % 1000);
+ v4l_dbg(1, msp_debug, client,
+ "NICAM/FM carrier : %d.%03d MHz\n",
+ state->second / 910000, (state->second/910) % 1000);
if (state->mode == MSP_MODE_AM_NICAM)
- v4l_dbg(1, msp_debug, client, "NICAM/AM carrier : %d.%03d MHz\n",
- state->second / 910000, (state->second / 910) % 1000);
+ v4l_dbg(1, msp_debug, client,
+ "NICAM/AM carrier : %d.%03d MHz\n",
+ state->second / 910000, (state->second / 910) % 1000);
if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) {
- v4l_dbg(1, msp_debug, client, "FM-stereo carrier : %d.%03d MHz\n",
- state->second / 910000, (state->second / 910) % 1000);
+ v4l_dbg(1, msp_debug, client,
+ "FM-stereo carrier : %d.%03d MHz\n",
+ state->second / 910000, (state->second / 910) % 1000);
}
}
@@ -385,7 +397,8 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
val = msp_read_dsp(client, 0x18);
if (val > 32767)
val -= 65536;
- v4l_dbg(2, msp_debug, client, "stereo detect register: %d\n", val);
+ v4l_dbg(2, msp_debug, client,
+ "stereo detect register: %d\n", val);
if (val > 8192) {
rxsubchans = V4L2_TUNER_SUB_STEREO;
} else if (val < -4096) {
@@ -430,7 +443,8 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
}
if (rxsubchans != state->rxsubchans) {
update = 1;
- v4l_dbg(1, msp_debug, client, "watch: rxsubchans %02x => %02x\n",
+ v4l_dbg(1, msp_debug, client,
+ "watch: rxsubchans %02x => %02x\n",
state->rxsubchans, rxsubchans);
state->rxsubchans = rxsubchans;
}
@@ -452,9 +466,8 @@ static void watch_stereo(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
- if (msp_detect_stereo(client)) {
+ if (msp_detect_stereo(client))
msp_set_audmode(client);
- }
if (msp_once)
state->watch_stereo = 0;
@@ -465,7 +478,7 @@ int msp3400c_thread(void *data)
struct i2c_client *client = data;
struct msp_state *state = i2c_get_clientdata(client);
struct msp3400c_carrier_detect *cd;
- int count, max1, max2, val1, val2, val, this;
+ int count, max1, max2, val1, val2, val, i;
v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n");
@@ -475,7 +488,7 @@ int msp3400c_thread(void *data)
msp_sleep(state, -1);
v4l_dbg(2, msp_debug, client, "msp3400 thread: wakeup\n");
- restart:
+restart:
v4l_dbg(2, msp_debug, client, "thread: restart scan\n");
state->restart = 0;
if (kthread_should_stop())
@@ -483,7 +496,8 @@ int msp3400c_thread(void *data)
if (state->radio || MSP_MODE_EXTERN == state->mode) {
/* no carrier scan, just unmute */
- v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
+ v4l_dbg(1, msp_debug, client,
+ "thread: no carrier scan\n");
state->scan_in_progress = 0;
msp_set_audio(client);
continue;
@@ -514,16 +528,17 @@ int msp3400c_thread(void *data)
v4l_dbg(1, msp_debug, client, "AM sound override\n");
}
- for (this = 0; this < count; this++) {
- msp3400c_set_carrier(client, cd[this].cdo, cd[this].cdo);
- if (msp_sleep(state,100))
+ for (i = 0; i < count; i++) {
+ msp3400c_set_carrier(client, cd[i].cdo, cd[i].cdo);
+ if (msp_sleep(state, 100))
goto restart;
val = msp_read_dsp(client, 0x1b);
if (val > 32767)
val -= 65536;
if (val1 < val)
- val1 = val, max1 = this;
- v4l_dbg(1, msp_debug, client, "carrier1 val: %5d / %s\n", val,cd[this].name);
+ val1 = val, max1 = i;
+ v4l_dbg(1, msp_debug, client,
+ "carrier1 val: %5d / %s\n", val, cd[i].name);
}
/* carrier detect pass #2 -- second (stereo) carrier */
@@ -550,16 +565,17 @@ int msp3400c_thread(void *data)
count = 0;
max2 = 0;
}
- for (this = 0; this < count; this++) {
- msp3400c_set_carrier(client, cd[this].cdo, cd[this].cdo);
- if (msp_sleep(state,100))
+ for (i = 0; i < count; i++) {
+ msp3400c_set_carrier(client, cd[i].cdo, cd[i].cdo);
+ if (msp_sleep(state, 100))
goto restart;
val = msp_read_dsp(client, 0x1b);
if (val > 32767)
val -= 65536;
if (val2 < val)
- val2 = val, max2 = this;
- v4l_dbg(1, msp_debug, client, "carrier2 val: %5d / %s\n", val,cd[this].name);
+ val2 = val, max2 = i;
+ v4l_dbg(1, msp_debug, client,
+ "carrier2 val: %5d / %s\n", val, cd[i].name);
}
/* program the msp3400 according to the results */
@@ -611,7 +627,7 @@ int msp3400c_thread(void *data)
break;
case 0: /* 4.5 */
default:
- no_second:
+no_second:
state->second = msp3400c_carrier_detect_main[max1].cdo;
msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
break;
@@ -632,7 +648,8 @@ int msp3400c_thread(void *data)
while (state->watch_stereo) {
if (msp_sleep(state, count ? 1000 : 5000))
goto restart;
- if (count) count--;
+ if (count)
+ count--;
watch_stereo(client);
}
}
@@ -651,10 +668,10 @@ int msp3410d_thread(void *data)
set_freezable();
for (;;) {
v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n");
- msp_sleep(state,-1);
+ msp_sleep(state, -1);
v4l_dbg(2, msp_debug, client, "msp3410 thread: wakeup\n");
- restart:
+restart:
v4l_dbg(2, msp_debug, client, "thread: restart scan\n");
state->restart = 0;
if (kthread_should_stop())
@@ -662,7 +679,8 @@ int msp3410d_thread(void *data)
if (state->mode == MSP_MODE_EXTERN) {
/* no carrier scan needed, just unmute */
- v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
+ v4l_dbg(1, msp_debug, client,
+ "thread: no carrier scan\n");
state->scan_in_progress = 0;
msp_set_audio(client);
continue;
@@ -673,7 +691,8 @@ int msp3410d_thread(void *data)
msp_set_audio(client);
/* start autodetect. Note: autodetect is not supported for
- NTSC-M and radio, hence we force the standard in those cases. */
+ NTSC-M and radio, hence we force the standard in those
+ cases. */
if (state->radio)
std = 0x40;
else
@@ -686,8 +705,9 @@ int msp3410d_thread(void *data)
goto restart;
if (msp_debug)
- v4l_dbg(2, msp_debug, client, "setting standard: %s (0x%04x)\n",
- msp_standard_std_name(std), std);
+ v4l_dbg(2, msp_debug, client,
+ "setting standard: %s (0x%04x)\n",
+ msp_standard_std_name(std), std);
if (std != 1) {
/* programmed some specific mode */
@@ -703,7 +723,8 @@ int msp3410d_thread(void *data)
val = msp_read_dem(client, 0x7e);
if (val < 0x07ff)
break;
- v4l_dbg(2, msp_debug, client, "detection still in progress\n");
+ v4l_dbg(2, msp_debug, client,
+ "detection still in progress\n");
}
}
for (i = 0; msp_stdlist[i].name != NULL; i++)
@@ -716,12 +737,13 @@ int msp3410d_thread(void *data)
state->std = val;
state->rxsubchans = V4L2_TUNER_SUB_MONO;
- if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) &&
- (val != 0x0009)) {
+ if (msp_amsound && !state->radio &&
+ (state->v4l2_std & V4L2_STD_SECAM) && (val != 0x0009)) {
/* autodetection has failed, let backup */
v4l_dbg(1, msp_debug, client, "autodetection failed,"
" switching to backup standard: %s (0x%04x)\n",
- msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val);
+ msp_stdlist[8].name ?
+ msp_stdlist[8].name : "unknown", val);
state->std = val = 0x0009;
msp_write_dem(client, 0x20, val);
}
@@ -786,7 +808,8 @@ int msp3410d_thread(void *data)
while (state->watch_stereo) {
if (msp_sleep(state, count ? 1000 : 5000))
goto restart;
- if (count) count--;
+ if (count)
+ count--;
watch_stereo(client);
}
}
@@ -872,8 +895,8 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
else
source = (in << 8) | matrix;
- v4l_dbg(1, msp_debug, client, "set source to %d (0x%x) for output %02x\n",
- in, source, reg);
+ v4l_dbg(1, msp_debug, client,
+ "set source to %d (0x%x) for output %02x\n", in, source, reg);
msp_write_dsp(client, reg, source);
}
@@ -948,7 +971,7 @@ int msp34xxg_thread(void *data)
msp_sleep(state, -1);
v4l_dbg(2, msp_debug, client, "msp34xxg thread: wakeup\n");
- restart:
+restart:
v4l_dbg(1, msp_debug, client, "thread: restart scan\n");
state->restart = 0;
if (kthread_should_stop())
@@ -956,7 +979,8 @@ int msp34xxg_thread(void *data)
if (state->mode == MSP_MODE_EXTERN) {
/* no carrier scan needed, just unmute */
- v4l_dbg(1, msp_debug, client, "thread: no carrier scan\n");
+ v4l_dbg(1, msp_debug, client,
+ "thread: no carrier scan\n");
state->scan_in_progress = 0;
msp_set_audio(client);
continue;
@@ -972,7 +996,8 @@ int msp34xxg_thread(void *data)
goto unmute;
/* watch autodetect */
- v4l_dbg(1, msp_debug, client, "started autodetect, waiting for result\n");
+ v4l_dbg(1, msp_debug, client,
+ "started autodetect, waiting for result\n");
for (i = 0; i < 10; i++) {
if (msp_sleep(state, 100))
goto restart;
@@ -983,15 +1008,18 @@ int msp34xxg_thread(void *data)
state->std = val;
break;
}
- v4l_dbg(2, msp_debug, client, "detection still in progress\n");
+ v4l_dbg(2, msp_debug, client,
+ "detection still in progress\n");
}
if (state->std == 1) {
- v4l_dbg(1, msp_debug, client, "detection still in progress after 10 tries. giving up.\n");
+ v4l_dbg(1, msp_debug, client,
+ "detection still in progress after 10 tries. giving up.\n");
continue;
}
- unmute:
- v4l_dbg(1, msp_debug, client, "detected standard: %s (0x%04x)\n",
+unmute:
+ v4l_dbg(1, msp_debug, client,
+ "detected standard: %s (0x%04x)\n",
msp_standard_std_name(state->std), state->std);
if (state->std == 9) {
@@ -1046,9 +1074,11 @@ static int msp34xxg_detect_stereo(struct i2c_client *client)
if (state->std == 0x20)
state->rxsubchans |= V4L2_TUNER_SUB_SAP;
else
- state->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
+ state->rxsubchans =
+ V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
}
- v4l_dbg(1, msp_debug, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
+ v4l_dbg(1, msp_debug, client,
+ "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
status, is_stereo, is_bilingual, state->rxsubchans);
return (oldrx != state->rxsubchans);
}