Re: [PATCH 1/2] platform/x86: ideapad-laptop: Support for mic and audio leds.

From: Jaroslav Kysela
Date: Sun Dec 22 2024 - 08:31:19 EST


On 19. 12. 24 12:40, Ilpo Järvinen wrote:
On Thu, 19 Dec 2024, Jackie Dong wrote:

...

+};
+
static int ideapad_input_init(struct ideapad_private *priv)
{
struct input_dev *inputdev;
@@ -2023,15 +2033,145 @@ static void ideapad_check_features(struct ideapad_private *priv)
/*
* WMI driver
*/
+#define IDEAPAD_ACPI_LED_MAX (((SNDRV_CTL_ELEM_ACCESS_MIC_LED -\
+ SNDRV_CTL_ELEM_ACCESS_SPK_LED) >> SNDRV_CTL_ELEM_ACCESS_LED_SHIFT) + 1)

Hmm, so you fix the math bug (2-1 is not 2 but 1) with that +1 in the end?

I think you would want something like this here (but I'm not entirely
sure at this point of reading your change):

FIELD_GET(SNDRV_CTL_ELEM_ACCESS_MIC_LED, SNDRV_CTL_ELEM_ACCESS_MIC_LED)

(Remember to make sure you've include for FIELD_GET if that's the correct
way to go here).

There's no reason to use SNDRV_CTL_ELEM_ACCESS definitions here (no direct connection to the sound control API). I would use direct value 2 here, because this extension controls only 2 LEDs.

Jaroslav

--
Jaroslav Kysela <perex@xxxxxxxx>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.