⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hdsp.c

📁 优龙2410linux2.6.8内核源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	hdsp_set_spdif_professional(hdsp, val);	spin_unlock_irqrestore(&hdsp->lock, flags);	return change;}#define HDSP_SPDIF_EMPHASIS(xname, xindex) \{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \  .info = snd_hdsp_info_spdif_bits, \  .get = snd_hdsp_get_spdif_emphasis, .put = snd_hdsp_put_spdif_emphasis }static int hdsp_spdif_emphasis(hdsp_t *hdsp){	return (hdsp->control_register & HDSP_SPDIFEmphasis) ? 1 : 0;}static int hdsp_set_spdif_emphasis(hdsp_t *hdsp, int val){	if (val) {		hdsp->control_register |= HDSP_SPDIFEmphasis;	} else {		hdsp->control_register &= ~HDSP_SPDIFEmphasis;	}	hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);	return 0;}static int snd_hdsp_get_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);		ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp);	return 0;}static int snd_hdsp_put_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);	unsigned long flags;	int change;	unsigned int val;		if (!snd_hdsp_use_is_exclusive(hdsp))		return -EBUSY;	val = ucontrol->value.integer.value[0] & 1;	spin_lock_irqsave(&hdsp->lock, flags);	change = (int)val != hdsp_spdif_emphasis(hdsp);	hdsp_set_spdif_emphasis(hdsp, val);	spin_unlock_irqrestore(&hdsp->lock, flags);	return change;}#define HDSP_SPDIF_NON_AUDIO(xname, xindex) \{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, .name = xname, .index = xindex, \  .info = snd_hdsp_info_spdif_bits, \  .get = snd_hdsp_get_spdif_nonaudio, .put = snd_hdsp_put_spdif_nonaudio }static int hdsp_spdif_nonaudio(hdsp_t *hdsp){	return (hdsp->control_register & HDSP_SPDIFNonAudio) ? 1 : 0;}static int hdsp_set_spdif_nonaudio(hdsp_t *hdsp, int val){	if (val) {		hdsp->control_register |= HDSP_SPDIFNonAudio;	} else {		hdsp->control_register &= ~HDSP_SPDIFNonAudio;	}	hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);	return 0;}static int snd_hdsp_get_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);		ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp);	return 0;}static int snd_hdsp_put_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);	unsigned long flags;	int change;	unsigned int val;		if (!snd_hdsp_use_is_exclusive(hdsp))		return -EBUSY;	val = ucontrol->value.integer.value[0] & 1;	spin_lock_irqsave(&hdsp->lock, flags);	change = (int)val != hdsp_spdif_nonaudio(hdsp);	hdsp_set_spdif_nonaudio(hdsp, val);	spin_unlock_irqrestore(&hdsp->lock, flags);	return change;}#define HDSP_SPDIF_SAMPLE_RATE(xname, xindex) \{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \  .name = xname, \  .index = xindex, \  .access = SNDRV_CTL_ELEM_ACCESS_READ, \  .info = snd_hdsp_info_spdif_sample_rate, \  .get = snd_hdsp_get_spdif_sample_rate \}static int snd_hdsp_info_spdif_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo){	static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;	uinfo->count = 1;	uinfo->value.enumerated.items = (hdsp->io_type == H9632) ? 10 : 7;	if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)		uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);	return 0;}static int snd_hdsp_get_spdif_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);		switch (hdsp_spdif_sample_rate(hdsp)) {	case 32000:		ucontrol->value.enumerated.item[0] = 0;		break;	case 44100:		ucontrol->value.enumerated.item[0] = 1;		break;	case 48000:		ucontrol->value.enumerated.item[0] = 2;		break;	case 64000:		ucontrol->value.enumerated.item[0] = 3;		break;	case 88200:		ucontrol->value.enumerated.item[0] = 4;		break;	case 96000:		ucontrol->value.enumerated.item[0] = 5;		break;	case 128000:		ucontrol->value.enumerated.item[0] = 7;		break;	case 176400:		ucontrol->value.enumerated.item[0] = 8;		break;	case 192000:		ucontrol->value.enumerated.item[0] = 9;		break;	default:		ucontrol->value.enumerated.item[0] = 6;			}	return 0;}#define HDSP_SYSTEM_SAMPLE_RATE(xname, xindex) \{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \  .name = xname, \  .index = xindex, \  .access = SNDRV_CTL_ELEM_ACCESS_READ, \  .info = snd_hdsp_info_system_sample_rate, \  .get = snd_hdsp_get_system_sample_rate \}static int snd_hdsp_info_system_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo){	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;	uinfo->count = 1;	return 0;}static int snd_hdsp_get_system_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);		ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate;	return 0;}#define HDSP_AUTOSYNC_SAMPLE_RATE(xname, xindex) \{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \  .name = xname, \  .index = xindex, \  .access = SNDRV_CTL_ELEM_ACCESS_READ, \  .info = snd_hdsp_info_autosync_sample_rate, \  .get = snd_hdsp_get_autosync_sample_rate \}static int snd_hdsp_info_autosync_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);	static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};		uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;	uinfo->count = 1;	uinfo->value.enumerated.items = (hdsp->io_type == H9632) ? 10 : 7 ;	if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)		uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);	return 0;}static int snd_hdsp_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);		switch (hdsp_external_sample_rate(hdsp)) {	case 32000:		ucontrol->value.enumerated.item[0] = 0;		break;	case 44100:		ucontrol->value.enumerated.item[0] = 1;		break;	case 48000:		ucontrol->value.enumerated.item[0] = 2;		break;	case 64000:		ucontrol->value.enumerated.item[0] = 3;		break;	case 88200:		ucontrol->value.enumerated.item[0] = 4;		break;	case 96000:		ucontrol->value.enumerated.item[0] = 5;		break;	case 128000:		ucontrol->value.enumerated.item[0] = 7;		break;	case 176400:		ucontrol->value.enumerated.item[0] = 8;		break;	case 192000:		ucontrol->value.enumerated.item[0] = 9;		break;		default:		ucontrol->value.enumerated.item[0] = 6;			}	return 0;}#define HDSP_SYSTEM_CLOCK_MODE(xname, xindex) \{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \  .name = xname, \  .index = xindex, \  .access = SNDRV_CTL_ELEM_ACCESS_READ, \  .info = snd_hdsp_info_system_clock_mode, \  .get = snd_hdsp_get_system_clock_mode \}static int hdsp_system_clock_mode(hdsp_t *hdsp){	if (hdsp->control_register & HDSP_ClockModeMaster) {		return 0;	} else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate) {			return 0;	}	return 1;}static int snd_hdsp_info_system_clock_mode(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo){	static char *texts[] = {"Master", "Slave" };		uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;	uinfo->count = 1;	uinfo->value.enumerated.items = 2;	if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)		uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);	return 0;}static int snd_hdsp_get_system_clock_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);		ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp);	return 0;}#define HDSP_CLOCK_SOURCE(xname, xindex) \{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \  .name = xname, \  .index = xindex, \  .info = snd_hdsp_info_clock_source, \  .get = snd_hdsp_get_clock_source, \  .put = snd_hdsp_put_clock_source \}static int hdsp_clock_source(hdsp_t *hdsp){	if (hdsp->control_register & HDSP_ClockModeMaster) {		switch (hdsp->system_sample_rate) {		case 32000:			return 1;		case 44100:			return 2;		case 48000:			return 3;		case 64000:			return 4;		case 88200:			return 5;		case 96000:			return 6;		case 128000:			return 7;		case 176400:			return 8;		case 192000:			return 9;		default:			return 3;			}	} else {		return 0;	}}static int hdsp_set_clock_source(hdsp_t *hdsp, int mode){	int rate;	switch (mode) {	case HDSP_CLOCK_SOURCE_AUTOSYNC:		if (hdsp_external_sample_rate(hdsp) != 0) {		    if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) {			hdsp->control_register &= ~HDSP_ClockModeMaster;					hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);			return 0;		    }		}		return -1;	case HDSP_CLOCK_SOURCE_INTERNAL_32KHZ:		rate = 32000;		break;	case HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ:		rate = 44100;		break;	    	case HDSP_CLOCK_SOURCE_INTERNAL_48KHZ:		rate = 48000;		break;	case HDSP_CLOCK_SOURCE_INTERNAL_64KHZ:		rate = 64000;		break;	case HDSP_CLOCK_SOURCE_INTERNAL_88_2KHZ:		rate = 88200;		break;	case HDSP_CLOCK_SOURCE_INTERNAL_96KHZ:		rate = 96000;		break;	case HDSP_CLOCK_SOURCE_INTERNAL_128KHZ:		rate = 128000;		break;	case HDSP_CLOCK_SOURCE_INTERNAL_176_4KHZ:		rate = 176400;		break;	case HDSP_CLOCK_SOURCE_INTERNAL_192KHZ:		rate = 192000;		break;	default:		rate = 48000;	}	hdsp->control_register |= HDSP_ClockModeMaster;	hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);	hdsp_set_rate(hdsp, rate, 1);	return 0;}static int snd_hdsp_info_clock_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo){	static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" };	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);		uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;	uinfo->count = 1;	if (hdsp->io_type == H9632)	    uinfo->value.enumerated.items = 10;	else	    uinfo->value.enumerated.items = 7;		if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)		uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);	return 0;}static int snd_hdsp_get_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);		ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp);	return 0;}static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol){	hdsp_t *hdsp = _snd_kcontrol_chip(kcontrol);	unsigned long flags;	int change;	int val;		if (!snd_hdsp_use_is_exclusive(hdsp))		return -EBUSY;	val = ucontrol->value.enumerated.item[0];	if (val < 0) val = 0;	if (hdsp->io_type == H9632) {	    if (val > 9) val = 9;	} else {	    if (val > 6) val = 6;	}	spin_lock_irqsave(&hdsp->lock, flags);	if (val != hdsp_clock_source(hdsp)) {		change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0;	} else {		change = 0;	}	spin_unlock_irqrestore(&hdsp->lock, flags);	return change;}#define HDSP_DA_GAIN(xname, xindex) \{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \  .name = xname, \  .index = xindex, \  .info = snd_hdsp_info_da_gain, \  .get = snd_hdsp_get_da_gain, \  .put = snd_hdsp_put_da_gain \}static int hdsp_da_gain(hdsp_t *hdsp){	switch (hdsp->control_register & HDSP_DAGainMask) {	case HDSP_DAGainHighGain:		return 0;	case HDSP_DAGainPlus4dBu:		return 1;	case HDSP_DAGainMinus10dBV:		return 2;	default:		return 1;		}}static int hdsp_set_da_gain(hdsp_t *hdsp, int m

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -