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

Commit af183c6b authored by Pratham Pratap's avatar Pratham Pratap Committed by Gerrit - the friendly Code Review server
Browse files

usb: pd: Register typec partner in case AAA is connected



Currently PD driver is not registering typec partner if
analog audio adapter(AAA) is connected to the device. Because of
this, userspace will not be notified of the connected adapter
and there will be no notification seen on UI. This change
registers typec partner in case AAA is connected and unregister
it upon disconnect.

Change-Id: Iffd9a43ded068047dd175ccf66de43160da4daaf
Signed-off-by: default avatarPratham Pratap <prathampratap@codeaurora.org>
parent 32735954
Loading
Loading
Loading
Loading
+25 −2
Original line number Diff line number Diff line
@@ -476,6 +476,7 @@ struct usbpd {
	u8			get_battery_status_db;
	bool			send_get_battery_status;
	u32			battery_sts_dobj;
	bool			typec_analog_audio_connected;
};

static LIST_HEAD(_usbpd);	/* useful for debugging */
@@ -3552,6 +3553,18 @@ static void usbpd_sm(struct work_struct *w)
	usbpd_dbg(&pd->dev, "handle state %s\n",
			usbpd_state_strings[pd->current_state]);

	/* Register typec partner in case AAA is connected */
	if (pd->typec_mode == POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER) {
		if (!pd->partner) {
			memset(&pd->partner_identity, 0,
					sizeof(pd->partner_identity));
			pd->partner_desc.usb_pd = false;
			pd->partner_desc.accessory = TYPEC_ACCESSORY_AUDIO;
			pd->partner = typec_register_partner(pd->typec_port,
							&pd->partner_desc);
			pd->typec_analog_audio_connected = true;
		}
	}
	hrtimer_cancel(&pd->timer);
	pd->sm_queued = false;

@@ -3565,9 +3578,18 @@ static void usbpd_sm(struct work_struct *w)
	/* Disconnect? */
	if (pd->current_pr == PR_NONE) {
		if (pd->current_state == PE_UNKNOWN &&
				pd->current_dr == DR_NONE)
			goto sm_done;
				pd->current_dr == DR_NONE) {
			/*
			 * Since PD stack will not be loaded in case AAA is
			 * connected, call disconnect to unregister typec
			 * partner
			 */
			if (!pd->typec_analog_audio_connected &&
					pd->partner)
				handle_disconnect(pd);

			goto sm_done;
		}
		handle_disconnect(pd);
		goto sm_done;
	}
@@ -3637,6 +3659,7 @@ static int usbpd_process_typec_mode(struct usbpd *pd,
		}

		pd->current_pr = PR_NONE;
		pd->typec_analog_audio_connected = false;
		break;

	/* Sink states */