ews.c (7022b15e2a9f878fd5184586064c63352c3dd225) ews.c (da3cec35dd3c31d8706db4bf379372ce70d92118)
1/*
2 * ALSA driver for ICEnsemble ICE1712 (Envy24)
3 *
4 * Lowlevel functions for Terratec EWS88MT/D, EWX24/96, DMX 6Fire
5 *
6 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
7 * 2002 Takashi Iwai <tiwai@suse.de>
8 *

--- 135 unchanged lines hidden (view full) ---

144 */
145
146/* AK4524 chip select; address 0x48 bit 0-3 */
147static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mask)
148{
149 struct ews_spec *spec = ice->spec;
150 unsigned char data, ndata;
151
1/*
2 * ALSA driver for ICEnsemble ICE1712 (Envy24)
3 *
4 * Lowlevel functions for Terratec EWS88MT/D, EWX24/96, DMX 6Fire
5 *
6 * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
7 * 2002 Takashi Iwai <tiwai@suse.de>
8 *

--- 135 unchanged lines hidden (view full) ---

144 */
145
146/* AK4524 chip select; address 0x48 bit 0-3 */
147static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mask)
148{
149 struct ews_spec *spec = ice->spec;
150 unsigned char data, ndata;
151
152 snd_assert(chip_mask >= 0 && chip_mask <= 0x0f, return -EINVAL);
152 if (snd_BUG_ON(chip_mask < 0 || chip_mask > 0x0f))
153 return -EINVAL;
153 snd_i2c_lock(ice->i2c);
154 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1)
155 goto __error;
156 ndata = (data & 0xf0) | chip_mask;
157 if (ndata != data)
158 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF2], &ndata, 1)
159 != 1)
160 goto __error;

--- 519 unchanged lines hidden (view full) ---

680/* analog input sensitivity; address 0x46 */
681static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
682{
683 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
684 struct ews_spec *spec = ice->spec;
685 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
686 unsigned char data;
687
154 snd_i2c_lock(ice->i2c);
155 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1)
156 goto __error;
157 ndata = (data & 0xf0) | chip_mask;
158 if (ndata != data)
159 if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF2], &ndata, 1)
160 != 1)
161 goto __error;

--- 519 unchanged lines hidden (view full) ---

681/* analog input sensitivity; address 0x46 */
682static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
683{
684 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
685 struct ews_spec *spec = ice->spec;
686 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
687 unsigned char data;
688
688 snd_assert(channel >= 0 && channel <= 7, return 0);
689 if (snd_BUG_ON(channel < 0 || channel > 7))
690 return 0;
689 snd_i2c_lock(ice->i2c);
690 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
691 snd_i2c_unlock(ice->i2c);
692 return -EIO;
693 }
694 /* reversed; high = +4dBu, low = -10dBV */
695 ucontrol->value.enumerated.item[0] = data & (1 << channel) ? 0 : 1;
696 snd_i2c_unlock(ice->i2c);
697 return 0;
698}
699
700/* analog output sensitivity; address 0x46 */
701static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
702{
703 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
704 struct ews_spec *spec = ice->spec;
705 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
706 unsigned char data, ndata;
707
691 snd_i2c_lock(ice->i2c);
692 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
693 snd_i2c_unlock(ice->i2c);
694 return -EIO;
695 }
696 /* reversed; high = +4dBu, low = -10dBV */
697 ucontrol->value.enumerated.item[0] = data & (1 << channel) ? 0 : 1;
698 snd_i2c_unlock(ice->i2c);
699 return 0;
700}
701
702/* analog output sensitivity; address 0x46 */
703static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
704{
705 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
706 struct ews_spec *spec = ice->spec;
707 int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
708 unsigned char data, ndata;
709
708 snd_assert(channel >= 0 && channel <= 7, return 0);
710 if (snd_BUG_ON(channel < 0 || channel > 7))
711 return 0;
709 snd_i2c_lock(ice->i2c);
710 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
711 snd_i2c_unlock(ice->i2c);
712 return -EIO;
713 }
714 ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));
715 if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF1],
716 &ndata, 1) != 1) {

--- 368 unchanged lines hidden ---
712 snd_i2c_lock(ice->i2c);
713 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
714 snd_i2c_unlock(ice->i2c);
715 return -EIO;
716 }
717 ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));
718 if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF1],
719 &ndata, 1) != 1) {

--- 368 unchanged lines hidden ---