Example #1
0
static void hfp_microphone_volume(struct ofono_call_volume *cv,
					unsigned char percent,
					ofono_call_volume_cb_t cb,
					void *data)
{
	struct cv_data *vd = ofono_call_volume_get_data(data);
	struct cb_data *cbd = cb_data_new(cb, data);
	char buf[64];

	if (!cbd)
		goto error;

	vd->mic_volume = percent;

	snprintf(buf, sizeof(buf), "AT+VGM=%d",
				(int)(percent*HFP_CALL_VOLUME_MAX/100));

	if (g_at_chat_send(vd->chat, buf, vgm_prefix,
				cv_generic_set_cb, cbd, g_free) > 0)
		return;

error:
	if (cbd)
		g_free(cbd);

	CALLBACK_WITH_FAILURE(cb, data);
}
Example #2
0
static void sync_speaker_volume_cb(const struct ofono_error *error,
					void *user_data)
{
	struct ofono_call_volume *cv = user_data;
	struct cv_data *vd = ofono_call_volume_get_data(cv);

	ofono_call_volume_set_speaker_volume(cv, vd->sp_volume);
}
Example #3
0
static void hfp_call_volume_remove(struct ofono_call_volume *cv)
{
	struct cv_data *vd = ofono_call_volume_get_data(cv);

	ofono_call_volume_set_data(cv, NULL);

	g_free(vd);
}
Example #4
0
static void sync_microphone_volume_cb(const struct ofono_error *error,
					void *user_data)
{
	struct ofono_call_volume *cv = user_data;
	struct cv_data *vd = ofono_call_volume_get_data(cv);

	ofono_call_volume_set_microphone_volume(cv, vd->mic_volume);
}
Example #5
0
static void call_probe_mute(gpointer user_data)
{
	struct ofono_call_volume *cv = user_data;
	struct cv_data *cvd = ofono_call_volume_get_data(cv);

	g_ril_send(cvd->ril, RIL_REQUEST_GET_MUTE, NULL,
			probe_mute_cb, cv, NULL);
}
Example #6
0
static void ril_call_volume_remove(struct ofono_call_volume *cv)
{
	struct cv_data *cvd = ofono_call_volume_get_data(cv);

	ofono_call_volume_set_data(cv, NULL);

	g_ril_unref(cvd->ril);
	g_free(cvd);
}
Example #7
0
static void hfp_call_volume_initialized(gpointer user_data)
{
	struct ofono_call_volume *cv = user_data;
	struct cv_data *vd = ofono_call_volume_get_data(cv);

	DBG("");

	g_at_chat_register(vd->chat, "+VGS:", vgs_notify, FALSE, cv, NULL);
	g_at_chat_register(vd->chat, "+VGM:", vgm_notify, FALSE, cv, NULL);

	ofono_call_volume_register(cv);

	/* set sp and mic volume at 50 percents by default */
	hfp_speaker_volume(cv, 50, sync_speaker_volume_cb, cv);
	hfp_microphone_volume(cv, 50, sync_microphone_volume_cb, cv);
}
Example #8
0
static void vgm_notify(GAtResult *result, gpointer user_data)
{
	struct ofono_call_volume *cv = user_data;
	struct cv_data *vd = ofono_call_volume_get_data(cv);
	GAtResultIter iter;
	gint value;

	g_at_result_iter_init(&iter, result);

	if (!g_at_result_iter_next(&iter, "+VGM:"))
		return;

	if (!g_at_result_iter_next_number(&iter, &value))
		return;

	vd->mic_volume = (unsigned char)(value*100/HFP_CALL_VOLUME_MAX);
	ofono_call_volume_set_microphone_volume(cv, vd->mic_volume);
}
Example #9
0
static void probe_mute_cb(struct ril_msg *message, gpointer user_data)
{
	struct ofono_call_volume *cv = user_data;
	struct cv_data *cvd = ofono_call_volume_get_data(cv);
	struct parcel rilp;
	int muted;

	if (message->error != RIL_E_SUCCESS)
		return;

	g_ril_init_parcel(message, &rilp);

	/* skip length of int[] */
	parcel_r_int32(&rilp);
	muted = parcel_r_int32(&rilp);

	g_ril_append_print_buf(cvd->ril, "{%d}", muted);
	g_ril_print_response(cvd->ril, message);

	ofono_call_volume_set_muted(cv, muted);
}
Example #10
0
static void ril_call_volume_mute(struct ofono_call_volume *cv, int muted,
					ofono_call_volume_cb_t cb, void *data)
{
	struct cv_data *cvd = ofono_call_volume_get_data(cv);
	struct cb_data *cbd = cb_data_new(cb, data, cvd);
	struct parcel rilp;

	DBG("muted: %d", muted);

	parcel_init(&rilp);

	parcel_w_int32(&rilp, 1);
	parcel_w_int32(&rilp, muted);

	g_ril_append_print_buf(cvd->ril, "(%d)", muted);

	if (g_ril_send(cvd->ril, RIL_REQUEST_SET_MUTE, &rilp,
			volume_mute_cb, cbd, g_free) > 0)
		return;

	g_free(cbd);
	CALLBACK_WITH_FAILURE(cb, data);
}