Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f61908f9 authored by David Lin's avatar David Lin Committed by Alex Elder
Browse files

greybus: control: add bundle deactivate and activate operation



Add the AP implementation for the Greybus Control Bundle Deactivate
Operation. This operation requests a Bundle to enter the BUNDLE_OFF
state. All Connections associated with the Bundle must be closed prior
sending this operation.

Add the AP implementation for the Greybus Control Bundle Activate
Operation. This operation requests a specific Bundle to transition from
the BUNDLE_OFF state to the BUNDLE_ACTIVE state.

[elder@linaro.org: fixed a typo pointed out by Johan]

Signed-off-by: default avatarDavid Lin <dtwlin@google.com>
Reviewed-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
parent 2c8e8841
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -298,6 +298,56 @@ int gb_control_bundle_resume(struct gb_control *control, u8 bundle_id)
	return 0;
}

int gb_control_bundle_deactivate(struct gb_control *control, u8 bundle_id)
{
	struct gb_control_bundle_pm_request request;
	struct gb_control_bundle_pm_response response;
	int ret;

	request.bundle_id = bundle_id;
	ret = gb_operation_sync(control->connection,
				GB_CONTROL_TYPE_BUNDLE_DEACTIVATE, &request,
				sizeof(request), &response, sizeof(response));
	if (ret) {
		dev_err(&control->dev,
			"failed to send bundle deactivate: %d\n", ret);
		return ret;
	}

	if (response.status != GB_CONTROL_BUNDLE_PM_OK) {
		dev_err(&control->dev,
			"bundle error while deactivating: %d\n", response.status);
		return gb_control_bundle_pm_status_map(response.status);
	}

	return 0;
}

int gb_control_bundle_activate(struct gb_control *control, u8 bundle_id)
{
	struct gb_control_bundle_pm_request request;
	struct gb_control_bundle_pm_response response;
	int ret;

	request.bundle_id = bundle_id;
	ret = gb_operation_sync(control->connection,
				GB_CONTROL_TYPE_BUNDLE_ACTIVATE, &request,
				sizeof(request), &response, sizeof(response));
	if (ret) {
		dev_err(&control->dev,
			"failed to send bundle activate: %d\n", ret);
		return ret;
	}

	if (response.status != GB_CONTROL_BUNDLE_PM_OK) {
		dev_err(&control->dev,
			"bundle error while activating: %d\n", response.status);
		return gb_control_bundle_pm_status_map(response.status);
	}

	return 0;
}

static ssize_t vendor_string_show(struct device *dev,
			struct device_attribute *attr, char *buf)
{
+2 −0
Original line number Diff line number Diff line
@@ -54,4 +54,6 @@ int gb_control_timesync_authoritative(struct gb_control *control,
				      u64 *frame_time);
int gb_control_bundle_suspend(struct gb_control *control, u8 bundle_id);
int gb_control_bundle_resume(struct gb_control *control, u8 bundle_id);
int gb_control_bundle_deactivate(struct gb_control *control, u8 bundle_id);
int gb_control_bundle_activate(struct gb_control *control, u8 bundle_id);
#endif /* __CONTROL_H */
+2 −0
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ struct gb_protocol_version_response {
#define GB_CONTROL_TYPE_MODE_SWITCH		0x0e
#define GB_CONTROL_TYPE_BUNDLE_SUSPEND		0x0f
#define GB_CONTROL_TYPE_BUNDLE_RESUME		0x10
#define GB_CONTROL_TYPE_BUNDLE_DEACTIVATE	0x11
#define GB_CONTROL_TYPE_BUNDLE_ACTIVATE		0x12

struct gb_control_version_request {
	__u8	major;