Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Mar 2022 09:24:18 -0600
From:      Antonio Olivares <olivares14031@gmail.com>
To:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: get sound from headphones
Message-ID:  <CAJ5UdcMY4Dpt=SpY-Oukpo8%2BD1cxnuY4%2BNnJDT_WJH8iKNpFEg@mail.gmail.com>
In-Reply-To: <CAJ5UdcNo6CQ10X-69DcfB7CgC1w6iUw_=m%2BLdyymtzOie99-kw@mail.gmail.com>
References:  <CAJ5UdcNHy49h3XMifBm3Lngki-ow6mGusvX27awaJ6%2BfDzDW4A@mail.gmail.com> <CAJ5UdcNo6CQ10X-69DcfB7CgC1w6iUw_=m%2BLdyymtzOie99-kw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 9, 2022 at 4:15 AM Antonio Olivares <olivares14031@gmail.com> wrote:
>
> On Wed, Mar 9, 2022 at 4:14 AM Antonio Olivares <olivares14031@gmail.com> wrote:
> >
> > Dear kind folks,
> >
> > I am trying to get sound from headphones, but have not succeeded.  I
> > have booted in verbose mode and I get the following:
> >
> > ---------
> > olivares@ryzen$ cat boot.txt
> > Preloaded elf obj module "snd_hda.ko" at 0xffffffff81db3a40.
> > hdac0.pci6.pcib6.pci0.pcib0.acpi0.nexus0.root0
> > hdac0: <ATI RV810 HDA Controller> [tentative] mem
> > 0xfcf40000-0xfcf43fff irq 55 at device 0.1 on pci6
> > hdac0: PCI card vendor: 0x1545, device: 0xaa68
> > hdac0: HDA Driver Revision: 20120126_0002
> > hdac0: Config options: on=0x00000000 off=0x00000000
> > hdac0: link ctrl 0x2930
> > hdac0: disable nosnoop
> > hdac0: Reserved 0x4000 bytes for rid 0x10 type 3 at 0xfcf40000
> > hdac0: attempting to allocate 1 MSI vector (1 supported)
> > hdac0: using IRQ 16 on cpu3 for MSI
> > hdac0: Caps: OSS 1, ISS 0, BSS 0, NSDO 1, 64bit, CORB 256, RIRB 256
> > hdac0: <ATI RV810 HDA Controller> [attached!] mem
> > 0xfcf40000-0xfcf43fff irq 16,55 at device 0.1 on pci6
> > hdac1.pci8.pcib8.pci0.pcib0.acpi0.nexus0.root0
> > hdac1: <AMD (0x1487) HDA Controller> [tentative] mem
> > 0xfca00000-0xfca07fff irq 36 at device 0.4 on pci8
> > hdac1: PCI card vendor: 0x1043, device: 0x8760
> > hdac1: HDA Driver Revision: 20120126_0002
> > hdac1: Config options: on=0x00000000 off=0x00000000
> > hdac1: link ctrl 0x2830
> > hdac1: disable nosnoop
> > hdac1: Reserved 0x8000 bytes for rid 0x10 type 3 at 0xfca00000
> > hdac1: attempting to allocate 1 MSI vector (1 supported)
> > hdac1: using IRQ 16 on cpu5 for MSI
> > hdac1: Caps: OSS 4, ISS 4, BSS 0, NSDO 1, 64bit, CORB 256, RIRB 256
> > hdac1: <AMD (0x1487) HDA Controller> [attached!] mem
> > 0xfca00000-0xfca07fff irq 16,36 at device 0.4 on pci8
> > hdacc0.hdac0.pci6.pcib6.pci0.pcib0.acpi0.nexus0.root0
> > hdacc0: <ATI R6xx HDA CODEC> [tentative] at cad 0 on hdac0
> > hdaa0.hdacc0.hdac0.pci6.pcib6.pci0.pcib0.acpi0.nexus0.root0
> > hdaa0: <ATI R6xx Audio Function Group> [tentative] at nid 1 on hdacc0
> > hdaa0: Subsystem ID: 0x00aa0100
> > hdaa0: NumGPIO=0 NumGPO=0 NumGPI=0 GPIWake=0 GPIUnsol=0
> > hdaa0: Original pins configuration:
> > hdaa0: nid   0x    as seq device       conn  jack    loc        color   misc
> > hdaa0:  3 18560010 1  0  Digital-out   Jack  Digital 0x18       Unknown 0
> > hdaa0: Patched pins configuration:
> > hdaa0: nid   0x    as seq device       conn  jack    loc        color   misc
> > hdaa0:  3 18560010 1  0  Digital-out   Jack  Digital 0x18       Unknown 0
> > hdaa0: 1 associations found:
> > hdaa0: Association 0 (1) out:
> > hdaa0:  Pin nid=3 seq=0
> > hdaa0: Tracing association 0 (1)
> > hdaa0:  Pin 3 traced to DAC 2
> > hdaa0: Association 0 (1) trace succeeded
> > hdaa0: Looking for additional DAC for association 0 (1)
> > hdaa0: Tracing input monitor
> > hdaa0: Tracing other input monitors
> > hdaa0: Tracing beeper
> > hdaa0: Pin sense: nid=3 sense=0x7fffffff (disconnected, ELD valid)
> > hdaa0: FG config/quirks: forcestereo ivref50 ivref80 ivref100 ivref
> > pcm0.hdaa0.hdacc0.hdac0.pci6.pcib6.pci0.pcib0.acpi0.nexus0.root0
> > pcm0: <ATI R6xx (HDMI)> [tentative] at nid 3 on hdaa0
> > pcm0: <ATI R6xx (HDMI)> [attached!] at nid 3 on hdaa0
> > hdaa0: <ATI R6xx Audio Function Group> [attached!] at nid 1 on hdacc0
> > hdacc0: <ATI R6xx HDA CODEC> [attached!] at cad 0 on hdac0
> > hdacc1.hdac1.pci8.pcib8.pci0.pcib0.acpi0.nexus0.root0
> > hdacc1: <Realtek ALC887 HDA CODEC> [tentative] at cad 0 on hdac1
> > hdaa1.hdacc1.hdac1.pci8.pcib8.pci0.pcib0.acpi0.nexus0.root0
> > hdaa1: <Realtek ALC887 Audio Function Group> [tentative] at nid 1 on hdacc1
> > hdaa1: Subsystem ID: 0x10438760
> > hdaa1: NumGPIO=2 NumGPO=0 NumGPI=0 GPIWake=0 GPIUnsol=1
> > hdaa1:  GPIO0: disabled
> > hdaa1:  GPIO1: disabled
> > hdaa1: Original pins configuration:
> > hdaa1: nid   0x    as seq device       conn  jack    loc        color   misc
> > hdaa1: 17 90460130 3  0  SPDIF-out     Fixed Digital Internal   Unknown 1
> > hdaa1: 18 40330000 0  0  CD            None  ATAPI   0x00       Unknown 0
> > hdaa1: 20 01014010 1  0  Line-out      Jack  1/8     Rear       Green   0
> > hdaa1: 21 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
> > hdaa1: 22 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
> > hdaa1: 23 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
> > hdaa1: 24 01a19040 4  0  Mic           Jack  1/8     Rear       Pink    0
> > hdaa1: 25 02a19050 5  0  Mic           Jack  1/8     Front      Pink    0
> > hdaa1: 26 0181304f 4  15 Line-in       Jack  1/8     Rear       Blue    0
> > hdaa1: 27 02214020 2  0  Headphones    Jack  1/8     Front      Green   0
> > hdaa1: 28 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
> > hdaa1: 29 4046c629 2  9  SPDIF-out     None  Digital 0x00       Res.C   6
> > hdaa1: 30 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
> > hdaa1: 31 411111f0 15 0  Speaker       None  1/8     Rear       Black   1
> > hdaa1: Patching widget caps nid=29 0x00400400 -> 0x00700400
> > hdaa1: Patched pins configuration:
> > hdaa1: nid   0x    as seq device       conn  jack    loc        color   misc
> > hdaa1: 17 90460130 3  0  SPDIF-out     Fixed Digital Internal   Unknown 1
> > hdaa1: 18 40330000 0  0  CD            None  ATAPI   0x00       Unknown 0 DISA
> > hdaa1: 20 01014010 1  0  Line-out      Jack  1/8     Rear       Green   0
> > hdaa1: 21 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
> > hdaa1: 22 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
> > hdaa1: 23 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
> > hdaa1: 24 01a19040 4  0  Mic           Jack  1/8     Rear       Pink    0
> > hdaa1: 25 02a19050 5  0  Mic           Jack  1/8     Front      Pink    0
> > hdaa1: 26 0181304f 4  15 Line-in       Jack  1/8     Rear       Blue    0
> > hdaa1: 27 02214020 2  0  Headphones    Jack  1/8     Front      Green   0
> > hdaa1: 28 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
> > hdaa1: 30 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
> > hdaa1: 31 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
> > hdaa1: 5 associations found:
> > hdaa1: Association 0 (1) out:
> > hdaa1:  Pin nid=20 seq=0
> > hdaa1: Association 1 (2) out:
> > hdaa1:  Pin nid=27 seq=0
> > hdaa1: Association 2 (3) out:
> > hdaa1:  Pin nid=17 seq=0
> > hdaa1: Association 3 (4) in:
> > hdaa1:  Pin nid=24 seq=0
> > hdaa1:  Pin nid=26 seq=15
> > hdaa1: Association 4 (5) in:
> > hdaa1:  Pin nid=25 seq=0
> > hdaa1: Tracing association 0 (1)
> > hdaa1:  Pin 20 traced to DAC 2
> > hdaa1: Association 0 (1) trace succeeded
> > hdaa1: Tracing association 1 (2)
> > hdaa1:  Pin 27 traced to DAC 3
> > hdaa1: Association 1 (2) trace succeeded
> > hdaa1: Tracing association 2 (3)
> > hdaa1:  Pin 17 traced to DAC 16
> > hdaa1: Association 2 (3) trace succeeded
> > hdaa1: Tracing association 3 (4)
> > hdaa1:  Pin 24 traced to ADC 8
> > hdaa1:  Pin 26 traced to ADC 8
> > hdaa1: Association 3 (4) trace succeeded
> > hdaa1: Tracing association 4 (5)
> > hdaa1:  Pin 25 traced to ADC 9
> > hdaa1: Association 4 (5) trace succeeded
> > hdaa1: Looking for additional DAC for association 0 (1)
> > hdaa1: Looking for additional DAC for association 1 (2)
> > hdaa1: Looking for additional DAC for association 2 (3)
> > hdaa1: Looking for additional ADC for association 3 (4)
> > hdaa1: Looking for additional ADC for association 4 (5)
> > hdaa1: Tracing input monitor
> > hdaa1:  Tracing nid 11 to out
> > hdaa1:  nid 11 is input monitor
> > hdaa1:  Tracing nid 34 to out
> > hdaa1:  Tracing nid 35 to out
> > hdaa1: Tracing other input monitors
> > hdaa1:  Tracing nid 24 to out
> > hdaa1:  Tracing nid 25 to out
> > hdaa1:  Tracing nid 26 to out
> > hdaa1: Tracing beeper
> > hdaa1: Pin sense: nid=20 sense=0x80000000 (connected)
> > hdaa1: FG config/quirks: forcestereo ivref50 ivref80 ivref100 ivref
> > pcm1.hdaa1.hdacc1.hdac1.pci8.pcib8.pci0.pcib0.acpi0.nexus0.root0
> > pcm1: <Realtek ALC887 (Rear Analog)> [tentative] at nid 20 and 24,26 on hdaa1
> > pcm1: <Realtek ALC887 (Rear Analog)> [attached!] at nid 20 and 24,26 on hdaa1
> > pcm2.hdaa1.hdacc1.hdac1.pci8.pcib8.pci0.pcib0.acpi0.nexus0.root0
> > pcm2: <Realtek ALC887 (Front Analog)> [tentative] at nid 27 and 25 on hdaa1
> > pcm2: <Realtek ALC887 (Front Analog)> [attached!] at nid 27 and 25 on hdaa1
> > pcm3.hdaa1.hdacc1.hdac1.pci8.pcib8.pci0.pcib0.acpi0.nexus0.root0
> > pcm3: <Realtek ALC887 (Internal Digital)> [tentative] at nid 17 on hdaa1
> > pcm3: <Realtek ALC887 (Internal Digital)> [attached!] at nid 17 on hdaa1
> > hdaa1: <Realtek ALC887 Audio Function Group> [attached!] at nid 1 on hdacc1
> > hdacc1: <Realtek ALC887 HDA CODEC> [attached!] at cad 0 on hdac1
> > ------
> >
> > I am trying to copy from the following website as example:
>
> https://srinicame.blogspot.com/2018/11/auto-switching-of-audio-output-to.html
>
> But do not know what to put in /boot/device.hints
>
> Thanks for your help.
>
> Best Regards,
>
>
> Antonio

Dear fellow users,

Back in 2010, I used a script I found online and it setup specifically
what was needed to put into /boot/device.hints.  This is a new machine
and script does not work as it used to.
Script is
#######
olivares@rosewill:~/Downloads/kerTeX/Documents $ cat snd_head.pm
#!/usr/local/bin/perl
#------------------------------------------------------------------
# If you find bug in this, fix it or leave it.
# Script to get your headphones jack to work on freebsd
# applies only for those having an snd_hda
# c0ded by sch A|T csis.dk / selven pirabarlen cheenaramen
# just in case someone else is having this issue.
# and yes the obvious: am not responsible if this script fucks up
# bsd licensed
#------------------------------------------------------------------

use strict;
use warnings;

#---- Main Body ------------
fixHeadphone();

#---- Function List --------
sub fixHeadphone
{

    my( $nid_head, $nid_mic, $lines_to_add);
    my %nidList=getNid();
    $lines_to_add="";
    $nid_head=$nidList{'line_out'}; #hahaha yeah 'nid head'! hahaha
    $nid_mic=$nidList{'mic'};
    if(trim($nid_head) ne "" && trim($nid_mic) ne "")
    {    $lines_to_add=
"hint.hdac.0.cad0.nid".$nid_head.".config=\"as=1 seq=15
device=Headphones\"\nhint.hdac.0.cad0.nid".$nid_mic.".config=\"as=4
seq=0\"\n"; }
    elsif(trim($nid_head) ne "" && trim($nid_mic) eq "")
    {    $lines_to_add=
"hint.hdac.0.cad0.nid".$nid_head.".config=\"as=1 seq=15
device=Headphones\"";}

    if($lines_to_add ne "")
    {
        if(appendDevHints($lines_to_add)==1)
        {
            print "\n\n device hints have been added\n";
            print " I have made a copy of your original device.hints
in /boot/device.hints.head.orig just in case of trouble\n";
            print " Try REBOOTING, cross fingers and hope it works\n";
            print " If it didnt i guess i screwed up somewhere";
            print " sysctl dev.hdac.0.pindump=1 and  post your dmesg
and /boot/device.hints on freebsd.org forum \n";
            print " Hope it works out for you :) \n";
            print " selven / pcthegreat A|T gmail\n";
            print "\n Go on reboot, what are you reading?\n\n";
        }
    }


}

sub appendDevHints
{
    my($snd_hda_lines)= @_;
    `cp /boot/device.hints /boot/device.hints.head.orig`;
    my $device_hints="/boot/device.hints";
    open(DEVICEHINTS,">>$device_hints") || die("Cannot Open Device Hints");
    print DEVICEHINTS $snd_hda_lines;
    close(DEVICEHINTS);
    return 1;
}

sub getNid
{
    my ($line,@hda_lines,$headPhoned, $miked, $nid_head, $nid_mic,
$HDALOUT, $HDAHP, $MIC);
    my %nidList=();
    $HDALOUT="Line-out";
    $HDAHP="Headphones";
    $MIC="Mic";
    @hda_lines=getHda();
    $headPhoned=0;
    $miked=0;


    foreach(@hda_lines)
    {
        $line=$_;
        if(($line=~ /$HDALOUT/ || $line=~/$HDAHP/) && $line=~/loc\s+2/
&& !$headPhoned)
        {
               $line=$_;
            #print $line;
            $nid_head=grepInBetween($line, "nid", "0x");
            $headPhoned=1; #just not to go through the whole lot
           }

        if($line=~ /$MIC/ && $line=~/loc\s+2/ && !$miked)
        {
            $line=$_;
            #print $line;
            $nid_mic=grepInBetween($line, "nid", "0x");
            $miked=1; #just not to go through the whole lot
        }

    }
    $nidList{'line_out'}=$nid_head;
    $nidList{'mic'}=$nid_mic;

    return %nidList;

}

sub grepInBetween
{
    my($value, $start_boundary, $end_boundary )= @_;
    return trim($1) if $value =~ /\Q$start_boundary\E(.*?)\Q$end_boundary\E/;
}

sub getHda
{
    my (@dmesg_dump, $line,@hda_line, $nid_head, $nid_mic, $HDADEV);
    $HDADEV="hdac0:";
    @dmesg_dump=getDmesg();

    foreach(@dmesg_dump)
    {
        #print $_;
        $line=$_;
        if($line=~ /$HDADEV/)
        {
            push(@hda_line, $line);
        }
    }

    return @hda_line;
}
sub getDmesg
{
    my $result;
    my @dmesg_dump;
    `sysctl dev.hdac.0.pindump=1`;
    $result = `dmesg 2>&1`;
    @dmesg_dump=split("\n", $result);

    return @dmesg_dump;

}

sub trim
{
  my($string)= @_;
  $string =~ s/^\s+//;
  $string =~ s/\s+$//;
  return $string;
}

######
output from script :
#####

root@rosewill:/home/olivares/Downloads/kerTeX/Documents # ./snd_head.pm
Use of uninitialized value $string in substitution (s///) at
./snd_head.pm line 139.
Use of uninitialized value $string in substitution (s///) at
./snd_head.pm line 140.
Use of uninitialized value in string ne at ./snd_head.pm line 27.
Use of uninitialized value $string in substitution (s///) at
./snd_head.pm line 139.
Use of uninitialized value $string in substitution (s///) at
./snd_head.pm line 140.
Use of uninitialized value in string ne at ./snd_head.pm line 29.

root@rosewill:/home/olivares/Downloads/kerTeX/Documents # uname -a
FreeBSD rosewill 13.0-RELEASE-p7 FreeBSD 13.0-RELEASE-p7 #0: Mon Jan
31 18:24:03 UTC 2022
root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
 amd64


Any pointers, fixes or thoughts to get this going will be appreciated.

Best Regards,

Antonio



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ5UdcMY4Dpt=SpY-Oukpo8%2BD1cxnuY4%2BNnJDT_WJH8iKNpFEg>