[PATCH 6/8] usb: typec: ucsi: yoga-c630: correct response for GET_CURRENT_CAM

Dmitry Baryshkov posted 8 patches 3 months, 2 weeks ago
[PATCH 6/8] usb: typec: ucsi: yoga-c630: correct response for GET_CURRENT_CAM
Posted by Dmitry Baryshkov 3 months, 2 weeks ago
On Lenovo Yoga C630 the EC handles GET_CURRENT_CAM command, but it
returns 1 if DisplayPort is active and 0 otherwise. However in order to
let UCSI drivers handle AltModes correctly, it should return 0 / 0xff.
Correct returned value.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
 drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
index 506faf31b6e3a056e067f2bb69f5e9e5ea40e514..76afd128d42a2573ff55433f815c2773462a6426 100644
--- a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
+++ b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
@@ -111,7 +111,15 @@ static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi,
 		return 0;
 	}
 
-	return ucsi_sync_control_common(ucsi, command, cci, data, size);
+	ret = ucsi_sync_control_common(ucsi, command, cci, data, size);
+	if (ret < 0)
+		return ret;
+
+	/* UCSI_GET_CURRENT_CAM is off-by-one on all ports */
+	if (UCSI_COMMAND(command) == UCSI_GET_CURRENT_CAM && data)
+		((u8 *)data)[0]--;
+
+	return ret;
 }
 
 static bool yoga_c630_ucsi_update_altmodes(struct ucsi *ucsi,

-- 
2.39.5
Re: [PATCH 6/8] usb: typec: ucsi: yoga-c630: correct response for GET_CURRENT_CAM
Posted by Heikki Krogerus 3 months, 2 weeks ago
On Sat, Jun 21, 2025 at 09:13:01PM +0300, Dmitry Baryshkov wrote:
> On Lenovo Yoga C630 the EC handles GET_CURRENT_CAM command, but it
> returns 1 if DisplayPort is active and 0 otherwise. However in order to
> let UCSI drivers handle AltModes correctly, it should return 0 / 0xff.
> Correct returned value.
> 
> 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 | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> index 506faf31b6e3a056e067f2bb69f5e9e5ea40e514..76afd128d42a2573ff55433f815c2773462a6426 100644
> --- a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> +++ b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c
> @@ -111,7 +111,15 @@ static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi,
>  		return 0;
>  	}
>  
> -	return ucsi_sync_control_common(ucsi, command, cci, data, size);
> +	ret = ucsi_sync_control_common(ucsi, command, cci, data, size);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* UCSI_GET_CURRENT_CAM is off-by-one on all ports */
> +	if (UCSI_COMMAND(command) == UCSI_GET_CURRENT_CAM && data)
> +		((u8 *)data)[0]--;
> +
> +	return ret;
>  }
>  
>  static bool yoga_c630_ucsi_update_altmodes(struct ucsi *ucsi,
> 
> -- 
> 2.39.5

-- 
heikki