return true;
}
+gboolean handle_pwm_set_polarity(
+ PeripheralIoGdbusPwm *pwm,
+ GDBusMethodInvocation *invocation,
+ gint handle,
+ gint polarity,
+ gpointer user_data)
+{
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ pb_pwm_data_h pwm_handle = GUINT_TO_POINTER(handle);
+ const gchar *id;
+
+ /* Handle validation */
+ if (!pwm_handle || !pwm_handle->client_info.id) {
+ _E("pwm handle is not valid");
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ } else {
+ id = g_dbus_method_invocation_get_sender(invocation);
+ if (strcmp(pwm_handle->client_info.id, id)) {
+ _E("Invalid access, handle id : %s, current id : %s", pwm_handle->client_info.id, id);
+ ret = PERIPHERAL_ERROR_INVALID_OPERATION;
+ } else
+ ret = peripheral_bus_pwm_set_polarity(pwm_handle, polarity);
+ }
+
+ peripheral_io_gdbus_pwm_complete_set_polarity(pwm, invocation, ret);
+
+ return true;
+}
+
+gboolean handle_pwm_get_polarity(
+ PeripheralIoGdbusPwm *pwm,
+ GDBusMethodInvocation *invocation,
+ gint handle,
+ gpointer user_data)
+{
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ pb_pwm_data_h pwm_handle = GUINT_TO_POINTER(handle);
+ const gchar *id;
+ int polarity = 0;
+
+ /* Handle validation */
+ if (!pwm_handle || !pwm_handle->client_info.id) {
+ _E("pwm handle is not valid");
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ } else {
+ id = g_dbus_method_invocation_get_sender(invocation);
+ if (strcmp(pwm_handle->client_info.id, id)) {
+ _E("Invalid access, handle id : %s, current id : %s", pwm_handle->client_info.id, id);
+ ret = PERIPHERAL_ERROR_INVALID_OPERATION;
+ } else
+ ret = peripheral_bus_pwm_get_polarity(pwm_handle, &polarity);
+ }
+
+ peripheral_io_gdbus_pwm_complete_get_polarity(pwm, invocation, polarity, ret);
+
+ return true;
+}
+
gboolean handle_pwm_set_enable(
PeripheralIoGdbusPwm *pwm,
GDBusMethodInvocation *invocation,
G_CALLBACK(handle_pwm_get_duty_cycle),
pb_data);
g_signal_connect(pb_data->pwm_skeleton,
+ "handle-set-polarity",
+ G_CALLBACK(handle_pwm_set_polarity),
+ pb_data);
+ g_signal_connect(pb_data->pwm_skeleton,
+ "handle-get-polarity",
+ G_CALLBACK(handle_pwm_get_polarity),
+ pb_data);
+ g_signal_connect(pb_data->pwm_skeleton,
"handle-set-enable",
G_CALLBACK(handle_pwm_set_enable),
pb_data);
return pwm_get_duty_cycle(pwm->device, pwm->channel, duty_cycle);
}
+int peripheral_bus_pwm_set_polarity(pb_pwm_data_h pwm, int polarity)
+{
+ return pwm_set_polarity(pwm->device, pwm->channel, (pwm_polarity_e)polarity);
+}
+
+int peripheral_bus_pwm_get_polarity(pb_pwm_data_h pwm, int *polarity)
+{
+ return pwm_get_polarity(pwm->device, pwm->channel, (pwm_polarity_e*)polarity);
+}
+
int peripheral_bus_pwm_set_enable(pb_pwm_data_h pwm, bool enable)
{
return pwm_set_enable(pwm->device, pwm->channel, enable);
int peripheral_bus_pwm_get_period(pb_pwm_data_h pwm, int *period);
int peripheral_bus_pwm_set_duty_cycle(pb_pwm_data_h pwm, int duty_cycle);
int peripheral_bus_pwm_get_duty_cycle(pb_pwm_data_h pwm, int *duty_cycle);
+int peripheral_bus_pwm_set_polarity(pb_pwm_data_h pwm, int polarity);
+int peripheral_bus_pwm_get_polarity(pb_pwm_data_h pwm, int *polarity);
int peripheral_bus_pwm_set_enable(pb_pwm_data_h pwm, bool enable);
int peripheral_bus_pwm_get_enable(pb_pwm_data_h pwm, bool *enable);
<arg type="i" name="duty_cycle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
+ <method name="SetPolarity">
+ <arg type="u" name="handle" direction="in"/>
+ <arg type="i" name="polarity" direction="in"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
+ <method name="GetPolarity">
+ <arg type="u" name="handle" direction="in"/>
+ <arg type="i" name="polarity" direction="out"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
<method name="SetEnable">
<arg type="u" name="handle" direction="in"/>
<arg type="b" name="enable" direction="in"/>