From: Gerd Knorr - minor msp3400 updates. - add tea6320 support. Signed-off-by: Gerd Knorr Signed-off-by: Andrew Morton --- 25-akpm/drivers/media/video/msp3400.c | 11 +++++- 25-akpm/drivers/media/video/tvaudio.c | 61 ++++++++++++++++++++++++++++++++-- 25-akpm/drivers/media/video/tvaudio.h | 2 - 25-akpm/drivers/media/video/tvmixer.c | 1 4 files changed, 70 insertions(+), 5 deletions(-) diff -puN drivers/media/video/msp3400.c~v4l-tvaudio-update drivers/media/video/msp3400.c --- 25/drivers/media/video/msp3400.c~v4l-tvaudio-update 2005-01-22 18:44:42.021836776 -0800 +++ 25-akpm/drivers/media/video/msp3400.c 2005-01-22 18:44:42.031835256 -0800 @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -379,7 +380,7 @@ static void msp3400c_setvolume(struct i2 int val = 0, bal = 0; if (!muted) { - val = (volume * 0x73 / 65535) << 8; + val = (volume * 0x7F / 65535) << 8; } if (val) { bal = (balance / 256) - 128; @@ -1202,7 +1203,7 @@ static void msp34xxg_set_source(struct i static int msp34xxg_init(struct i2c_client *client) { struct msp3400c *msp = i2c_get_clientdata(client); - int modus; + int modus,std; if (msp3400c_reset(client)) return -1; @@ -1216,6 +1217,7 @@ static int msp34xxg_init(struct i2c_clie /* step-by-step initialisation, as described in the manual */ modus = msp34xx_modus(msp->norm); + std = msp34xx_standard(msp->norm); modus &= ~0x03; /* STATUS_CHANGE=0 */ modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION=1 */ if (msp3400c_write(client, @@ -1223,6 +1225,11 @@ static int msp34xxg_init(struct i2c_clie 0x30/*MODUS*/, modus)) return -1; + if (msp3400c_write(client, + I2C_MSP3400C_DEM, + 0x20/*stanard*/, + std)) + return -1; /* write the dfps that may have an influence on standard/audio autodetection right now */ diff -puN drivers/media/video/tvaudio.c~v4l-tvaudio-update drivers/media/video/tvaudio.c --- 25/drivers/media/video/tvaudio.c~v4l-tvaudio-update 2005-01-22 18:44:42.023836472 -0800 +++ 25-akpm/drivers/media/video/tvaudio.c 2005-01-22 18:44:42.034834800 -0800 @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -1027,6 +1028,21 @@ static int tda9874a_initialize(struct CH #define TEA6300_S_SC 0x04 /* stereo C */ #define TEA6300_S_GMU 0x80 /* general mute */ +#define TEA6320_V 0x00 /* volume (0-5)/loudness off (6)/zero crossing mute(7) */ +#define TEA6320_FFR 0x01 /* fader front right (0-5) */ +#define TEA6320_FFL 0x02 /* fader front left (0-5) */ +#define TEA6320_FRR 0x03 /* fader rear right (0-5) */ +#define TEA6320_FRL 0x04 /* fader rear left (0-5) */ +#define TEA6320_BA 0x05 /* bass (0-4) */ +#define TEA6320_TR 0x06 /* treble (0-4) */ +#define TEA6320_S 0x07 /* switch register */ + /* values for those registers: */ +#define TEA6320_S_SA 0x07 /* stereo A input */ +#define TEA6320_S_SB 0x06 /* stereo B */ +#define TEA6320_S_SC 0x05 /* stereo C */ +#define TEA6320_S_SD 0x04 /* stereo D */ +#define TEA6320_S_GMU 0x80 /* general mute */ + #define TEA6420_S_SA 0x00 /* stereo A input */ #define TEA6420_S_SB 0x01 /* stereo B */ #define TEA6420_S_SC 0x02 /* stereo C */ @@ -1037,6 +1053,20 @@ static int tda9874a_initialize(struct CH static int tea6300_shift10(int val) { return val >> 10; } static int tea6300_shift12(int val) { return val >> 12; } +/* Assumes 16bit input (values 0x3f to 0x0c are unique, values less than */ +/* 0x0c mirror those immediately higher) */ +static int tea6320_volume(int val) { return (val / (65535/(63-12)) + 12) & 0x3f; } +static int tea6320_shift11(int val) { return val >> 11; } +static int tea6320_initialize(struct CHIPSTATE * chip) +{ + chip_write(chip, TEA6320_FFR, 0x3f); + chip_write(chip, TEA6320_FFL, 0x3f); + chip_write(chip, TEA6320_FRR, 0x3f); + chip_write(chip, TEA6320_FRL, 0x3f); + + return 0; +} + /* ---------------------------------------------------------------------- */ /* audio chip descriptions - defines+functions for tda8425 */ @@ -1214,6 +1244,7 @@ int tda9855 = 1; int tda9873 = 1; int tda9874a = 1; int tea6300 = 0; // address clash with msp34xx +int tea6320 = 0; // address clash with msp34xx int tea6420 = 1; int pic16c54 = 1; int ta8874z = 0; // address clash with tda9840 @@ -1225,6 +1256,7 @@ module_param(tda9855, int, 0444); module_param(tda9873, int, 0444); module_param(tda9874a, int, 0444); module_param(tea6300, int, 0444); +module_param(tea6320, int, 0444); module_param(tea6420, int, 0444); module_param(pic16c54, int, 0444); module_param(ta8874z, int, 0444); @@ -1339,6 +1371,28 @@ static struct CHIPDESC chiplist[] = { .inputmute = TEA6300_S_GMU, }, { + .name = "tea6320", + .id = I2C_DRIVERID_TEA6300, + .initialize = tea6320_initialize, + .insmodopt = &tea6320, + .addr_lo = I2C_TEA6300 >> 1, + .addr_hi = I2C_TEA6300 >> 1, + .registers = 8, + .flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL, + + .leftreg = TEA6320_V, + .rightreg = TEA6320_V, + .bassreg = TEA6320_BA, + .treblereg = TEA6320_TR, + .volfunc = tea6320_volume, + .bassfunc = tea6320_shift11, + .treblefunc = tea6320_shift11, + + .inputreg = TEA6320_S, + .inputmap = { TEA6320_S_SA, TEA6420_S_SB, TEA6300_S_SC, TEA6320_S_SD }, + .inputmute = TEA6300_S_GMU, + }, + { .name = "tea6420", .id = I2C_DRIVERID_TEA6420, .insmodopt = &tea6420, @@ -1571,8 +1625,11 @@ static int chip_command(struct i2c_clien if (desc->flags & CHIP_HAS_VOLUME) { va->flags |= VIDEO_AUDIO_VOLUME; va->volume = max(chip->left,chip->right); - va->balance = (32768*min(chip->left,chip->right))/ - (va->volume ? va->volume : 1); + if (va->volume) + va->balance = (32768*min(chip->left,chip->right))/ + va->volume; + else + va->balance = 32768; } if (desc->flags & CHIP_HAS_BASSTREBLE) { va->flags |= VIDEO_AUDIO_BASS | VIDEO_AUDIO_TREBLE; diff -puN drivers/media/video/tvaudio.h~v4l-tvaudio-update drivers/media/video/tvaudio.h --- 25/drivers/media/video/tvaudio.h~v4l-tvaudio-update 2005-01-22 18:44:42.024836320 -0800 +++ 25-akpm/drivers/media/video/tvaudio.h 2005-01-22 18:44:42.032835104 -0800 @@ -8,7 +8,7 @@ #define I2C_TDA985x_H 0xb6 #define I2C_TDA9874 0xb0 /* also used by 9875 */ -#define I2C_TEA6300 0x80 +#define I2C_TEA6300 0x80 /* also used by 6320 */ #define I2C_TEA6420 0x98 #define I2C_PIC16C54 0x96 /* PV951 */ diff -puN drivers/media/video/tvmixer.c~v4l-tvaudio-update drivers/media/video/tvmixer.c --- 25/drivers/media/video/tvmixer.c~v4l-tvaudio-update 2005-01-22 18:44:42.026836016 -0800 +++ 25-akpm/drivers/media/video/tvmixer.c 2005-01-22 18:44:42.034834800 -0800 @@ -1,4 +1,5 @@ #include +#include #include #include #include _