#include <asm/pgtable.h>
#include <media/audiochip.h>
-#include <media/id.h>
#include "msp3400.h"
/* insmod parameters */
int input;
int muted;
- int volume, balance;
+ int left, right; /* volume */
int bass, treble;
/* shadow register set */
}
static void msp3400c_setvolume(struct i2c_client *client,
- int muted, int volume, int balance)
+ int muted, int left, int right)
{
- int val = 0, bal = 0;
+ int vol = 0,val = 0,balance = 0;
if (!muted) {
- val = (volume * 0x73 / 65535) << 8;
+ vol = (left > right) ? left : right;
+ val = (vol * 0x73 / 65535) << 8;
}
- if (val) {
- bal = (balance / 256) - 128;
+ if (vol > 0) {
+ balance = ((right-left) * 127) / vol;
}
+
dprintk(KERN_DEBUG
"msp34xx: setvolume: mute=%s %d:%d v=0x%02x b=0x%02x\n",
- muted ? "on" : "off", volume, balance, val>>8, bal);
+ muted ? "on" : "off", left, right, val>>8, balance);
msp3400c_write(client,I2C_MSP3400C_DFP, 0x0000, val); /* loudspeaker */
msp3400c_write(client,I2C_MSP3400C_DFP, 0x0006, val); /* headphones */
/* scart - on/off only */
msp3400c_write(client,I2C_MSP3400C_DFP, 0x0007, val ? 0x4000 : 0);
- msp3400c_write(client,I2C_MSP3400C_DFP, 0x0001, bal << 8);
+ msp3400c_write(client,I2C_MSP3400C_DFP, 0x0001, balance << 8);
}
static void msp3400c_setbass(struct i2c_client *client, int bass)
/* no carrier scan, just unmute */
printk("msp3400: thread: no carrier scan\n");
msp3400c_setvolume(client, msp->muted,
- msp->volume, msp->balance);
+ msp->left, msp->right);
continue;
}
msp->restart = 0;
}
/* unmute + restore dfp registers */
- msp3400c_setvolume(client, msp->muted,
- msp->volume, msp->balance);
+ msp3400c_setvolume(client, msp->muted, msp->left, msp->right);
msp3400c_restore_dfp(client);
if (msp->watch_stereo)
/* no carrier scan needed, just unmute */
dprintk(KERN_DEBUG "msp3410: thread: no carrier scan\n");
msp3400c_setvolume(client, msp->muted,
- msp->volume, msp->balance);
+ msp->left, msp->right);
continue;
}
msp->restart = 0;
/* unmute + restore dfp registers */
msp3400c_setbass(client, msp->bass);
msp3400c_settreble(client, msp->treble);
- msp3400c_setvolume(client, msp->muted,
- msp->volume, msp->balance);
+ msp3400c_setvolume(client, msp->muted, msp->left, msp->right);
msp3400c_restore_dfp(client);
if (msp->watch_stereo)
}
memset(msp,0,sizeof(struct msp3400c));
- msp->volume = 65535;
- msp->balance = 32768;
+ msp->left = 65535;
+ msp->right = 65535;
msp->bass = 32768;
msp->treble = 32768;
msp->input = -1;
/* this will turn on a 1kHz beep - might be useful for debugging... */
msp3400c_write(c,I2C_MSP3400C_DFP, 0x0014, 0x1040);
#endif
- msp3400c_setvolume(c, msp->muted, msp->volume, msp->balance);
+ msp3400c_setvolume(c,msp->muted,msp->left,msp->right);
snprintf(c->name, sizeof(c->name), "MSP34%02d%c-%c%d",
(msp->rev2>>8)&0xff, (msp->rev1&0xff)+'@',
} else {
/* set msp3400 to FM radio mode */
msp3400c_setmode(client,MSP_MODE_FM_RADIO);
- msp3400c_setcarrier(client, MSP_CARRIER(10.7),
- MSP_CARRIER(10.7));
- msp3400c_setvolume(client, msp->muted,
- msp->volume, msp->balance);
+ msp3400c_setcarrier(client, MSP_CARRIER(10.7),MSP_CARRIER(10.7));
+ msp3400c_setvolume(client,msp->muted,msp->left,msp->right);
}
if (msp->active)
msp->restart = 1;
VIDEO_AUDIO_MUTABLE;
if (msp->muted)
va->flags |= VIDEO_AUDIO_MUTE;
+ va->volume=max(msp->left,msp->right);
- va->volume = msp->volume;
- va->balance = (va->volume) ? msp->balance : 32768;
+ if (0 == va->volume) {
+ va->balance = 32768;
+ } else {
+ va->balance = (32768 * min(msp->left,msp->right))
+ / va->volume;
+ va->balance = (msp->left<msp->right) ?
+ (65535 - va->balance) : va->balance;
+ }
va->bass = msp->bass;
va->treble = msp->treble;
dprintk(KERN_DEBUG "msp34xx: VIDIOCSAUDIO\n");
msp->muted = (va->flags & VIDEO_AUDIO_MUTE);
- msp->volume = va->volume;
- msp->balance = va->balance;
+ msp->left = (min(65536 - va->balance,32768) *
+ va->volume) / 32768;
+ msp->right = (min(va->balance,(__u16)32768) *
+ va->volume) / 32768;
msp->bass = va->bass;
msp->treble = va->treble;
-
- msp3400c_setvolume(client, msp->muted,
- msp->volume, msp->balance);
+ msp3400c_setvolume(client,msp->muted,msp->left,msp->right);
msp3400c_setbass(client,msp->bass);
msp3400c_settreble(client,msp->treble);