Commit 687ff8b0 authored by Frank Schaefer's avatar Frank Schaefer Committed by Mauro Carvalho Chehab

[media] em28xx: fix I2S audio sample rate definitions and info output

The audio configuration in chip config register 0x00 and eeprom are always
consistent. But currently the audio configuration #defines for the chip config
register say 0x20 means 3 sample rates and 0x30 5 sample rates, while the eeprom
info output says 0x20 means 1 sample rate and 0x30 3 sample rates.

I've checked the datasheet excerpts I have and it seems that the meaning of
these bits is different for em2820/40 (1 and 3 sample rates) and em2860+
(3 and 5 smaple rates).
I have also checked my Hauppauge WinTV USB 2 (em2840) and the chip/eeprom
audio config 0x20 matches the sample rates reproted by the USB device
descriptor (32k only).
Signed-off-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 2a9ecc17
...@@ -517,17 +517,19 @@ int em28xx_audio_setup(struct em28xx *dev) ...@@ -517,17 +517,19 @@ int em28xx_audio_setup(struct em28xx *dev)
dev->has_alsa_audio = false; dev->has_alsa_audio = false;
dev->audio_mode.has_audio = false; dev->audio_mode.has_audio = false;
return 0; return 0;
} else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) == } else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) != EM28XX_CHIPCFG_AC97) {
EM28XX_CHIPCFG_I2S_3_SAMPRATES) { if (dev->chip_id < CHIP_ID_EM2860 &&
em28xx_info("I2S Audio (3 sample rates)\n"); (cfg & EM28XX_CHIPCFG_AUDIOMASK) ==
dev->audio_mode.i2s_3rates = 1; EM2820_CHIPCFG_I2S_1_SAMPRATE)
} else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) == dev->audio_mode.i2s_samplerates = 1;
EM28XX_CHIPCFG_I2S_5_SAMPRATES) { else if (dev->chip_id >= CHIP_ID_EM2860 &&
em28xx_info("I2S Audio (5 sample rates)\n"); (cfg & EM28XX_CHIPCFG_AUDIOMASK) ==
dev->audio_mode.i2s_5rates = 1; EM2860_CHIPCFG_I2S_5_SAMPRATES)
} dev->audio_mode.i2s_samplerates = 5;
else
if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) != EM28XX_CHIPCFG_AC97) { dev->audio_mode.i2s_samplerates = 3;
em28xx_info("I2S Audio (%d sample rate(s))\n",
dev->audio_mode.i2s_samplerates);
/* Skip the code that does AC97 vendor detection */ /* Skip the code that does AC97 vendor detection */
dev->audio_mode.ac97 = EM28XX_NO_AC97; dev->audio_mode.ac97 = EM28XX_NO_AC97;
goto init_audio; goto init_audio;
......
...@@ -736,10 +736,16 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus, ...@@ -736,10 +736,16 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
em28xx_info("\tAC97 audio (5 sample rates)\n"); em28xx_info("\tAC97 audio (5 sample rates)\n");
break; break;
case 2: case 2:
em28xx_info("\tI2S audio, sample rate=32k\n"); if (dev->chip_id < CHIP_ID_EM2860)
em28xx_info("\tI2S audio, sample rate=32k\n");
else
em28xx_info("\tI2S audio, 3 sample rates\n");
break; break;
case 3: case 3:
em28xx_info("\tI2S audio, 3 sample rates\n"); if (dev->chip_id < CHIP_ID_EM2860)
em28xx_info("\tI2S audio, 3 sample rates\n");
else
em28xx_info("\tI2S audio, 5 sample rates\n");
break; break;
} }
......
...@@ -25,10 +25,12 @@ ...@@ -25,10 +25,12 @@
#define EM28XX_R00_CHIPCFG 0x00 #define EM28XX_R00_CHIPCFG 0x00
/* em28xx Chip Configuration 0x00 */ /* em28xx Chip Configuration 0x00 */
#define EM28XX_CHIPCFG_VENDOR_AUDIO 0x80 #define EM2860_CHIPCFG_VENDOR_AUDIO 0x80
#define EM28XX_CHIPCFG_I2S_VOLUME_CAPABLE 0x40 #define EM2860_CHIPCFG_I2S_VOLUME_CAPABLE 0x40
#define EM28XX_CHIPCFG_I2S_5_SAMPRATES 0x30 #define EM2820_CHIPCFG_I2S_3_SAMPRATES 0x30
#define EM28XX_CHIPCFG_I2S_3_SAMPRATES 0x20 #define EM2860_CHIPCFG_I2S_5_SAMPRATES 0x30
#define EM2820_CHIPCFG_I2S_1_SAMPRATE 0x20
#define EM2860_CHIPCFG_I2S_3_SAMPRATES 0x20
#define EM28XX_CHIPCFG_AC97 0x10 #define EM28XX_CHIPCFG_AC97 0x10
#define EM28XX_CHIPCFG_AUDIOMASK 0x30 #define EM28XX_CHIPCFG_AUDIOMASK 0x30
......
...@@ -295,8 +295,7 @@ struct em28xx_audio_mode { ...@@ -295,8 +295,7 @@ struct em28xx_audio_mode {
unsigned int has_audio:1; unsigned int has_audio:1;
unsigned int i2s_3rates:1; u8 i2s_samplerates;
unsigned int i2s_5rates:1;
}; };
/* em28xx has two audio inputs: tuner and line in. /* em28xx has two audio inputs: tuner and line in.
......
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