Exemple #1
0
/*
 * load the firmware binaries
 */
static int vx_boot(const char *devname)
{
	snd_hwdep_t *hw;
	const char *id;
	int err, is_pcmcia;
	unsigned int idx, dsps, loaded;
	snd_hwdep_dsp_status_t *stat;

	if ((err = snd_hwdep_open(&hw, devname, O_RDWR)) < 0) {
		error("cannot open hwdep %s\n", devname);
		return err;
	}

	if (check_hwinfo(hw, "VX Loader") < 0) {
		error("invalid hwdep %s\n", devname);
		snd_hwdep_close(hw);
		return -ENODEV;
	}

	snd_hwdep_dsp_status_alloca(&stat);
	/* get the current status */
	if ((err = snd_hwdep_dsp_status(hw, stat)) < 0) {
		error("cannot get version for %s\n", devname);
		snd_hwdep_close(hw);
		return err;
	}

	if (snd_hwdep_dsp_status_get_chip_ready(stat))
		return 0; /* already loaded */

	id = snd_hwdep_dsp_status_get_id(stat);
	if (strcmp(id, "vxpocket") == 0 ||
	    strcmp(id, "vxp440") == 0)
		is_pcmcia = 1;
	else
		is_pcmcia = 0;

	dsps = snd_hwdep_dsp_status_get_num_dsps(stat);
	loaded = snd_hwdep_dsp_status_get_dsp_loaded(stat);

	for (idx = 0; idx < dsps; idx++) {
		if (loaded & (1 << idx))
			continue;
		if ((err = load_firmware(hw, id, idx, is_pcmcia)) < 0) {
			snd_hwdep_close(hw);
			return err;
		}
	}

	snd_hwdep_close(hw);
	return 0;
}
Exemple #2
0
static int init(void)
{
	const char* device;
	snd_hwdep_info_t* info;
	struct pollfd pollfd;
	int err;

	device = drv.device;
	if (!device || !*device) {
		device = search_device();
		if (!device) {
			logprintf(LIRC_ERROR, "device not found");
			return 0;
		}
	}
	err = snd_hwdep_open(&hwdep, device, SND_HWDEP_OPEN_READ);
	if (err < 0) {
		logprintf(LIRC_ERROR, "cannot open %s: %s", device, snd_strerror(err));
		return 0;
	}
	snd_hwdep_info_alloca(&info);
	err = snd_hwdep_info(hwdep, info);
	if (err < 0) {
		snd_hwdep_close(hwdep);
		logprintf(LIRC_ERROR, "cannot get hwdep info: %s", snd_strerror(err));
		return 0;
	}
	if (snd_hwdep_info_get_iface(info) != SND_HWDEP_IFACE_SB_RC) {
		snd_hwdep_close(hwdep);
		logprintf(LIRC_ERROR, "%s is not a Sound Blaster remote control device", device);
		return 0;
	}
	err = snd_hwdep_poll_descriptors(hwdep, &pollfd, 1);
	if (err < 0) {
		snd_hwdep_close(hwdep);
		logprintf(LIRC_ERROR, "cannot get file descriptor: %s", snd_strerror(err));
		return 0;
	}
	if (err != 1) {
		snd_hwdep_close(hwdep);
		logprintf(LIRC_ERROR, "invalid number of file descriptors (%d): %s", err, snd_strerror(err));
		return 0;
	}
	drv.fd = pollfd.fd;
	return 1;
}
Exemple #3
0
static void headset_destroy(struct s_headset *headset)
{
	if (headset == NULL)
		return;
	if (headset->sco_fd != -1) {
		bt_sco_set_fd(headset->handle, -1);
		close(headset->sco_fd);
	}

	sleep(1);
	if (headset->rfcomm_fd != -1) 
		close(headset->rfcomm_fd);
	if (headset->handle != NULL) 
		snd_hwdep_close(headset->handle);
	headset->sco_fd = -1;
	headset->rfcomm_fd = -1;
	headset->handle = NULL;
}
Exemple #4
0
static int deinit(void)
{
	snd_hwdep_close(hwdep);
	drv.fd = -1;
	return 1;
}