From: Kristo <kristo.ilmari@gmail.com>
To: 9front <9front@9front.org>
Subject: [9front] [PATCH] audiohda: one-off jack detection
Date: Wed, 7 Dec 2022 18:10:48 +0200 [thread overview]
Message-ID: <CAAJ3RaN1xww8+5sdR8owmks5LquG+-WKdLD5NGfqUEgRzzTG5A@mail.gmail.com> (raw)
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;
next reply other threads:[~2022-12-07 16:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-07 16:10 Kristo [this message]
2022-12-07 16:36 ` Sigrid Solveig Haflínudóttir
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAAJ3RaN1xww8+5sdR8owmks5LquG+-WKdLD5NGfqUEgRzzTG5A@mail.gmail.com \
--to=kristo.ilmari@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).