From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 3/8] usb: typec: ucsi: yoga-c630: remove duplicate AltModes
Date: Tue, 24 Jun 2025 12:08:36 +0300 [thread overview]
Message-ID: <aFprFG2Pmnx1aAXT@kuha.fi.intel.com> (raw)
In-Reply-To: <20250621-c630-ucsi-v1-3-a86de5e11361@oss.qualcomm.com>
On Sat, Jun 21, 2025 at 09:12:58PM +0300, Dmitry Baryshkov wrote:
> On Lenovo Yoga C630 the EC firmware is buggy and it returns duplicate
> AltModes over and over again instead of returning an empty one, as
> demanded by the spec. Ignore extra altmodes by zeroing them in the
> update_altmodes() callback. It is not possible to shortcut that in the
> sync_control() callback since we need to know if the AltMode matches the
> first reported AltMode or not.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> index 47e8dd5b255b2b306dd9c3d6ac8c3b896954981a..7cc1342d6e2f1d2c6f5b95caa48a711a280b91d3 100644
> --- a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> +++ b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> @@ -71,6 +71,28 @@ static int yoga_c630_ucsi_async_control(struct ucsi *ucsi, u64 command)
> return yoga_c630_ec_ucsi_write(uec->ec, (u8*)&command);
> }
>
> +static bool yoga_c630_ucsi_update_altmodes(struct ucsi *ucsi,
> + u8 recipient,
> + struct ucsi_altmode *orig,
> + struct ucsi_altmode *updated)
> +{
> + int i;
> +
> + if (orig[0].svid == 0 || recipient != UCSI_RECIPIENT_SOP)
> + return false;
> +
> + /* EC is nice and repeats altmodes again and again. Ignore copies. */
> + for (i = 1; i < UCSI_MAX_ALTMODES; i++) {
> + if (orig[i].svid == orig[0].svid) {
> + dev_dbg(ucsi->dev, "Found duplicate altmodes, starting from %d\n", i);
> + memset(&orig[i], 0, (UCSI_MAX_ALTMODES - i) * sizeof(*orig));
> + break;
> + }
> + }
> +
> + return false;
> +}
> +
> static const struct ucsi_operations yoga_c630_ucsi_ops = {
> .read_version = yoga_c630_ucsi_read_version,
> .read_cci = yoga_c630_ucsi_read_cci,
> @@ -78,6 +100,7 @@ static const struct ucsi_operations yoga_c630_ucsi_ops = {
> .read_message_in = yoga_c630_ucsi_read_message_in,
> .sync_control = ucsi_sync_control_common,
> .async_control = yoga_c630_ucsi_async_control,
> + .update_altmodes = yoga_c630_ucsi_update_altmodes,
> };
>
> static int yoga_c630_ucsi_notify(struct notifier_block *nb,
>
> --
> 2.39.5
--
heikki
next prev parent reply other threads:[~2025-06-24 9:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-21 18:12 [PATCH 0/8] usb: typec: ucsi: yoga-c630: enable DisplayPort support Dmitry Baryshkov
2025-06-21 18:12 ` [PATCH 1/8] usb: typec: ucsi: yoga-c630: fix error and remove paths Dmitry Baryshkov
2025-06-24 9:05 ` Heikki Krogerus
2025-06-21 18:12 ` [PATCH 2/8] usb: typec: ucsi: add recipient arg to update_altmodes() callback Dmitry Baryshkov
2025-06-24 9:07 ` Heikki Krogerus
2025-06-21 18:12 ` [PATCH 3/8] usb: typec: ucsi: yoga-c630: remove duplicate AltModes Dmitry Baryshkov
2025-06-24 9:08 ` Heikki Krogerus [this message]
2025-06-21 18:12 ` [PATCH 4/8] usb: typec: ucsi: yoga-c630: remove extra AltModes for port 1 Dmitry Baryshkov
2025-06-24 9:12 ` Heikki Krogerus
2025-06-21 18:13 ` [PATCH 5/8] usb: typec: ucsi: yoga-c630: fake AltModes for port 0 Dmitry Baryshkov
2025-06-24 9:13 ` Heikki Krogerus
2025-06-21 18:13 ` [PATCH 6/8] usb: typec: ucsi: yoga-c630: correct response for GET_CURRENT_CAM Dmitry Baryshkov
2025-06-24 9:16 ` Heikki Krogerus
2025-06-21 18:13 ` [PATCH 7/8] usb: typec: ucsi: yoga-c630: handle USB / HPD messages to set port orientation Dmitry Baryshkov
2025-06-24 9:20 ` Heikki Krogerus
2025-06-21 18:13 ` [PATCH 8/8] usb: typec: ucsi: yoga-c630: register DRM HPD bridge Dmitry Baryshkov
2025-06-24 9:21 ` Heikki Krogerus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aFprFG2Pmnx1aAXT@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.