Switch One Jack From Headphones To Mic Or Line-in

Good evening!

Notebook ASUS X555LJ on Intel(R) Core(TM) i3-4005U CPU @ 1.70GHz
Installed FreeBSD 10.2 RELEASE amd64 and then update to 11-CURRENT amd64.

There is a need to switch the single jack from Headphones mode to Line-in mode or Mic. Need record sound from this jack.

Code:
cat /dev/sndstat
FreeBSD Audio Driver (64bit 2009061500/amd64)
Installed devices:
pcm0: <Intel Haswell (HDMI/DP 8ch)> on hdaa0  (1p:1v/0r:0v)
pcm1: <Realtek (0x0233) (Internal Analog)> on hdaa1  (1p:4v/2r:4v) default
pcm2: <Realtek (0x0233) (Right Analog Headphones)> on hdaa1  (1p:1v/0r:0v)
No devices installed from userspace.

after sysctl hw.snd.verbose=1

Code:
sysctl dev.hdac.1.pindump=1 && dmesg

hdaa1: Dumping AFG pins:
hdaa1: nid  0x  as seq device  conn  jack  loc  color  misc
hdaa1: 18 40000000 0  0  Line-out  None  Unknown 0x00  Unknown 0 DISA
hdaa1:  Caps: IN   
hdaa1: 20 90170110 1  0  Speaker  Fixed Analog  Internal  Unknown 1
hdaa1:  Caps:  OUT  EAPD  Sense: 0x00000000 (disconnected)
hdaa1: 23 411111f0 15 0  Speaker  None  1/8  Rear  Black  1 DISA
hdaa1:  Caps:  OUT   
hdaa1: 24 411111f0 15 0  Speaker  None  1/8  Rear  Black  1 DISA
hdaa1:  Caps: IN  VREF Sense: 0x00000000 (disconnected)
hdaa1: 25 411111f0 15 0  Speaker  None  1/8  Rear  Black  1 DISA
hdaa1:  Caps: IN  VREF Sense: 0x00000000 (disconnected)
hdaa1: 26 411111f0 15 0  Speaker  None  1/8  Rear  Black  1 DISA
hdaa1:  Caps: IN  VREF Sense: 0x00000000 (disconnected)
hdaa1: 27 90a70130 3  0  Mic  Fixed Analog  Internal  Unknown 1
hdaa1:  Caps: IN OUT HP EAPD VREF Sense: 0x00000000 (disconnected)
hdaa1: 30 411111f0 15 0  Speaker  None  1/8  Rear  Black  1 DISA
hdaa1:  Caps:  OUT  Sense: 0x00000000 (disconnected)
hdaa1: [B]33[/B] 04211020 2  0  [B]Headphones[/B]  Jack  1/8  Right  Black  0
hdaa1:  Caps:  OUT HP EAPD  Sense: 0x00000000 (disconnected)
hdaa1: NumGPIO=3 NumGPO=0 NumGPI=0 GPIWake=0 GPIUnsol=1
hdaa1:  GPIO0: disabled
hdaa1:  GPIO1: disabled
hdaa1:  GPIO2: disabled
Change mode made by /boot/device.hints:
Code:
hint.hdac.1.cad0.nid33.config="as=2 seq=1 device=Line-in conn=Jack loc=Right color=Blue"

But this not work and device pcm2 disappear

Also not working are the following options:
Code:
hint.hdac.1.cad0.nid33.config="as=2 seq=0 device=Line-in conn=Jack loc=Right color=Blue"
hint.hdac.1.cad0.nid33.config="as=2 seq=0 device=Mic"
hint.hdac.1.cad0.nid33.config="as=2 seq=0 device=Line-in conn=Jack loc=Rear color=Blue"
hint.hdac.1.cad0.nid33.config="as=2 seq=1 device=Line-in conn=Jack loc=Right color=Blue"
hint.hdac.1.cad0.nid33.config="as=3 seq=15 device=Line-in conn=Jack loc=Rear color=Blue"
hint.hdac.1.cad0.nid33.config="as=3 seq=1 device=Line-in"
hint.hdac.1.cad0.nid33.config="as=3 seq=1 device=Mic"
hint.hdac.1.cad0.nid33.config="as=4 seq=15 device=Line-in conn=Jack"
hint.hdac.1.cad0.nid33.config="as=4 seq=0 device=Line-in"
hint.hdac.1.cad0.nid33.config="as=5 seq=0 device=Line-in"
hint.hdac.1.cad0.nid33.config="as=6 seq=0 device=Line-in"
hint.hdac.1.cad0.nid33.config="as=7 seq=0 device=Line-in"
Work only one variant, but mode continue headphones:
Code:
hint.hdac.1.cad0.nid33.config="as=2 seq=15"
Detailed analysis of the snd_hda(4) did not give ready-made solutions.

It's all in as and seq, but how to choose correctly?
 

Attachments

  • asus_X555LJ_right_panel.png
    asus_X555LJ_right_panel.png
    53.8 KB · Views: 467
Good day!
Well, if it's important, we will discuss only the version FreeBSD 10.2 RELEASE amd64.
 
Hmm.
We have to think.
However it is normal practice that one jack and it works as a headphone and as a microphone. Strange saving of course.
The choice is made by the user at the time of sticking the socket in another operating system such as MS WIN.
And I want to put jack in a state of constant.
I'll note that iron implies this, but how to switch programmatically - that is the question ;)
 
There are two record channels in pcm1, you've probably checked where they come from.

Juha

I too have noticed it.

Code:
cat /dev/sndstat
FreeBSD Audio Driver (64bit 2009061500/amd64)
Installed devices:
pcm0: <Intel Haswell (HDMI/DP 8ch)> on hdaa0  (1p:1v/0r:0v)
pcm1: <Realtek (0x0233) (Internal Analog)> on hdaa1  (1p:4v/2r:4v) default
pcm2: <Realtek (0x0233) (Right Analog Headphones)> on hdaa1  (1p:1v/0r:0v)

and how do you know who is a two channel recording?
 
One thing that has not been mentioned is that newer hardware combines headphones and mic into a single 4 pin jack. Older systems use a headphone/line-out jack with 3 pins (right channel, left channel, common). The older 3 pin jacks were usually green. The mic would usually be a separate blue jack with 2 pins (input, common). If you are using a 4 pin connector, the mic should just work.

Edit: remove redundant 3pins.
 
One thing that has not been mentioned is that newer hardware combines headphones and mic into a single 4 pin jack. Older systems use a 3 pin headphone/line-out jack with 3 pins (right channel, left channel, common). The older 3 pin jacks were usually green. The mic would usually be a separate blue jack with 2 pins (input, common). If you are using a 4 pin connector, the mic should just work.
I understood and realized that a little wrong. Need an adapter. At the output of one plug with 4 bands and two connector - headphone and microphone.
I will try ..
 
Good day!
Developing the idea further.
And how to automatically switch the sound from the speakers of the laptop on the headphones when the headphones are plugged in.
And back - switch to laptop speakers when headphones are disconnected?
Seen a lot of information about this, but I would like to consider this question for this configuration.

That is, only these three NID, with as > 0.
sysctl dev.hdac.1.pindump=1 && dmesg

Code:
hdaa1: Dumping AFG pins:
hdaa1: nid  0x  as seq device  conn  jack  loc  color  misc
hdaa1: 20 90170110 1  0  Speaker  Fixed Analog  Internal  Unknown 1
hdaa1:  Caps:  OUT  EAPD  Sense: 0x00000000 (disconnected)
...
hdaa1: 27 90a70130 3  0  Mic  Fixed Analog  Internal  Unknown 1
hdaa1:  Caps: IN OUT HP EAPD VREF Sense: 0x00000000 (disconnected)
...
hdaa1: 33 04211020 2  0  Headphones  Jack  1/8  Right  Black  0
hdaa1:  Caps:  OUT HP EAPD  Sense: 0x00000000 (disconnected)

In General, for the future, I would like to examine the issue of the driver architecture, and to understand how that is formed.
 
switch the single jack from Headphones mode to Line-in mode
One is an analogue input and the other is an output. To change them around you need to physically switch electrical connections. Think two ends of an OpAmp. Software can only do this if there is a way to electrically insulate one from the other. This could theoretically be done by an actual switching circuit but the jack is a physical item, not a digital one.
 
Sometimes one pin can be two without any active switches. Low-impedance driver, 1000 ohm resistance, line-out-and-in pin, high-impedance input stage.

Juha
 
I will try this scheme, it complies with the CTIA 2012.
let's see what happens with immutable configurations from the point of view of the driver.
 

Attachments

  • 3.5_jack_4_pin_to_3.5_jack_earphone_and_3.5_jack_mic.jpg
    3.5_jack_4_pin_to_3.5_jack_earphone_and_3.5_jack_mic.jpg
    110.5 KB · Views: 528
Good day!
Developing the idea further.
And how to automatically switch the sound from the speakers of the laptop on the headphones when the headphones are plugged in.
And back - switch to laptop speakers when headphones are disconnected?

This was the subject of a prior Thread 54229
 
I will try this scheme, it complies with the CTIA 2012.
let's see what happens with immutable configurations from the point of view of the driver.
Complete nonsense. Does not work.
Did splitter 3.5 Jack pin 4 -> two 3.5 Jack to 3 pins one microphone and one headphone.
Headphones work.
The microphone does not wish to work.
It seems that physically the circuit is such that an external MIC cannot be used. I'll check with support ASUS.

I'm tired of all this pandemonium.
Bought an external sound card on the CM108 chip to work with the microphone.
 
One is an analogue input and the other is an output. To change them around you need to physically switch electrical connections. Think two ends of an OpAmp. Software can only do this if there is a way to electrically insulate one from the other. This could theoretically be done by an actual switching circuit but the jack is a physical item, not a digital one.

The manual page for snd_hda(4) indicates that pins can be configure as either "in" or "out"
EXAMPLES
Taking HP Compaq DX2300 with Realtek ALC888 HDA codec for example. This
system has two audio connectors on a front side, three audio connectors
on a rear side and one internal speaker. According to verbose driver
output and the codec datasheet, this codec has five stereo DACs and two
stereo ADCs, all of them are routable to any codec pin (external connec-
tor). All codec pins are reversible (could be configured either as input
or output).

Doing this is beyond my experience but in theory should be doable. If you are able to accomplish this, you would become the forums resident expert on sound configuration.
 
The manual page for snd_hda(4) indicates that pins can be configure as either "in" or "out"
Could this be digital? That can go both ways on one physical line, but I'm still sceptical about running analogue signals in "both directions".
 
Could this be digital? That can go both ways on one physical line, but I'm still sceptical about running analogue signals in "both directions".

Could the direction change occur at the level of the AnalogDigitalConverter?
 
The AnalogDigitalConverter is analog input to digital output. For analog signals it is an input. For the DigitalAnalogConverter it is opposite. The configuration should be as below.
Code:
                  ---------------------------------------------
                 |
                 |         / o----------------->---ADC
socket ------------------o                                        Sound circuit
                 |           o-----------------<----DAC
                 |    switch
                 |    configurable by software
                  -----------------------------------------------
Of course the socket is usually stereo.
 
I switch Headphones To mode in /boot/device.hints:
hint.hdac.1.cad0.nid33.config="as=1 seq=15"
This work, nice work. But pcm2 disappeared.
In such a situation it is hardly possible to use jack as a microphone.

cat /dev/sndstat
FreeBSD Audio Driver (64bit 2009061500/amd64)
Installed devices:
pcm0: <Intel Haswell (HDMI/DP 8ch)> on hdaa0 (1p:1v/0r:0v)
pcm1: <Realtek (0x0233) (Analog 2.0+HP/2.0)> on hdaa1 (1p:4v/2r:4v) default

The combination of (1p:4v/2r:4v) leaves a lot of questions.
Why 2r? Where the second recording source?
Even if splitter file audio through the microphone Jack, earphone Jack, his barely audible - i.e. the connection inside the device.
 
Back
Top