* [9front] [PATCH] audiohda: one-off jack detection
@ 2022-12-07 16:10 Kristo
2022-12-07 16:36 ` Sigrid Solveig Haflínudóttir
0 siblings, 1 reply; 2+ messages in thread
From: Kristo @ 2022-12-07 16:10 UTC (permalink / raw)
To: 9front
When choosing input and output pins at start up, we can use the pin sense
control to find connected jacks and prioritize them. Of course it would
be preferable to implement proper presence detection handling with the
unsolicited responses.
diff 744053268d196e8c282d20243600fb33d4df0028 uncommitted
--- a/sys/src/9/pc/audiohda.c
+++ b/sys/src/9/pc/audiohda.c
@@ -1023,6 +1023,16 @@
}
static int
+present(Widget *w)
+{
+ /* validate presence detection result */
+ if(((w->pin >> 8) & 1) == 1 || (w->pincap & Pdetect) == 0)
+ return 0;
+
+ return cmd(w->id, Getpinsense, 0) >> 31;
+}
+
+static int
scoreout(Widget *w)
{
int score;
@@ -1035,6 +1045,8 @@
score = 0;
r = w->pin;
+ if(present(w))
+ score |= 64;
if(((r >> 30) & 0x3) >= 2) /* fix or fix+jack */
score |= 32;
if(((r >> 12) & 0xf) == 4) /* green */
@@ -1063,6 +1075,8 @@
score = 0;
r = w->pin;
+ if(present(w))
+ score |= 8;
if(((r >> 30) & 0x3) >= 2) /* fix or fix+jack */
score |= 4;
return score;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [9front] [PATCH] audiohda: one-off jack detection
2022-12-07 16:10 [9front] [PATCH] audiohda: one-off jack detection Kristo
@ 2022-12-07 16:36 ` Sigrid Solveig Haflínudóttir
0 siblings, 0 replies; 2+ messages in thread
From: Sigrid Solveig Haflínudóttir @ 2022-12-07 16:36 UTC (permalink / raw)
To: kristo.ilmari, 9front
https://git.sr.ht/~ft/jacksense
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-07 16:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 16:10 [9front] [PATCH] audiohda: one-off jack detection Kristo
2022-12-07 16:36 ` Sigrid Solveig Haflínudóttir
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).