On Thu, Apr 15, 2021 at 03:24:56PM +0200, Ivo Sbalzarini wrote:
> Thanks a lot! 
> 
> I also got the sound working on this machine now. As far as I 
> can tell, both speakers work and Dolby Atmos works, too, thanks 
> to the awesome quirk by Joshua Stein (jcs@).
> 
> I’m not sure I did everything right here, though it works. 
> Below is the diff.
> 
> cheers,
> - ivo
> 
> 
> Index: azalia.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/azalia.c,v
> retrieving revision 1.259
> diff -u -p -r1.259 azalia.c
> --- azalia.c  25 Oct 2020 07:22:06 -0000      1.259
> +++ azalia.c  15 Apr 2021 13:18:07 -0000
> @@ -490,7 +490,8 @@ azalia_configure_pci(azalia_t *az)
>  
>  const struct pci_matchid azalia_pci_devices[] = {
>       { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_200SERIES_U_HDA },
> -     { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_300SERIES_U_HDA }
> +     { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_300SERIES_U_HDA },
> +     { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_400SERIES_CAVS }
>  };
>  
>  int
> Index: azalia_codec.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/azalia_codec.c,v
> retrieving revision 1.183
> diff -u -p -r1.183 azalia_codec.c
> --- azalia_codec.c    16 Jan 2021 07:02:39 -0000      1.183
> +++ azalia_codec.c    15 Apr 2021 13:18:07 -0000
> @@ -162,9 +162,16 @@ azalia_codec_init_vtbl(codec_t *this)
>               break;
>       case 0x10ec0285:
>               this->name = "Realtek ALC285";
> -             if (this->subid == 0x229217aa)           /* Thinkpad X1 Carbon 
> 7 */
> -                     this->qrks |= AZ_QRK_ROUTE_SPKR2_DAC |
> -                         AZ_QRK_WID_CLOSE_PCBEEP;
> +             if (PCI_VENDOR(this->subid) == PCI_VENDOR_LENOVO) {
> +                if (this->subid == 0x22c017aa) {     /* Thinkpad X1 Extreme 
> 3 */
> +                        this->name = "Realtek ALC3286";
> +                        this->qrks |= AZ_QRK_DOLBY_ATMOS |
> +               AZ_QRK_ROUTE_SPKR2_DAC;
> +         } 
> +         else if (this->subid == 0x229217aa)          /* Thinkpad X1 Carbon 
> 7 */
> +                        this->qrks |= AZ_QRK_ROUTE_SPKR2_DAC |
> +                            AZ_QRK_WID_CLOSE_PCBEEP;
> +      }
>               break;
>       case 0x10ec0287:
>               this->name = "Realtek ALC287";
> 
> 
> 

Thanks for looking at this. Few comments:

- the "PCI_VENDOR(this->subid) == PCI_VENDOR_LENOVO" compares the 16
  lower bits of the subid. It's not necessary because below we compare
  the full 32 bits.

- the "name" field is the codec name; it is identified by the "vid"
  field, so it shouldn't depend on the device subid.

- style: indentation is (8 char) TAB, see style(9).

With above tweaks, I ended up this diff. Could you confirm it still
makes audio work?

Index: azalia.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/azalia.c,v
retrieving revision 1.259
diff -u -p -u -p -r1.259 azalia.c
--- azalia.c    25 Oct 2020 07:22:06 -0000      1.259
+++ azalia.c    19 Apr 2021 15:37:32 -0000
@@ -490,7 +490,8 @@ azalia_configure_pci(azalia_t *az)
 
 const struct pci_matchid azalia_pci_devices[] = {
        { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_200SERIES_U_HDA },
-       { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_300SERIES_U_HDA }
+       { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_300SERIES_U_HDA },
+       { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_400SERIES_CAVS }
 };
 
 int
Index: azalia_codec.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/azalia_codec.c,v
retrieving revision 1.183
diff -u -p -u -p -r1.183 azalia_codec.c
--- azalia_codec.c      16 Jan 2021 07:02:39 -0000      1.183
+++ azalia_codec.c      19 Apr 2021 15:37:32 -0000
@@ -162,9 +162,15 @@ azalia_codec_init_vtbl(codec_t *this)
                break;
        case 0x10ec0285:
                this->name = "Realtek ALC285";
-               if (this->subid == 0x229217aa)           /* Thinkpad X1 Carbon 
7 */
+               if (this->subid == 0x229217aa) {
+                       /* Thinkpad X1 Carbon 7 */
                        this->qrks |= AZ_QRK_ROUTE_SPKR2_DAC |
                            AZ_QRK_WID_CLOSE_PCBEEP;
+                } else if (this->subid == 0x22c017aa) {
+                       /* Thinkpad X1 Extreme 3 */
+                       this->qrks |= AZ_QRK_DOLBY_ATMOS |
+                           AZ_QRK_ROUTE_SPKR2_DAC;
+               }
                break;
        case 0x10ec0287:
                this->name = "Realtek ALC287";

Reply via email to