// SPDX-License-Identifier: GPL-2.0-or-later /* * cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver * * (c) 2001 Michael Eskin, Tom Zakrajsek [Windows version] * (c) 2002 Yurij Sysoev <yurij@naturesoft.net> * (c) 2003 Gerd Knorr <kraxel@bytesex.org> * * ----------------------------------------------------------------------- * * Lot of voodoo here. Even the data sheet doesn't help to * understand what is going on here, the documentation for the audio * part of the cx2388x chip is *very* bad. * * Some of this comes from party done linux driver sources I got from * [undocumented]. * * Some comes from the dscaler sources, one of the dscaler driver guy works * for Conexant ... * * -----------------------------------------------------------------------
*/
staticvoid set_audio_registers(struct cx88_core *core, conststruct rlist *l)
{ int i;
for (i = 0; l[i].reg; i++) { switch (l[i].reg) { case AUD_PDF_DDS_CNST_BYTE2: case AUD_PDF_DDS_CNST_BYTE1: case AUD_PDF_DDS_CNST_BYTE0: case AUD_QAM_MODE: case AUD_PHACC_FREQ_8MSB: case AUD_PHACC_FREQ_8LSB:
cx_writeb(l[i].reg, l[i].val); break; default:
cx_write(l[i].reg, l[i].val); break;
}
}
}
/* restart dma; This avoids buzz in NICAM and is good in others */
cx88_stop_audio_dma(core);
cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
cx88_start_audio_dma(core);
if (core->board.mpeg & CX88_MPEG_BLACKBIRD) {
cx_write(AUD_I2SINPUTCNTL, 4);
cx_write(AUD_BAUDRATE, 1); /* * 'pass-thru mode': this enables the i2s * output to the mpeg encoder
*/
cx_set(AUD_CTL, EN_I2SOUT_ENABLE);
cx_write(AUD_I2SOUTPUTCNTL, 1);
cx_write(AUD_I2SCNTL, 0); /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */
} if ((always_analog) || (!(core->board.mpeg & CX88_MPEG_BLACKBIRD))) {
ctl |= EN_DAC_ENABLE;
cx_write(AUD_CTL, ctl);
}
{AUD_POLYPH80SCALEFAC, 0x0003},
{ /* end of list */ },
};
/* * It is enough to leave default values? * * No, it's not! The deemphasis registers are reset to the 75us * values by default. Analyzing the spectrum of the decoded audio * reveals that "no deemphasis" is the same as 75 us, while the 50 us * setting results in less deemphasis.
*/ staticconststruct rlist fm_no_deemph[] = {
{AUD_POLYPH80SCALEFAC, 0x0003},
{ /* end of list */ },
};
staticint cx88_detect_nicam(struct cx88_core *core)
{ int i, j = 0;
dprintk("start nicam autodetect.\n");
for (i = 0; i < 6; i++) { /* if bit1=1 then nicam is detected */
j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1);
if (j == 1) {
dprintk("nicam is detected.\n"); return 1;
}
/* wait a little bit for next reading status */
usleep_range(10000, 20000);
}
dprintk("nicam is not detected.\n"); return 0;
}
void cx88_set_tvaudio(struct cx88_core *core)
{ switch (core->tvaudio) { case WW_BTSC:
set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); break; case WW_BG: case WW_DK: case WW_M: case WW_I: case WW_L: /* prepare all dsp registers */
set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
/* * set nicam mode - otherwise * AUD_NICAM_STATUS2 contains wrong values
*/
set_audio_standard_NICAM(core, EN_NICAM_AUTO_STEREO); if (cx88_detect_nicam(core) == 0) { /* fall back to fm / am mono */
set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
core->audiomode_current = V4L2_TUNER_MODE_MONO;
core->use_nicam = 0;
} else {
core->use_nicam = 1;
} break; case WW_EIAJ:
set_audio_standard_EIAJ(core); break; case WW_FM:
set_audio_standard_FM(core, radio_deemphasis); break; case WW_I2SADC:
set_audio_start(core, 0x01); /* * Slave/Philips/Autobaud * NB on Nova-S bit1 NPhilipsSony appears to be inverted: * 0= Sony, 1=Philips
*/
cx_write(AUD_I2SINPUTCNTL, core->board.i2sinputcntl); /* Switch to "I2S ADC mode" */
cx_write(AUD_I2SCNTL, 0x1);
set_audio_finish(core, EN_I2SIN_ENABLE); break; case WW_NONE: case WW_I2SPT:
pr_info("unknown tv audio mode [%d]\n", core->tvaudio); break;
}
}
EXPORT_SYMBOL(cx88_set_tvaudio);
switch (mode) { case 0:
t->audmode = V4L2_TUNER_MODE_STEREO; break; case 1:
t->audmode = V4L2_TUNER_MODE_LANG2; break; case 2:
t->audmode = V4L2_TUNER_MODE_MONO; break; case 3:
t->audmode = V4L2_TUNER_MODE_SAP; break;
}
switch (core->tvaudio) { case WW_BTSC: case WW_BG: case WW_DK: case WW_M: case WW_EIAJ: if (!core->use_nicam) {
t->rxsubchans = cx88_dsp_detect_stereo_sap(core); break;
} break; case WW_NONE: case WW_I: case WW_L: case WW_I2SPT: case WW_FM: case WW_I2SADC: /* nothing */ break;
}
/* If software stereo detection is not supported... */ if (t->rxsubchans == UNSET) {
t->rxsubchans = V4L2_TUNER_SUB_MONO; /* * If the hardware itself detected stereo, also return * stereo as an available subchannel
*/ if (t->audmode == V4L2_TUNER_MODE_STEREO)
t->rxsubchans |= V4L2_TUNER_SUB_STEREO;
}
}
EXPORT_SYMBOL(cx88_get_stereo);
if (manual) {
core->audiomode_manual = mode;
} else { if (core->audiomode_manual != UNSET) return;
}
core->audiomode_current = mode;
switch (core->tvaudio) { case WW_BTSC: switch (mode) { case V4L2_TUNER_MODE_MONO:
set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_MONO); break; case V4L2_TUNER_MODE_LANG1:
set_audio_standard_BTSC(core, 0, EN_BTSC_AUTO_STEREO); break; case V4L2_TUNER_MODE_LANG2:
set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP); break; case V4L2_TUNER_MODE_STEREO: case V4L2_TUNER_MODE_LANG1_LANG2:
set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO); break;
} break; case WW_BG: case WW_DK: case WW_M: case WW_I: case WW_L: if (core->use_nicam == 1) { switch (mode) { case V4L2_TUNER_MODE_MONO: case V4L2_TUNER_MODE_LANG1:
set_audio_standard_NICAM(core,
EN_NICAM_FORCE_MONO1); break; case V4L2_TUNER_MODE_LANG2:
set_audio_standard_NICAM(core,
EN_NICAM_FORCE_MONO2); break; case V4L2_TUNER_MODE_STEREO: case V4L2_TUNER_MODE_LANG1_LANG2:
set_audio_standard_NICAM(core,
EN_NICAM_FORCE_STEREO); break;
}
} else { if ((core->tvaudio == WW_I) ||
(core->tvaudio == WW_L)) { /* fall back to fm / am mono */
set_audio_standard_A2(core, EN_A2_FORCE_MONO1);
} else { /* TODO: Add A2 autodection */
mask = 0x3f; switch (mode) { case V4L2_TUNER_MODE_MONO: case V4L2_TUNER_MODE_LANG1:
ctl = EN_A2_FORCE_MONO1; break; case V4L2_TUNER_MODE_LANG2:
ctl = EN_A2_FORCE_MONO2; break; case V4L2_TUNER_MODE_STEREO: case V4L2_TUNER_MODE_LANG1_LANG2:
ctl = EN_A2_FORCE_STEREO; break;
}
}
} break; case WW_FM: switch (mode) { case V4L2_TUNER_MODE_MONO:
ctl = EN_FMRADIO_FORCE_MONO;
mask = 0x3f; break; case V4L2_TUNER_MODE_STEREO:
ctl = EN_FMRADIO_AUTO_STEREO;
mask = 0x3f; break;
} break; case WW_I2SADC: case WW_NONE: case WW_EIAJ: case WW_I2SPT: /* DO NOTHING */ break;
}
dprintk("cx88: tvaudio thread started\n");
set_freezable(); for (;;) {
msleep_interruptible(1000); if (kthread_should_stop()) break;
try_to_freeze();
switch (core->tvaudio) { case WW_BG: case WW_DK: case WW_M: case WW_I: case WW_L: if (core->use_nicam) goto hw_autodetect;
/* just monitor the audio status for now ... */
memset(&t, 0, sizeof(t));
cx88_get_stereo(core, &t);
if (core->audiomode_manual != UNSET) /* manually set, don't do anything. */ continue;
/* monitor signal and set stereo if available */ if (t.rxsubchans & V4L2_TUNER_SUB_STEREO)
mode = V4L2_TUNER_MODE_STEREO; else
mode = V4L2_TUNER_MODE_MONO; if (mode == core->audiomode_current) continue; /* automatically switch to best available mode */
cx88_set_stereo(core, mode, 0); break; case WW_NONE: case WW_BTSC: case WW_EIAJ: case WW_I2SPT: case WW_FM: case WW_I2SADC:
hw_autodetect: /* * stereo autodetection is supported by hardware so * we don't need to do it manually. Do nothing.
*/ break;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.