Пример #1
0
static void say_key(int key)
{
	int i, state = key >> 8;

	key &= 0xff;
	for (i = 0; i < 6; i++) {
		if (state & masks[i])
			synth_printf(" %s", spk_msg_get(MSG_STATES_START + i));
	}
	if ((key > 0) && (key <= num_key_names))
		synth_printf(" %s\n",
			     spk_msg_get(MSG_KEYNAMES_START + (key - 1)));
}
Пример #2
0
/*
 * This is called when text is sent to the synth via the synth_direct file.
 */
static ssize_t synth_direct_store(struct kobject *kobj,
				  struct kobj_attribute *attr,
				  const char *buf, size_t count)
{
	u_char tmp[256];
	int len;
	int bytes;
	const char *ptr = buf;
	unsigned long flags;

	if (!synth)
		return -EPERM;

	len = strlen(buf);
	spin_lock_irqsave(&speakup_info.spinlock, flags);
	while (len > 0) {
		bytes = min_t(size_t, len, 250);
		strncpy(tmp, ptr, bytes);
		tmp[bytes] = '\0';
		string_unescape_any_inplace(tmp);
		synth_printf("%s", tmp);
		ptr += bytes;
		len -= bytes;
	}
	spin_unlock_irqrestore(&speakup_info.spinlock, flags);
	return count;
}
Пример #3
0
void do_flush(void)
{
	speakup_info.flushing = 1;
	synth_buffer_clear();
	if (synth->alive) {
		if (pitch_shift) {
			synth_printf("%s", pitch_buff);
			pitch_shift = 0;
		}
	}
	wake_up_interruptible_all(&speakup_event);
	wake_up_process(speakup_task);
}
Пример #4
0
int spk_synth_is_alive_restart(struct spk_synth *synth)
{
	if (synth->alive)
		return 1;
	if (!synth->alive && wait_for_xmitr() > 0) {
		/* restart */
		synth->alive = 1;
		synth_printf("%s", synth->init);
		return 2; /* reenabled */
	}
	pr_warn("%s: can't restart synth\n", synth->long_name);
	return 0;
}
Пример #5
0
/* called by: synth_add() */
static int do_synth_init(struct spk_synth *in_synth)
{
	struct var_t *var;

	synth_release();
	if (in_synth->checkval != SYNTH_CHECK)
		return -EINVAL;
	synth = in_synth;
	synth->alive = 0;
	pr_warn("synth probe\n");
	if (synth->probe(synth) < 0) {
		pr_warn("%s: device probe failed\n", in_synth->name);
		synth = NULL;
		return -ENODEV;
	}
	synth_time_vars[0].u.n.value =
		synth_time_vars[0].u.n.default_val = synth->delay;
	synth_time_vars[1].u.n.value =
		synth_time_vars[1].u.n.default_val = synth->trigger;
	synth_time_vars[2].u.n.value =
		synth_time_vars[2].u.n.default_val = synth->jiffies;
	synth_time_vars[3].u.n.value =
		synth_time_vars[3].u.n.default_val = synth->full;
	synth_printf("%s", synth->init);
	for (var = synth->vars;
		(var->var_id >= 0) && (var->var_id < MAXVARS); var++)
		speakup_register_var(var);
	if (!quiet_boot)
		synth_printf("%s found\n", synth->long_name);
	if (synth->attributes.name
	&& sysfs_create_group(speakup_kobj, &(synth->attributes)) < 0)
		return -ENOMEM;
	synth_flags = synth->flags;
	wake_up_interruptible_all(&speakup_event);
	if (speakup_task)
		wake_up_process(speakup_task);
	return 0;
}
Пример #6
0
void synth_insert_next_index(int sent_num)
{
	int out;
	if (synth->alive) {
		if (sent_num == 0) {
			synth->indexing.currindex++;
			index_count++;
			if (synth->indexing.currindex >
					synth->indexing.highindex)
				synth->indexing.currindex =
					synth->indexing.lowindex;
		}

		out = synth->indexing.currindex * 10 + sent_num;
		synth_printf(synth->indexing.command, out, out);
	}
}
Пример #7
0
/*
 * This is called when text is sent to the synth via the synth_direct file.
 */
static ssize_t synth_direct_store(struct kobject *kobj,
	struct kobj_attribute *attr, const char *buf, size_t count)
{
	u_char tmp[256];
	int len;
	int bytes;
	const char *ptr = buf;

	if (!synth)
		return -EPERM;

	len = strlen(buf);
	while (len > 0) {
		bytes = min_t(size_t, len, 250);
		strncpy(tmp, ptr, bytes);
		tmp[bytes] = '\0';
		xlate(tmp);
		synth_printf("%s", tmp);
		ptr += bytes;
		len -= bytes;
	}
	return count;
}
Пример #8
0
int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
{
	int i, n;
	char *name;
	u_char func, *kp;
	u_short *p_keys, val;

	if (letter_offsets[0] == -1)
		help_init();
	if (type == KT_LATIN) {
		if (ch == SPACE) {
			spk_special_handler = NULL;
			synth_printf("%s\n", spk_msg_get(MSG_LEAVING_HELP));
			return 1;
		}
		ch |= 32; /* lower case */
		if (ch < 'a' || ch > 'z')
			return -1;
		if (letter_offsets[ch - 'a'] == -1) {
			synth_printf(spk_msg_get(MSG_NO_COMMAND), ch);
			synth_printf("\n");
			return 1;
		}
		cur_item = letter_offsets[ch - 'a'];
	} else if (type == KT_CUR) {
		if (ch == 0 &&
		    (MSG_FUNCNAMES_START + cur_item + 1) <= MSG_FUNCNAMES_END)
			cur_item++;
		else if (ch == 3 && cur_item > 0)
			cur_item--;
		else
			return -1;
	} else if (type == KT_SPKUP && ch == SPEAKUP_HELP &&
		   !spk_special_handler) {
		spk_special_handler = spk_handle_help;
		synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO));
		build_key_data(); /* rebuild each time in case new mapping */
		return 1;
	} else {
		name = NULL;
		if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
			synth_printf("%s\n",
				     spk_msg_get(MSG_KEYNAMES_START + key - 1));
			return 1;
		}
		for (i = 0; funcvals[i] != 0 && !name; i++) {
			if (ch == funcvals[i])
				name = spk_msg_get(MSG_FUNCNAMES_START + i);
		}
		if (!name)
			return -1;
		kp = spk_our_keys[key] + 1;
		for (i = 0; i < nstates; i++) {
			if (ch == kp[i])
				break;
		}
		key += (state_tbl[i] << 8);
		say_key(key);
		synth_printf(spk_msg_get(MSG_KEYDESC), name);
		synth_printf("\n");
		return 1;
	}
	name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
	func = funcvals[cur_item];
	synth_printf("%s", name);
	if (key_offsets[func] == 0) {
		synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
		return 1;
	}
	p_keys = key_data + key_offsets[func];
	for (n = 0; p_keys[n]; n++) {
		val = p_keys[n];
		if (n > 0)
			synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
		say_key(val);
	}
	return 1;
}
/* handlers for setting vars */
int spk_set_num_var(int input, struct st_var_header *var, int how)
{
	int val;
	short ret = 0;
	int *p_val = var->p_val;
	int l;
	char buf[32];
	char *cp;
	struct var_t *var_data = var->data;

	if (var_data == NULL)
		return -ENODATA;

	if (how == E_NEW_DEFAULT) {
		if (input < var_data->u.n.low || input > var_data->u.n.high)
			return -ERANGE;
		var_data->u.n.default_val = input;
		return 0;
	}
	if (how == E_DEFAULT) {
		val = var_data->u.n.default_val;
		ret = -ERESTART;
	} else {
		if (how == E_SET)
			val = input;
		else
			val = var_data->u.n.value;
		if (how == E_INC)
			val += input;
		else if (how == E_DEC)
			val -= input;
		if (val < var_data->u.n.low || val > var_data->u.n.high)
			return -ERANGE;
	}
	var_data->u.n.value = val;
	if (var->var_type == VAR_TIME && p_val != NULL) {
		*p_val = msecs_to_jiffies(val);
		return ret;
	}
	if (p_val != NULL)
		*p_val = val;
	if (var->var_id == PUNC_LEVEL) {
		spk_punc_mask = spk_punc_masks[val];
		return ret;
	}
	if (var_data->u.n.multiplier != 0)
		val *= var_data->u.n.multiplier;
	val += var_data->u.n.offset;
	if (var->var_id < FIRST_SYNTH_VAR || synth == NULL)
		return ret;
	if (synth->synth_adjust != NULL) {
		int status = synth->synth_adjust(var);
		return (status != 0) ? status : ret;
	}
	if (!var_data->u.n.synth_fmt)
		return ret;
	if (var->var_id == PITCH)
		cp = spk_pitch_buff;
	else
		cp = buf;
	if (!var_data->u.n.out_str)
		l = sprintf(cp, var_data->u.n.synth_fmt, (int)val);
	else
		l = sprintf(cp,
			var_data->u.n.synth_fmt, var_data->u.n.out_str[val]);
	synth_printf("%s", cp);
	return ret;
}
Пример #10
0
/* handlers for setting vars */
int spk_set_num_var(int input, struct st_var_header *var, int how)
{
	int val;
	int *p_val = var->p_val;
	char buf[32];
	char *cp;
	struct var_t *var_data = var->data;

	if (!var_data)
		return -ENODATA;

	val = var_data->u.n.value;
	switch (how) {
	case E_NEW_DEFAULT:
		if (input < var_data->u.n.low || input > var_data->u.n.high)
			return -ERANGE;
		var_data->u.n.default_val = input;
		return 0;
	case E_DEFAULT:
		val = var_data->u.n.default_val;
		break;
	case E_SET:
		val = input;
		break;
	case E_INC:
		val += input;
		break;
	case E_DEC:
		val -= input;
		break;
	}

	if (val < var_data->u.n.low || val > var_data->u.n.high)
		return -ERANGE;

	var_data->u.n.value = val;
	if (var->var_type == VAR_TIME && p_val) {
		*p_val = msecs_to_jiffies(val);
		return 0;
	}
	if (p_val)
		*p_val = val;
	if (var->var_id == PUNC_LEVEL) {
		spk_punc_mask = spk_punc_masks[val];
		return 0;
	}
	if (var_data->u.n.multiplier != 0)
		val *= var_data->u.n.multiplier;
	val += var_data->u.n.offset;
	if (var->var_id < FIRST_SYNTH_VAR || !synth)
		return 0;
	if (synth->synth_adjust)
		return synth->synth_adjust(var);

	if (!var_data->u.n.synth_fmt)
		return 0;
	if (var->var_id == PITCH)
		cp = spk_pitch_buff;
	else
		cp = buf;
	if (!var_data->u.n.out_str)
		sprintf(cp, var_data->u.n.synth_fmt, (int)val);
	else
		sprintf(cp, var_data->u.n.synth_fmt,
			var_data->u.n.out_str[val]);
	synth_printf("%s", cp);
	return 0;
}