From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Andrei Kuchynski <akuchynski@chromium.org>
Cc: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
Benson Leung <bleung@chromium.org>,
Jameson Thies <jthies@google.com>,
Tzung-Bi Shih <tzungbi@kernel.org>,
linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev,
Guenter Roeck <groeck@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
"Christian A. Ehrhardt" <lk@c--e.de>,
Venkat Jayaraman <venkat.jayaraman@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 4/5] usb: typec: Implement alternate mode priority handling
Date: Thu, 21 Aug 2025 14:14:55 +0300 [thread overview]
Message-ID: <aKb_rwVqqzipHHqf@kuha.fi.intel.com> (raw)
In-Reply-To: <aKbwby7OYdUpLvhA@kuha.fi.intel.com>
Hi again,
On Thu, Aug 21, 2025 at 01:09:57PM +0300, Heikki Krogerus wrote:
> > diff --git a/drivers/usb/typec/mode_selection.c b/drivers/usb/typec/mode_selection.c
> > new file mode 100644
> > index 000000000000..8a54639b86bf
> > --- /dev/null
> > +++ b/drivers/usb/typec/mode_selection.c
> > @@ -0,0 +1,127 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright 2025 Google LLC.
> > + */
> > +
> > +#include <linux/usb/typec_altmode.h>
> > +#include <linux/slab.h>
> > +#include <linux/list.h>
> > +#include "mode_selection.h"
> > +#include "class.h"
> > +
> > +static const char * const mode_names[TYPEC_ALTMODE_MAX] = {
> > + [TYPEC_ALTMODE_DP] = "DisplayPort",
> > + [TYPEC_ALTMODE_TBT] = "Thunderbolt3",
> > + [TYPEC_ALTMODE_USB4] = "USB4",
> > +};
>
> You only need string for USB4. The altmode names come from the drivers.
Sorry, that won't work with port altmode. But you can still do the
lookup with just the sid.
<snip>
> > +/* -------------------------------------------------------------------------- */
> > +/* port 'mode_priorities' attribute */
> > +
> > +int typec_mode_set_priority(struct typec_altmode *adev, const int priority)
> > +{
> > + struct typec_port *port = to_typec_port(adev->dev.parent);
> > + const enum typec_mode_type mode = typec_svid_to_altmode(adev->svid);
> > + struct mode_selection_state *ms_target = NULL;
> > + struct mode_selection_state *ms, *tmp;
> > +
> > + if (mode >= TYPEC_ALTMODE_MAX || !mode_names[mode])
> > + return -EOPNOTSUPP;
>
> Just support every altmode bind to a driver and USB4. USB4 you
> identify with a specific usb4 device type.
No driver so you would need to use the mode_names, but instead of
doing that, just don't limit this at all.
If there is no name for the mode, use the svid.
thanks,
--
heikki
next prev parent reply other threads:[~2025-08-21 11:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 18:44 [PATCH v1 0/5] USB Type-C alternate mode priorities Andrei Kuchynski
2025-08-14 18:44 ` [PATCH v1 1/5] usb: typec: Add alt_mode_override field to port property Andrei Kuchynski
2025-08-20 10:53 ` Heikki Krogerus
2025-08-21 14:19 ` Andrei Kuchynski
2025-08-14 18:44 ` [PATCH v1 2/5] platform/chrome: cros_ec_typec: Set alt_mode_override flag Andrei Kuchynski
2025-08-14 18:44 ` [PATCH v1 3/5] usb: typec: ucsi: " Andrei Kuchynski
2025-08-20 10:53 ` Heikki Krogerus
2025-08-14 18:44 ` [PATCH v1 4/5] usb: typec: Implement alternate mode priority handling Andrei Kuchynski
2025-08-21 10:09 ` Heikki Krogerus
2025-08-21 11:14 ` Heikki Krogerus [this message]
2025-08-22 12:52 ` Andrei Kuchynski
2025-08-14 18:44 ` [PATCH v1 5/5] usb: typec: Expose alternate mode priority via sysfs Andrei Kuchynski
2025-08-21 7:36 ` Heikki Krogerus
2025-08-21 14:44 ` Andrei Kuchynski
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=aKb_rwVqqzipHHqf@kuha.fi.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=abhishekpandit@chromium.org \
--cc=akuchynski@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=jthies@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lk@c--e.de \
--cc=tzungbi@kernel.org \
--cc=venkat.jayaraman@intel.com \
/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.