Re: [PATCH v5] ALSA: hda/tas2781: Add speaker id check for ASUS projects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sat, Nov 16, 2024 at 03:50:06PM +0800, Baojun Xu wrote:
> Add speaker id check by gpio in ACPI for ASUS projects.
> In other vendors, speaker id was checked by BIOS, and was applied in
> last bit of subsys id, so we can load corresponding firmware binary file
> for its speaker by subsys id.
> But in ASUS project, the firmware binary name will be appended an extra
> number to tell the speakers from different vendors. And this single digit
> come from gpio level of speaker id in BIOS.

...

> +	// Speaker id was needed for ASUS projects.
> +	if (!strncmp(sub, TAS2781_ASUS_ID, strlen(TAS2781_ASUS_ID))) {

Better approach is

	ret = sscanf(sub, "%04x%04x", &vid, &did);
	if (ret == 2 && vid == ASUS_ID) {
		... // matched to ASUS_ID
	} else {
		... // no match
	}

Alternatively it can be

	u32 subid;

	ret = kstrtou32(sub, 16, &subid);
	if (ret || upper_16_bits(subid) != ASUS_ID) {
		... // no match (as in previous 'else')
	} else {
		... // matched to ASUS_ID
	}

With it it will be clearer to see what's going on here.

With the above you can get rid of the custom constant and
use PCI_VENDOR_ID_ASUSTEK directly.

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux