All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Henningsson <david.henningsson@canonical.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: hda-jack-sense-test (was: Sound issues with ALC269VB-based hardware)
Date: Tue, 17 Jul 2012 17:20:27 +0200	[thread overview]
Message-ID: <500582BB.4090001@canonical.com> (raw)
In-Reply-To: <s5htxx6jum7.wl%tiwai@suse.de>

[-- Attachment #1: Type: text/plain, Size: 1252 bytes --]

On 07/17/2012 05:05 PM, Takashi Iwai wrote:
> Usually the device has a jack detection mechanism, and you can check
> it via hda-verb or whatever.  Plug your headphone to the headphone
> jack, and check any of the pin reacts to GET_PIN_SENSE verb (call it
> after setting SET_PIN_SENSE verb).  For example,
>
> 	% hda-verb /dev/snd/hwC0D0 0x21 SET_PIN_SENSE 1

How many codecs really require SET_PIN_SENSE? I have never had a problem 
with omitting the SET_PIN_SENSE command.

> 	% hda-verb /dev/snd/hwC0D0 0x21 GET_PIN_SENSE 0
>
> Check the value returned from GET_PIN_SENSE.  If bit 31 (0x80000000)
> is set, this is likely the pin of the interest.
>
> Check this for all pins, i.e. between 0x12 and 0x21.  Some nodes are
> no pins, but it doesn't matter much.

Btw, I made convenience script for doing this a year ago. Here it is again.

To install, you put it right next to the hda-analyzer py files, as it 
makes use of hda_codec.py from hda-analyzer, then run "sudo 
hda-jack-sense-test.py -a" (see -h for switches to set codec and card 
indices).

Let me know if you're interested in having this small script in ALSA 
upstream, and if so, what I should do to get it in there.

-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic



[-- Attachment #2: hda-jack-sense-test.py --]
[-- Type: text/x-python, Size: 1968 bytes --]

#!/usr/bin/env python
#
# Written by David Henningsson, Copyright 2011 Canonical Ltd. 
# Licensed under GPLv2+

# the hda_codec.py file comes from Jaroslav Kysela's hda_analyzer program.
from hda_codec import *


def parseoptions():
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("-c", "--card", dest="cardindex", default=0, metavar="CARD",
        help="card index (as can be seen in /proc/asound/cards)")
    parser.add_option("-d", "--codec", dest="codecindex", default=0, metavar="CODEC",
        help="codec device index (as can be seen in /proc/asound/cardX/codecY)")
    parser.add_option("-a", "--allpins", dest="tryallpins", default=False,
        action="store_true",
        help="also check pins which (probably) are not physical jacks")
    (options, args) = parser.parse_args()
    return int(options.cardindex), int(options.codecindex), options.tryallpins
    
def should_check_presence(node, tryallpins):
    if WIDGET_TYPE_IDS[node.wtype] != 'PIN':
        return False
    if tryallpins:
        return True
    conn_type = (node.defcfg_pincaps >> 30) & 0x03
    if conn_type != 0: # Not a Jack
        return False
    if node.defcfg_pincaps & (1 << 8): # Jack has NO_PRESENCE set
        return False     
    return True

def get_simplecaps(node):
    conn_type = (node.defcfg_pincaps >> 30) & 0x03
    if conn_type == 1: # N/A
        return 'Not connected'
    if conn_type == 0: # Jack
        return "%s %s" % (node.jack_color_name, node.jack_type_name)
    return "Internal %s" % node.jack_type_name

cardindex, codecindex, tryallpins = parseoptions()
codec = HDACodec(cardindex, codecindex)
codec.analyze()
for nid in codec.nodes:
    node = codec.get_node(nid)
    if not should_check_presence(node, tryallpins):
        continue
    present = codec.rw(nid, VERBS['GET_PIN_SENSE'], 0) & 0x80000000
    print "Pin 0x%.2x (%s): present = %s" % (nid, get_simplecaps(node), "Yes" if present else "No")


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2012-07-17 15:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-17 13:11 Sound issues with ALC269VB-based hardware Anisse Astier
2012-07-17 15:05 ` Takashi Iwai
2012-07-17 15:20   ` David Henningsson [this message]
2012-07-17 15:23     ` hda-jack-sense-test (was: Sound issues with ALC269VB-based hardware) Takashi Iwai
2012-07-17 15:25   ` Sound issues with ALC269VB-based hardware Takashi Iwai
2012-07-17 15:40     ` David Henningsson
2012-07-17 15:53       ` Takashi Iwai
2012-07-17 15:50     ` Anisse Astier
2012-07-17 15:53       ` Takashi Iwai
2012-08-30 16:57       ` Anisse Astier
2013-06-03  9:53 ` [PATCH] ALSA: hda - add mic fixup for ALC269VB on Ordissimo EVE2 Anisse Astier
2013-06-05 10:26   ` Takashi Iwai
2013-06-05 10:32     ` Anisse Astier
2013-06-05 15:36     ` Anisse Astier
2013-06-06  9:49       ` Takashi Iwai
2013-06-06 16:14         ` Anisse Astier
2013-06-06 16:19           ` Anisse Astier
2013-06-06 16:23           ` Takashi Iwai

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=500582BB.4090001@canonical.com \
    --to=david.henningsson@canonical.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.