Commit d52c7385 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (6866): msp3400: CodingStyle cleanups

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 35df38c0
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * 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.
*/ */
...@@ -72,7 +73,8 @@ int msp_debug; /* msp_debug output */ ...@@ -72,7 +73,8 @@ int msp_debug; /* msp_debug output */
int msp_once; /* no continous stereo monitoring */ int msp_once; /* no continous stereo monitoring */
int msp_amsound; /* hard-wire AM sound at 6.5 Hz (france), int msp_amsound; /* hard-wire AM sound at 6.5 Hz (france),
the autoscan seems work well only with FM... */ the autoscan seems work well only with FM... */
int msp_standard = 1; /* Override auto detect of audio msp_standard, if needed. */ int msp_standard = 1; /* Override auto detect of audio msp_standard,
if needed. */
int msp_dolby; int msp_dolby;
int msp_stereo_thresh = 0x190; /* a2 threshold for stereo/bilingual int msp_stereo_thresh = 0x190; /* a2 threshold for stereo/bilingual
...@@ -82,12 +84,12 @@ int msp_stereo_thresh = 0x190; /* a2 threshold for stereo/bilingual ...@@ -82,12 +84,12 @@ int msp_stereo_thresh = 0x190; /* a2 threshold for stereo/bilingual
module_param(opmode, int, 0444); module_param(opmode, int, 0444);
/* read-write */ /* read-write */
module_param_named(once,msp_once, bool, 0644); module_param_named(once, msp_once, bool, 0644);
module_param_named(debug,msp_debug, int, 0644); module_param_named(debug, msp_debug, int, 0644);
module_param_named(stereo_threshold,msp_stereo_thresh, int, 0644); module_param_named(stereo_threshold, msp_stereo_thresh, int, 0644);
module_param_named(standard,msp_standard, int, 0644); module_param_named(standard, msp_standard, int, 0644);
module_param_named(amsound,msp_amsound, bool, 0644); module_param_named(amsound, msp_amsound, bool, 0644);
module_param_named(dolby,msp_dolby, bool, 0644); module_param_named(dolby, msp_dolby, bool, 0644);
MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Autodetect, 2=Autodetect and autoselect"); MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Autodetect, 2=Autodetect and autoselect");
MODULE_PARM_DESC(once, "No continuous stereo monitoring"); MODULE_PARM_DESC(once, "No continuous stereo monitoring");
...@@ -161,12 +163,13 @@ static int msp_read(struct i2c_client *client, int dev, int addr) ...@@ -161,12 +163,13 @@ static int msp_read(struct i2c_client *client, int dev, int addr)
schedule_timeout_interruptible(msecs_to_jiffies(10)); schedule_timeout_interruptible(msecs_to_jiffies(10));
} }
if (err == 3) { if (err == 3) {
v4l_warn(client, "giving up, resetting chip. Sound will go off, sorry folks :-|\n"); v4l_warn(client, "resetting chip, sound will go off.\n");
msp_reset(client); msp_reset(client);
return -1; return -1;
} }
retval = read[0] << 8 | read[1]; retval = read[0] << 8 | read[1];
v4l_dbg(3, msp_debug, client, "msp_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval); v4l_dbg(3, msp_debug, client, "msp_read(0x%x, 0x%x): 0x%x\n",
dev, addr, retval);
return retval; return retval;
} }
...@@ -191,7 +194,8 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val) ...@@ -191,7 +194,8 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val)
buffer[3] = val >> 8; buffer[3] = val >> 8;
buffer[4] = val & 0xff; buffer[4] = val & 0xff;
v4l_dbg(3, msp_debug, client, "msp_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val); v4l_dbg(3, msp_debug, client, "msp_write(0x%x, 0x%x, 0x%x)\n",
dev, addr, val);
for (err = 0; err < 3; err++) { for (err = 0; err < 3; err++) {
if (i2c_master_send(client, buffer, 5) == 5) if (i2c_master_send(client, buffer, 5) == 5)
break; break;
...@@ -200,7 +204,7 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val) ...@@ -200,7 +204,7 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val)
schedule_timeout_interruptible(msecs_to_jiffies(10)); schedule_timeout_interruptible(msecs_to_jiffies(10));
} }
if (err == 3) { if (err == 3) {
v4l_warn(client, "giving up, resetting chip. Sound will go off, sorry folks :-|\n"); v4l_warn(client, "resetting chip, sound will go off.\n");
msp_reset(client); msp_reset(client);
return -1; return -1;
} }
...@@ -274,7 +278,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out) ...@@ -274,7 +278,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
state->acb = 0xf60; /* Mute Input and SCART 1 Output */ state->acb = 0xf60; /* Mute Input and SCART 1 Output */
v4l_dbg(1, msp_debug, client, "scart switch: %s => %d (ACB=0x%04x)\n", v4l_dbg(1, msp_debug, client, "scart switch: %s => %d (ACB=0x%04x)\n",
scart_names[in], out, state->acb); scart_names[in], out, state->acb);
msp_write_dsp(client, 0x13, state->acb); msp_write_dsp(client, 0x13, state->acb);
/* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */ /* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */
...@@ -293,7 +297,8 @@ void msp_set_audio(struct i2c_client *client) ...@@ -293,7 +297,8 @@ void msp_set_audio(struct i2c_client *client)
val = (state->volume * 0x7f / 65535) << 8; val = (state->volume * 0x7f / 65535) << 8;
v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n", v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n",
state->muted ? "on" : "off", state->scan_in_progress ? "yes" : "no", state->muted ? "on" : "off",
state->scan_in_progress ? "yes" : "no",
state->volume); state->volume);
msp_write_dsp(client, 0x0000, val); msp_write_dsp(client, 0x0000, val);
...@@ -682,14 +687,14 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -682,14 +687,14 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", *a); v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", *a);
switch (*a) { switch (*a) {
case 1024000: case 1024000:
state->i2s_mode = 0; state->i2s_mode = 0;
break; break;
case 2048000: case 2048000:
state->i2s_mode = 1; state->i2s_mode = 1;
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
break; break;
} }
...@@ -699,22 +704,22 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -699,22 +704,22 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
struct v4l2_queryctrl *qc = arg; struct v4l2_queryctrl *qc = arg;
switch (qc->id) { switch (qc->id) {
case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME:
case V4L2_CID_AUDIO_MUTE: case V4L2_CID_AUDIO_MUTE:
return v4l2_ctrl_query_fill_std(qc); return v4l2_ctrl_query_fill_std(qc);
default: default:
break; break;
} }
if (!state->has_sound_processing) if (!state->has_sound_processing)
return -EINVAL; return -EINVAL;
switch (qc->id) { switch (qc->id) {
case V4L2_CID_AUDIO_LOUDNESS: case V4L2_CID_AUDIO_LOUDNESS:
case V4L2_CID_AUDIO_BALANCE: case V4L2_CID_AUDIO_BALANCE:
case V4L2_CID_AUDIO_BASS: case V4L2_CID_AUDIO_BASS:
case V4L2_CID_AUDIO_TREBLE: case V4L2_CID_AUDIO_TREBLE:
return v4l2_ctrl_query_fill_std(qc); return v4l2_ctrl_query_fill_std(qc);
default: default:
return -EINVAL; return -EINVAL;
} }
} }
...@@ -736,13 +741,14 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -736,13 +741,14 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
state->volume, state->muted ? " (muted)" : ""); state->volume, state->muted ? " (muted)" : "");
if (state->has_sound_processing) { if (state->has_sound_processing) {
v4l_info(client, "Audio: balance %d bass %d treble %d loudness %s\n", v4l_info(client, "Audio: balance %d bass %d treble %d loudness %s\n",
state->balance, state->bass, state->treble, state->balance, state->bass,
state->treble,
state->loudness ? "on" : "off"); state->loudness ? "on" : "off");
} }
switch (state->mode) { switch (state->mode) {
case MSP_MODE_AM_DETECT: p = "AM (for carrier detect)"; break; case MSP_MODE_AM_DETECT: p = "AM (for carrier detect)"; break;
case MSP_MODE_FM_RADIO: p = "FM Radio"; break; case MSP_MODE_FM_RADIO: p = "FM Radio"; break;
case MSP_MODE_FM_TERRA: p = "Terrestial FM-mono + FM-stereo"; break; case MSP_MODE_FM_TERRA: p = "Terrestial FM-mono/stereo"; break;
case MSP_MODE_FM_SAT: p = "Satellite FM-mono"; break; case MSP_MODE_FM_SAT: p = "Satellite FM-mono"; break;
case MSP_MODE_FM_NICAM1: p = "NICAM/FM (B/G, D/K)"; break; case MSP_MODE_FM_NICAM1: p = "NICAM/FM (B/G, D/K)"; break;
case MSP_MODE_FM_NICAM2: p = "NICAM/FM (I)"; break; case MSP_MODE_FM_NICAM2: p = "NICAM/FM (I)"; break;
...@@ -773,7 +779,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -773,7 +779,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
} }
case VIDIOC_G_CHIP_IDENT: case VIDIOC_G_CHIP_IDENT:
return v4l2_chip_ident_i2c_client(client, arg, state->ident, (state->rev1 << 16) | state->rev2); return v4l2_chip_ident_i2c_client(client, arg, state->ident,
(state->rev1 << 16) | state->rev2);
default: default:
/* unknown */ /* unknown */
...@@ -816,9 +823,8 @@ static int msp_probe(struct i2c_client *client) ...@@ -816,9 +823,8 @@ static int msp_probe(struct i2c_client *client)
} }
state = kzalloc(sizeof(*state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (!state) { if (!state)
return -ENOMEM; return -ENOMEM;
}
i2c_set_clientdata(client, state); i2c_set_clientdata(client, state);
...@@ -840,9 +846,11 @@ static int msp_probe(struct i2c_client *client) ...@@ -840,9 +846,11 @@ static int msp_probe(struct i2c_client *client)
state->rev1 = msp_read_dsp(client, 0x1e); state->rev1 = msp_read_dsp(client, 0x1e);
if (state->rev1 != -1) if (state->rev1 != -1)
state->rev2 = msp_read_dsp(client, 0x1f); state->rev2 = msp_read_dsp(client, 0x1f);
v4l_dbg(1, msp_debug, client, "rev1=0x%04x, rev2=0x%04x\n", state->rev1, state->rev2); v4l_dbg(1, msp_debug, client, "rev1=0x%04x, rev2=0x%04x\n",
state->rev1, state->rev2);
if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) {
v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n"); v4l_dbg(1, msp_debug, client,
"not an msp3400 (cannot read chip version)\n");
kfree(state); kfree(state);
return -ENODEV; return -ENODEV;
} }
...@@ -860,37 +868,55 @@ static int msp_probe(struct i2c_client *client) ...@@ -860,37 +868,55 @@ static int msp_probe(struct i2c_client *client)
msp_family, msp_product, msp_family, msp_product,
msp_revision, msp_hard, msp_rom); msp_revision, msp_hard, msp_rom);
/* Rev B=2, C=3, D=4, G=7 */ /* Rev B=2, C=3, D=4, G=7 */
state->ident = msp_family * 10000 + 4000 + msp_product * 10 + msp_revision - '@'; state->ident = msp_family * 10000 + 4000 + msp_product * 10 +
msp_revision - '@';
/* Has NICAM support: all mspx41x and mspx45x products have NICAM */ /* Has NICAM support: all mspx41x and mspx45x products have NICAM */
state->has_nicam = msp_prod_hi == 1 || msp_prod_hi == 5; state->has_nicam =
msp_prod_hi == 1 || msp_prod_hi == 5;
/* Has radio support: was added with revision G */ /* Has radio support: was added with revision G */
state->has_radio = msp_revision >= 'G'; state->has_radio =
msp_revision >= 'G';
/* Has headphones output: not for stripped down products */ /* Has headphones output: not for stripped down products */
state->has_headphones = msp_prod_lo < 5; state->has_headphones =
msp_prod_lo < 5;
/* Has scart2 input: not in stripped down products of the '3' family */ /* Has scart2 input: not in stripped down products of the '3' family */
state->has_scart2 = msp_family >= 4 || msp_prod_lo < 7; state->has_scart2 =
msp_family >= 4 || msp_prod_lo < 7;
/* Has scart3 input: not in stripped down products of the '3' family */ /* Has scart3 input: not in stripped down products of the '3' family */
state->has_scart3 = msp_family >= 4 || msp_prod_lo < 5; state->has_scart3 =
msp_family >= 4 || msp_prod_lo < 5;
/* Has scart4 input: not in pre D revisions, not in stripped D revs */ /* Has scart4 input: not in pre D revisions, not in stripped D revs */
state->has_scart4 = msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5); state->has_scart4 =
/* Has scart2 output: not in stripped down products of the '3' family */ msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5);
state->has_scart2_out = msp_family >= 4 || msp_prod_lo < 5; /* Has scart2 output: not in stripped down products of
* the '3' family */
state->has_scart2_out =
msp_family >= 4 || msp_prod_lo < 5;
/* Has scart2 a volume control? Not in pre-D revisions. */ /* Has scart2 a volume control? Not in pre-D revisions. */
state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart2_out; state->has_scart2_out_volume =
msp_revision > 'C' && state->has_scart2_out;
/* Has a configurable i2s out? */ /* Has a configurable i2s out? */
state->has_i2s_conf = msp_revision >= 'G' && msp_prod_lo < 7; state->has_i2s_conf =
/* Has subwoofer output: not in pre-D revs and not in stripped down products */ msp_revision >= 'G' && msp_prod_lo < 7;
state->has_subwoofer = msp_revision >= 'D' && msp_prod_lo < 5; /* Has subwoofer output: not in pre-D revs and not in stripped down
/* Has soundprocessing (bass/treble/balance/loudness/equalizer): not in * products */
stripped down products */ state->has_subwoofer =
state->has_sound_processing = msp_prod_lo < 7; msp_revision >= 'D' && msp_prod_lo < 5;
/* Has soundprocessing (bass/treble/balance/loudness/equalizer):
* not in stripped down products */
state->has_sound_processing =
msp_prod_lo < 7;
/* Has Virtual Dolby Surround: only in msp34x1 */ /* Has Virtual Dolby Surround: only in msp34x1 */
state->has_virtual_dolby_surround = msp_revision == 'G' && msp_prod_lo == 1; state->has_virtual_dolby_surround =
msp_revision == 'G' && msp_prod_lo == 1;
/* Has Virtual Dolby Surround & Dolby Pro Logic: only in msp34x2 */ /* Has Virtual Dolby Surround & Dolby Pro Logic: only in msp34x2 */
state->has_dolby_pro_logic = msp_revision == 'G' && msp_prod_lo == 2; state->has_dolby_pro_logic =
/* The msp343xG supports BTSC only and cannot do Automatic Standard Detection. */ msp_revision == 'G' && msp_prod_lo == 2;
state->force_btsc = msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3; /* The msp343xG supports BTSC only and cannot do Automatic Standard
* Detection. */
state->force_btsc =
msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3;
state->opmode = opmode; state->opmode = opmode;
if (state->opmode == OPMODE_AUTO) { if (state->opmode == OPMODE_AUTO) {
...@@ -905,32 +931,33 @@ static int msp_probe(struct i2c_client *client) ...@@ -905,32 +931,33 @@ static int msp_probe(struct i2c_client *client)
} }
/* hello world :-) */ /* hello world :-) */
v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, client->addr << 1, client->adapter->name); v4l_info(client, "%s found @ 0x%x (%s)\n", client->name,
client->addr << 1, client->adapter->name);
v4l_info(client, "%s ", client->name); v4l_info(client, "%s ", client->name);
if (state->has_nicam && state->has_radio) if (state->has_nicam && state->has_radio)
printk("supports nicam and radio, "); printk(KERN_CONT "supports nicam and radio, ");
else if (state->has_nicam) else if (state->has_nicam)
printk("supports nicam, "); printk(KERN_CONT "supports nicam, ");
else if (state->has_radio) else if (state->has_radio)
printk("supports radio, "); printk(KERN_CONT "supports radio, ");
printk("mode is "); printk(KERN_CONT "mode is ");
/* version-specific initialization */ /* version-specific initialization */
switch (state->opmode) { switch (state->opmode) {
case OPMODE_MANUAL: case OPMODE_MANUAL:
printk("manual"); printk(KERN_CONT "manual");
thread_func = msp3400c_thread; thread_func = msp3400c_thread;
break; break;
case OPMODE_AUTODETECT: case OPMODE_AUTODETECT:
printk("autodetect"); printk(KERN_CONT "autodetect");
thread_func = msp3410d_thread; thread_func = msp3410d_thread;
break; break;
case OPMODE_AUTOSELECT: case OPMODE_AUTOSELECT:
printk("autodetect and autoselect"); printk(KERN_CONT "autodetect and autoselect");
thread_func = msp34xxg_thread; thread_func = msp34xxg_thread;
break; break;
} }
printk("\n"); printk(KERN_CONT "\n");
/* startup control thread if needed */ /* startup control thread if needed */
if (thread_func) { if (thread_func) {
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * 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 { ...@@ -78,37 +79,37 @@ static struct msp3400c_init_data_dem {
{75, 19, 36, 35, 39, 40}, {75, 19, 36, 35, 39, 40},
MSP_CARRIER(5.5), MSP_CARRIER(5.5), MSP_CARRIER(5.5), MSP_CARRIER(5.5),
0x00d0, 0x0500, 0x0020, 0x3000 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},
{-1, -1, -8, 2, 59, 126}, {-1, -1, -8, 2, 59, 126},
MSP_CARRIER(5.5), MSP_CARRIER(5.5), MSP_CARRIER(5.5), MSP_CARRIER(5.5),
0x00d0, 0x0100, 0x0020, 0x3000 0x00d0, 0x0100, 0x0020, 0x3000
},{ /* FM Radio */ }, { /* FM Radio */
{-8, -8, 4, 6, 78, 107}, {-8, -8, 4, 6, 78, 107},
{-8, -8, 4, 6, 78, 107}, {-8, -8, 4, 6, 78, 107},
MSP_CARRIER(10.7), MSP_CARRIER(10.7), MSP_CARRIER(10.7), MSP_CARRIER(10.7),
0x00d0, 0x0480, 0x0020, 0x3000 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},
{3, 18, 27, 48, 66, 72}, {3, 18, 27, 48, 66, 72},
MSP_CARRIER(5.5), MSP_CARRIER(5.5), MSP_CARRIER(5.5), MSP_CARRIER(5.5),
0x00d0, 0x0480, 0x0030, 0x3000 0x00d0, 0x0480, 0x0030, 0x3000
},{ /* Sat FM-mono */ }, { /* Sat FM-mono */
{ 1, 9, 14, 24, 33, 37}, { 1, 9, 14, 24, 33, 37},
{ 3, 18, 27, 48, 66, 72}, { 3, 18, 27, 48, 66, 72},
MSP_CARRIER(6.5), MSP_CARRIER(6.5), MSP_CARRIER(6.5), MSP_CARRIER(6.5),
0x00c6, 0x0480, 0x0000, 0x3000 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}, {-2, -8, -10, 10, 50, 86},
{3, 18, 27, 48, 66, 72}, {3, 18, 27, 48, 66, 72},
MSP_CARRIER(5.5), MSP_CARRIER(5.5), MSP_CARRIER(5.5), MSP_CARRIER(5.5),
0x00d0, 0x0040, 0x0120, 0x3000 0x00d0, 0x0040, 0x0120, 0x3000
},{ /* NICAM/FM -- I (6.0/6.552) */ }, { /* NICAM/FM -- I (6.0/6.552) */
{2, 4, -6, -4, 40, 94}, {2, 4, -6, -4, 40, 94},
{3, 18, 27, 48, 66, 72}, {3, 18, 27, 48, 66, 72},
MSP_CARRIER(6.0), MSP_CARRIER(6.0), MSP_CARRIER(6.0), MSP_CARRIER(6.0),
0x00d0, 0x0040, 0x0120, 0x3000 0x00d0, 0x0040, 0x0120, 0x3000
},{ /* NICAM/AM -- L (6.5/5.85) */ }, { /* NICAM/AM -- L (6.5/5.85) */
{-2, -8, -10, 10, 50, 86}, {-2, -8, -10, 10, 50, 86},
{-4, -12, -9, 23, 79, 126}, {-4, -12, -9, 23, 79, 126},
MSP_CARRIER(6.5), MSP_CARRIER(6.5), MSP_CARRIER(6.5), MSP_CARRIER(6.5),
...@@ -224,7 +225,9 @@ void msp3400c_set_mode(struct i2c_client *client, int mode) ...@@ -224,7 +225,9 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
nor do they support stereo BTSC. */ nor do they support stereo BTSC. */
static void msp3400c_set_audmode(struct i2c_client *client) 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); struct msp_state *state = i2c_get_clientdata(client);
char *modestr = (state->audmode >= 0 && state->audmode < 5) ? char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
strmode[state->audmode] : "unknown"; strmode[state->audmode] : "unknown";
...@@ -298,19 +301,23 @@ static void msp3400c_set_audmode(struct i2c_client *client) ...@@ -298,19 +301,23 @@ static void msp3400c_set_audmode(struct i2c_client *client)
case MSP_MODE_FM_NICAM1: case MSP_MODE_FM_NICAM1:
case MSP_MODE_FM_NICAM2: case MSP_MODE_FM_NICAM2:
case MSP_MODE_AM_NICAM: 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) if (state->nicam_on)
src = 0x0100; /* NICAM */ src = 0x0100; /* NICAM */
break; break;
case MSP_MODE_BTSC: 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; break;
case MSP_MODE_EXTERN: 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 */ src = 0x0200; /* SCART */
break; break;
case MSP_MODE_FM_RADIO: 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; break;
default: default:
v4l_dbg(1, msp_debug, client, "mono set_audmode\n"); v4l_dbg(1, msp_debug, client, "mono set_audmode\n");
...@@ -342,7 +349,8 @@ static void msp3400c_set_audmode(struct i2c_client *client) ...@@ -342,7 +349,8 @@ static void msp3400c_set_audmode(struct i2c_client *client)
src |= 0x0010; src |= 0x0010;
break; 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); msp_set_source(client, src);
} }
...@@ -351,22 +359,26 @@ static void msp3400c_print_mode(struct i2c_client *client) ...@@ -351,22 +359,26 @@ static void msp3400c_print_mode(struct i2c_client *client)
{ {
struct msp_state *state = i2c_get_clientdata(client); struct msp_state *state = i2c_get_clientdata(client);
if (state->main == state->second) { if (state->main == state->second)
v4l_dbg(1, msp_debug, client, "mono sound carrier: %d.%03d MHz\n", v4l_dbg(1, msp_debug, client,
state->main / 910000, (state->main / 910) % 1000); "mono sound carrier: %d.%03d MHz\n",
} else { state->main / 910000, (state->main / 910) % 1000);
v4l_dbg(1, msp_debug, client, "main sound carrier: %d.%03d MHz\n", else
state->main / 910000, (state->main / 910) % 1000); 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) 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", v4l_dbg(1, msp_debug, client,
state->second / 910000, (state->second/910) % 1000); "NICAM/FM carrier : %d.%03d MHz\n",
state->second / 910000, (state->second/910) % 1000);
if (state->mode == MSP_MODE_AM_NICAM) if (state->mode == MSP_MODE_AM_NICAM)
v4l_dbg(1, msp_debug, client, "NICAM/AM carrier : %d.%03d MHz\n", v4l_dbg(1, msp_debug, client,
state->second / 910000, (state->second / 910) % 1000); "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) { if (state->mode == MSP_MODE_FM_TERRA && state->main != state->second) {
v4l_dbg(1, msp_debug, client, "FM-stereo carrier : %d.%03d MHz\n", v4l_dbg(1, msp_debug, client,
state->second / 910000, (state->second / 910) % 1000); "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) ...@@ -385,7 +397,8 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
val = msp_read_dsp(client, 0x18); val = msp_read_dsp(client, 0x18);
if (val > 32767) if (val > 32767)
val -= 65536; 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) { if (val > 8192) {
rxsubchans = V4L2_TUNER_SUB_STEREO; rxsubchans = V4L2_TUNER_SUB_STEREO;
} else if (val < -4096) { } else if (val < -4096) {
...@@ -430,7 +443,8 @@ static int msp3400c_detect_stereo(struct i2c_client *client) ...@@ -430,7 +443,8 @@ static int msp3400c_detect_stereo(struct i2c_client *client)
} }
if (rxsubchans != state->rxsubchans) { if (rxsubchans != state->rxsubchans) {
update = 1; 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);
state->rxsubchans = rxsubchans; state->rxsubchans = rxsubchans;
} }
...@@ -452,9 +466,8 @@ static void watch_stereo(struct i2c_client *client) ...@@ -452,9 +466,8 @@ static void watch_stereo(struct i2c_client *client)
{ {
struct msp_state *state = i2c_get_clientdata(client); struct msp_state *state = i2c_get_clientdata(client);
if (msp_detect_stereo(client)) { if (msp_detect_stereo(client))
msp_set_audmode(client); msp_set_audmode(client);
}
if (msp_once) if (msp_once)
state->watch_stereo = 0; state->watch_stereo = 0;
...@@ -465,7 +478,7 @@ int msp3400c_thread(void *data) ...@@ -465,7 +478,7 @@ int msp3400c_thread(void *data)
struct i2c_client *client = data; struct i2c_client *client = data;
struct msp_state *state = i2c_get_clientdata(client); struct msp_state *state = i2c_get_clientdata(client);
struct msp3400c_carrier_detect *cd; 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"); v4l_dbg(1, msp_debug, client, "msp3400 daemon started\n");
...@@ -475,7 +488,7 @@ int msp3400c_thread(void *data) ...@@ -475,7 +488,7 @@ int msp3400c_thread(void *data)
msp_sleep(state, -1); msp_sleep(state, -1);
v4l_dbg(2, msp_debug, client, "msp3400 thread: wakeup\n"); v4l_dbg(2, msp_debug, client, "msp3400 thread: wakeup\n");
restart: restart:
v4l_dbg(2, msp_debug, client, "thread: restart scan\n"); v4l_dbg(2, msp_debug, client, "thread: restart scan\n");
state->restart = 0; state->restart = 0;
if (kthread_should_stop()) if (kthread_should_stop())
...@@ -483,7 +496,8 @@ int msp3400c_thread(void *data) ...@@ -483,7 +496,8 @@ int msp3400c_thread(void *data)
if (state->radio || MSP_MODE_EXTERN == state->mode) { if (state->radio || MSP_MODE_EXTERN == state->mode) {
/* no carrier scan, just unmute */ /* 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; state->scan_in_progress = 0;
msp_set_audio(client); msp_set_audio(client);
continue; continue;
...@@ -514,16 +528,17 @@ int msp3400c_thread(void *data) ...@@ -514,16 +528,17 @@ int msp3400c_thread(void *data)
v4l_dbg(1, msp_debug, client, "AM sound override\n"); v4l_dbg(1, msp_debug, client, "AM sound override\n");
} }
for (this = 0; this < count; this++) { for (i = 0; i < count; i++) {
msp3400c_set_carrier(client, cd[this].cdo, cd[this].cdo); msp3400c_set_carrier(client, cd[i].cdo, cd[i].cdo);
if (msp_sleep(state,100)) if (msp_sleep(state, 100))
goto restart; goto restart;
val = msp_read_dsp(client, 0x1b); val = msp_read_dsp(client, 0x1b);
if (val > 32767) if (val > 32767)
val -= 65536; val -= 65536;
if (val1 < val) if (val1 < val)
val1 = val, max1 = this; val1 = val, max1 = i;
v4l_dbg(1, msp_debug, client, "carrier1 val: %5d / %s\n", val,cd[this].name); v4l_dbg(1, msp_debug, client,
"carrier1 val: %5d / %s\n", val, cd[i].name);
} }
/* carrier detect pass #2 -- second (stereo) carrier */ /* carrier detect pass #2 -- second (stereo) carrier */
...@@ -550,16 +565,17 @@ int msp3400c_thread(void *data) ...@@ -550,16 +565,17 @@ int msp3400c_thread(void *data)
count = 0; count = 0;
max2 = 0; max2 = 0;
} }
for (this = 0; this < count; this++) { for (i = 0; i < count; i++) {
msp3400c_set_carrier(client, cd[this].cdo, cd[this].cdo); msp3400c_set_carrier(client, cd[i].cdo, cd[i].cdo);
if (msp_sleep(state,100)) if (msp_sleep(state, 100))
goto restart; goto restart;
val = msp_read_dsp(client, 0x1b); val = msp_read_dsp(client, 0x1b);
if (val > 32767) if (val > 32767)
val -= 65536; val -= 65536;
if (val2 < val) if (val2 < val)
val2 = val, max2 = this; val2 = val, max2 = i;
v4l_dbg(1, msp_debug, client, "carrier2 val: %5d / %s\n", val,cd[this].name); v4l_dbg(1, msp_debug, client,
"carrier2 val: %5d / %s\n", val, cd[i].name);
} }
/* program the msp3400 according to the results */ /* program the msp3400 according to the results */
...@@ -611,7 +627,7 @@ int msp3400c_thread(void *data) ...@@ -611,7 +627,7 @@ int msp3400c_thread(void *data)
break; break;
case 0: /* 4.5 */ case 0: /* 4.5 */
default: default:
no_second: no_second:
state->second = msp3400c_carrier_detect_main[max1].cdo; state->second = msp3400c_carrier_detect_main[max1].cdo;
msp3400c_set_mode(client, MSP_MODE_FM_TERRA); msp3400c_set_mode(client, MSP_MODE_FM_TERRA);
break; break;
...@@ -632,7 +648,8 @@ int msp3400c_thread(void *data) ...@@ -632,7 +648,8 @@ int msp3400c_thread(void *data)
while (state->watch_stereo) { while (state->watch_stereo) {
if (msp_sleep(state, count ? 1000 : 5000)) if (msp_sleep(state, count ? 1000 : 5000))
goto restart; goto restart;
if (count) count--; if (count)
count--;
watch_stereo(client); watch_stereo(client);
} }
} }
...@@ -651,10 +668,10 @@ int msp3410d_thread(void *data) ...@@ -651,10 +668,10 @@ int msp3410d_thread(void *data)
set_freezable(); set_freezable();
for (;;) { for (;;) {
v4l_dbg(2, msp_debug, client, "msp3410 thread: sleep\n"); 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"); v4l_dbg(2, msp_debug, client, "msp3410 thread: wakeup\n");
restart: restart:
v4l_dbg(2, msp_debug, client, "thread: restart scan\n"); v4l_dbg(2, msp_debug, client, "thread: restart scan\n");
state->restart = 0; state->restart = 0;
if (kthread_should_stop()) if (kthread_should_stop())
...@@ -662,7 +679,8 @@ int msp3410d_thread(void *data) ...@@ -662,7 +679,8 @@ int msp3410d_thread(void *data)
if (state->mode == MSP_MODE_EXTERN) { if (state->mode == MSP_MODE_EXTERN) {
/* no carrier scan needed, just unmute */ /* 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; state->scan_in_progress = 0;
msp_set_audio(client); msp_set_audio(client);
continue; continue;
...@@ -673,7 +691,8 @@ int msp3410d_thread(void *data) ...@@ -673,7 +691,8 @@ int msp3410d_thread(void *data)
msp_set_audio(client); msp_set_audio(client);
/* start autodetect. Note: autodetect is not supported for /* 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) if (state->radio)
std = 0x40; std = 0x40;
else else
...@@ -686,8 +705,9 @@ int msp3410d_thread(void *data) ...@@ -686,8 +705,9 @@ int msp3410d_thread(void *data)
goto restart; goto restart;
if (msp_debug) if (msp_debug)
v4l_dbg(2, msp_debug, client, "setting standard: %s (0x%04x)\n", v4l_dbg(2, msp_debug, client,
msp_standard_std_name(std), std); "setting standard: %s (0x%04x)\n",
msp_standard_std_name(std), std);
if (std != 1) { if (std != 1) {
/* programmed some specific mode */ /* programmed some specific mode */
...@@ -703,7 +723,8 @@ int msp3410d_thread(void *data) ...@@ -703,7 +723,8 @@ int msp3410d_thread(void *data)
val = msp_read_dem(client, 0x7e); val = msp_read_dem(client, 0x7e);
if (val < 0x07ff) if (val < 0x07ff)
break; 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++) for (i = 0; msp_stdlist[i].name != NULL; i++)
...@@ -716,12 +737,13 @@ int msp3410d_thread(void *data) ...@@ -716,12 +737,13 @@ int msp3410d_thread(void *data)
state->std = val; state->std = val;
state->rxsubchans = V4L2_TUNER_SUB_MONO; state->rxsubchans = V4L2_TUNER_SUB_MONO;
if (msp_amsound && !state->radio && (state->v4l2_std & V4L2_STD_SECAM) && if (msp_amsound && !state->radio &&
(val != 0x0009)) { (state->v4l2_std & V4L2_STD_SECAM) && (val != 0x0009)) {
/* autodetection has failed, let backup */ /* autodetection has failed, let backup */
v4l_dbg(1, msp_debug, client, "autodetection failed," v4l_dbg(1, msp_debug, client, "autodetection failed,"
" switching to backup standard: %s (0x%04x)\n", " 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; state->std = val = 0x0009;
msp_write_dem(client, 0x20, val); msp_write_dem(client, 0x20, val);
} }
...@@ -786,7 +808,8 @@ int msp3410d_thread(void *data) ...@@ -786,7 +808,8 @@ int msp3410d_thread(void *data)
while (state->watch_stereo) { while (state->watch_stereo) {
if (msp_sleep(state, count ? 1000 : 5000)) if (msp_sleep(state, count ? 1000 : 5000))
goto restart; goto restart;
if (count) count--; if (count)
count--;
watch_stereo(client); watch_stereo(client);
} }
} }
...@@ -872,8 +895,8 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in) ...@@ -872,8 +895,8 @@ static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
else else
source = (in << 8) | matrix; source = (in << 8) | matrix;
v4l_dbg(1, msp_debug, client, "set source to %d (0x%x) for output %02x\n", v4l_dbg(1, msp_debug, client,
in, source, reg); "set source to %d (0x%x) for output %02x\n", in, source, reg);
msp_write_dsp(client, reg, source); msp_write_dsp(client, reg, source);
} }
...@@ -948,7 +971,7 @@ int msp34xxg_thread(void *data) ...@@ -948,7 +971,7 @@ int msp34xxg_thread(void *data)
msp_sleep(state, -1); msp_sleep(state, -1);
v4l_dbg(2, msp_debug, client, "msp34xxg thread: wakeup\n"); v4l_dbg(2, msp_debug, client, "msp34xxg thread: wakeup\n");
restart: restart:
v4l_dbg(1, msp_debug, client, "thread: restart scan\n"); v4l_dbg(1, msp_debug, client, "thread: restart scan\n");
state->restart = 0; state->restart = 0;
if (kthread_should_stop()) if (kthread_should_stop())
...@@ -956,7 +979,8 @@ int msp34xxg_thread(void *data) ...@@ -956,7 +979,8 @@ int msp34xxg_thread(void *data)
if (state->mode == MSP_MODE_EXTERN) { if (state->mode == MSP_MODE_EXTERN) {
/* no carrier scan needed, just unmute */ /* 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; state->scan_in_progress = 0;
msp_set_audio(client); msp_set_audio(client);
continue; continue;
...@@ -972,7 +996,8 @@ int msp34xxg_thread(void *data) ...@@ -972,7 +996,8 @@ int msp34xxg_thread(void *data)
goto unmute; goto unmute;
/* watch autodetect */ /* 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++) { for (i = 0; i < 10; i++) {
if (msp_sleep(state, 100)) if (msp_sleep(state, 100))
goto restart; goto restart;
...@@ -983,15 +1008,18 @@ int msp34xxg_thread(void *data) ...@@ -983,15 +1008,18 @@ int msp34xxg_thread(void *data)
state->std = val; state->std = val;
break; 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) { 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; continue;
} }
unmute: unmute:
v4l_dbg(1, msp_debug, client, "detected standard: %s (0x%04x)\n", v4l_dbg(1, msp_debug, client,
"detected standard: %s (0x%04x)\n",
msp_standard_std_name(state->std), state->std); msp_standard_std_name(state->std), state->std);
if (state->std == 9) { if (state->std == 9) {
...@@ -1046,9 +1074,11 @@ static int msp34xxg_detect_stereo(struct i2c_client *client) ...@@ -1046,9 +1074,11 @@ static int msp34xxg_detect_stereo(struct i2c_client *client)
if (state->std == 0x20) if (state->std == 0x20)
state->rxsubchans |= V4L2_TUNER_SUB_SAP; state->rxsubchans |= V4L2_TUNER_SUB_SAP;
else 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); status, is_stereo, is_bilingual, state->rxsubchans);
return (oldrx != state->rxsubchans); return (oldrx != state->rxsubchans);
} }
......
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