35 #define PCXHR_DSP_RESET 0x20
36 #define PCXHR_XLX_CFG 0x24
37 #define PCXHR_XLX_RUER 0x28
38 #define PCXHR_XLX_DATA 0x2C
39 #define PCXHR_XLX_STATUS 0x30
40 #define PCXHR_XLX_LOFREQ 0x34
41 #define PCXHR_XLX_HIFREQ 0x38
42 #define PCXHR_XLX_CSUER 0x3C
43 #define PCXHR_XLX_SELMIC 0x40
48 #define PCXHR_INPB(mgr, x) inb((mgr)->port[PCXHR_DSP] + (x))
49 #define PCXHR_OUTPB(mgr, x, data) outb((data), (mgr)->port[PCXHR_DSP] + (x))
53 #define PCXHR_DSP_RESET_DSP 0x01
54 #define PCXHR_DSP_RESET_MUTE 0x02
55 #define PCXHR_DSP_RESET_CODEC 0x08
56 #define PCXHR_DSP_RESET_SMPTE 0x10
57 #define PCXHR_DSP_RESET_GPO_OFFSET 5
58 #define PCXHR_DSP_RESET_GPO_MASK 0x60
61 #define PCXHR_CFG_SYNCDSP_MASK 0x80
62 #define PCXHR_CFG_DEPENDENCY_MASK 0x60
63 #define PCXHR_CFG_INDEPENDANT_SEL 0x00
64 #define PCXHR_CFG_MASTER_SEL 0x40
65 #define PCXHR_CFG_SLAVE_SEL 0x20
66 #define PCXHR_CFG_DATA_UER1_SEL_MASK 0x10
67 #define PCXHR_CFG_DATAIN_SEL_MASK 0x08
68 #define PCXHR_CFG_SRC_MASK 0x04
69 #define PCXHR_CFG_CLOCK_UER1_SEL_MASK 0x02
70 #define PCXHR_CFG_CLOCKIN_SEL_MASK 0x01
73 #define PCXHR_DATA_CODEC 0x80
74 #define AKM_POWER_CONTROL_CMD 0xA007
75 #define AKM_RESET_ON_CMD 0xA100
76 #define AKM_RESET_OFF_CMD 0xA103
77 #define AKM_CLOCK_INF_55K_CMD 0xA240
78 #define AKM_CLOCK_SUP_55K_CMD 0xA24D
79 #define AKM_MUTE_CMD 0xA38D
80 #define AKM_UNMUTE_CMD 0xA30D
81 #define AKM_LEFT_LEVEL_CMD 0xA600
82 #define AKM_RIGHT_LEVEL_CMD 0xA700
85 #define PCXHR_STAT_SRC_LOCK 0x01
86 #define PCXHR_STAT_LEVEL_IN 0x02
87 #define PCXHR_STAT_GPI_OFFSET 2
88 #define PCXHR_STAT_GPI_MASK 0x0C
89 #define PCXHR_STAT_MIC_CAPS 0x10
91 #define PCXHR_STAT_FREQ_SYNC_MASK 0x01
92 #define PCXHR_STAT_FREQ_UER1_MASK 0x02
93 #define PCXHR_STAT_FREQ_SAVE_MASK 0x80
96 #define PCXHR_SUER1_BIT_U_READ_MASK 0x80
97 #define PCXHR_SUER1_BIT_C_READ_MASK 0x40
98 #define PCXHR_SUER1_DATA_PRESENT_MASK 0x20
99 #define PCXHR_SUER1_CLOCK_PRESENT_MASK 0x10
100 #define PCXHR_SUER_BIT_U_READ_MASK 0x08
101 #define PCXHR_SUER_BIT_C_READ_MASK 0x04
102 #define PCXHR_SUER_DATA_PRESENT_MASK 0x02
103 #define PCXHR_SUER_CLOCK_PRESENT_MASK 0x01
105 #define PCXHR_SUER_BIT_U_WRITE_MASK 0x02
106 #define PCXHR_SUER_BIT_C_WRITE_MASK 0x01
109 #define PCXHR_SELMIC_PREAMPLI_OFFSET 2
110 #define PCXHR_SELMIC_PREAMPLI_MASK 0x0C
111 #define PCXHR_SELMIC_PHANTOM_ALIM 0x80
114 static const unsigned char g_hr222_p_level[] = {
218 static void hr222_config_akm(
struct pcxhr_mgr *mgr,
unsigned short data)
220 unsigned short mask = 0x8000;
234 static int hr222_set_hw_playback_level(
struct pcxhr_mgr *mgr,
249 cmd += g_hr222_p_level[
level];
251 hr222_config_akm(mgr, cmd);
256 static int hr222_set_hw_capture_level(
struct pcxhr_mgr *mgr,
257 int level_l,
int level_r,
int level_mic)
266 data = ((level_mic & 0xff) << 24);
267 data |= ((level_mic & 0xff) << 16);
268 data |= ((level_r & 0xff) << 8);
269 data |= (level_l & 0xff);
273 for (i = 0; i < 32; i++, data <<= 1) {
281 static void hr222_micro_boost(
struct pcxhr_mgr *mgr,
int level);
313 hr222_micro_boost(mgr, 0);
321 static int hr222_pll_freq_register(
unsigned int freq,
322 unsigned int *pllreg,
323 unsigned int *realfreq)
327 if (freq < 6900 || freq > 219000)
329 reg = (28224000 * 2) / freq;
332 *pllreg = reg + 0xC00;
333 else if (reg < 0x200)
334 *pllreg = reg + 0x800;
335 else if (reg < 0x400)
336 *pllreg = reg & 0x1ff;
337 else if (reg < 0x800) {
338 *pllreg = ((reg >> 1) & 0x1ff) + 0x200;
341 *pllreg = ((reg >> 2) & 0x1ff) + 0x400;
345 *realfreq = (28224000 / (reg + 1));
353 unsigned int speed, pllreg = 0;
355 unsigned realfreq =
rate;
359 err = hr222_pll_freq_register(rate, &pllreg, &realfreq);
391 speed = rate < 55000 ? 0 : 1;
408 snd_printdd(
"set_clock to %dHz (realfreq=%d pllreg=%x)\n",
409 rate, realfreq, pllreg);
417 int rate, calc_rate = 0;
434 snd_printdd(
"get_external_clock : type %d not supported\n",
440 snd_printdd(
"get_external_clock(%d) = 0 Hz\n", clock_type);
459 ticks = (ticks & 0x03) << 8;
463 calc_rate = 28224000 /
ticks;
465 if (calc_rate > 184200)
467 else if (calc_rate > 152200)
469 else if (calc_rate > 112000)
471 else if (calc_rate > 92100)
473 else if (calc_rate > 76100)
475 else if (calc_rate > 56000)
477 else if (calc_rate > 46050)
479 else if (calc_rate > 38050)
481 else if (calc_rate > 28000)
483 else if (calc_rate > 23025)
485 else if (calc_rate > 19025)
487 else if (calc_rate > 14000)
489 else if (calc_rate > 11512)
491 else if (calc_rate > 9512)
493 else if (calc_rate > 7000)
498 snd_printdd(
"External clock is at %d Hz (measured %d Hz)\n",
545 snd_printdd(
"hr222_update_analog_audio_level(%s chan=%d)\n",
546 is_capture ?
"capture" :
"playback", channel);
548 int level_l, level_r, level_mic;
561 return hr222_set_hw_capture_level(chip->
mgr,
562 level_l, level_r, level_mic);
569 return hr222_set_hw_playback_level(chip->
mgr, channel, vol);
575 #define SOURCE_LINE 0
576 #define SOURCE_DIGITAL 1
577 #define SOURCE_DIGISRC 2
579 #define SOURCE_LINEMIC 4
598 if (chip->
mgr->board_has_aes1) {
632 int aes_idx,
unsigned char *aes_bits)
634 unsigned char idx = (
unsigned char)(aes_idx * 8);
635 unsigned char temp = 0;
636 unsigned char mask = chip->
mgr->board_has_aes1 ?
639 for (i = 0; i < 8; i++) {
653 int aes_idx,
unsigned char aes_bits)
656 unsigned char new_bits = aes_bits;
657 unsigned char old_bits = chip->
aes_bits[aes_idx];
658 unsigned char idx = (
unsigned char)(aes_idx * 8);
659 for (i = 0; i < 8; i++) {
660 if ((old_bits & 0x01) != (new_bits & 0x01)) {
675 static void hr222_micro_boost(
struct pcxhr_mgr *mgr,
int level)
677 unsigned char boost_mask;
687 snd_printdd(
"hr222_micro_boost : set %x\n", boost_mask);
690 static void hr222_phantom_power(
struct pcxhr_mgr *mgr,
int power)
699 snd_printdd(
"hr222_phantom_power : set %d\n", power);
706 static int hr222_mic_vol_info(
struct snd_kcontrol *kcontrol,
717 static int hr222_mic_vol_get(
struct snd_kcontrol *kcontrol,
727 static int hr222_mic_vol_put(
struct snd_kcontrol *kcontrol,
746 .
name =
"Mic Capture Volume",
747 .
info = hr222_mic_vol_info,
748 .
get = hr222_mic_vol_get,
749 .
put = hr222_mic_vol_put,
750 .
tlv = { .p = db_scale_mic_hr222 },
757 static int hr222_mic_boost_info(
struct snd_kcontrol *kcontrol,
767 static int hr222_mic_boost_get(
struct snd_kcontrol *kcontrol,
777 static int hr222_mic_boost_put(
struct snd_kcontrol *kcontrol,
796 .
name =
"MicBoost Capture Volume",
797 .
info = hr222_mic_boost_info,
798 .
get = hr222_mic_boost_get,
799 .
put = hr222_mic_boost_put,
800 .
tlv = { .p = db_scale_micboost_hr222 },
805 #define hr222_phantom_power_info snd_ctl_boolean_mono_info
807 static int hr222_phantom_power_get(
struct snd_kcontrol *kcontrol,
817 static int hr222_phantom_power_put(
struct snd_kcontrol *kcontrol,
821 int power, changed = 0;
824 power = !!ucontrol->
value.integer.value[0];
826 hr222_phantom_power(chip->
mgr, power);
836 .name =
"Phantom Power Switch",
838 .get = hr222_phantom_power_get,
839 .put = hr222_phantom_power_put,
846 if (!chip->
mgr->board_has_mic)