tools/sound/dapm-graph

Source file repositories/reference/linux-study-clean/tools/sound/dapm-graph

File Facts

System
Linux kernel
Corpus path
tools/sound/dapm-graph
Extension
[no extension]
Size
9359 bytes
Lines
330
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Generate a graph of the current DAPM state for an audio card
#
# Copyright 2024 Bootlin
# Author: Luca Ceresoli <luca.ceresol@bootlin.com>

set -eu

STYLE_COMPONENT_ON="color=dodgerblue;style=bold"
STYLE_COMPONENT_OFF="color=gray40;style=filled;fillcolor=gray90"
STYLE_NODE_ON="shape=box,style=bold,color=green4,fillcolor=white"
STYLE_NODE_OFF="shape=box,style=filled,color=gray30,fillcolor=gray95"

# Print usage and exit
#
# $1 = exit return value
# $2 = error string (required if $1 != 0)
usage()
{
    if [  "${1}" -ne 0 ]; then
	echo "${2}" >&2
    fi

    echo "
Generate a graph of the current DAPM state for an audio card.

The DAPM state can be obtained via debugfs for a card on the local host or
a remote target, or from a local copy of the debugfs tree for the card.

Usage:
    $(basename $0) [options] -c CARD                  - Local sound card
    $(basename $0) [options] -c CARD -r REMOTE_TARGET - Card on remote system
    $(basename $0) [options] -d STATE_DIR             - Local directory

Options:
    -c CARD             Sound card to get DAPM state of
    -r REMOTE_TARGET    Get DAPM state from REMOTE_TARGET via SSH and SCP
                        instead of using a local sound card
    -d STATE_DIR        Get DAPM state from a local copy of a debugfs tree
    -o OUT_FILE         Output file (default: dapm.dot)
    -D                  Show verbose debugging info
    -h                  Print this help and exit

The output format is implied by the extension of OUT_FILE:

 * Use the .dot extension to generate a text graph representation in
   graphviz dot syntax.
 * Any other extension is assumed to be a format supported by graphviz for
   rendering, e.g. 'png', 'svg', and will produce both the .dot file and a
   picture from it. This requires the 'dot' program from the graphviz
   package.
"

    exit ${1}
}

# Connect to a remote target via SSH, collect all DAPM files from debufs
# into a tarball and get the tarball via SCP into $3/dapm.tar
#
# $1 = target as used by ssh and scp, e.g. "root@192.168.1.1"
# $2 = sound card name
# $3 = temp dir path (present on the host, created on the target)
# $4 = local directory to extract the tarball into
#
# Requires an ssh+scp server, find and tar+gz on the target
#
# Note: the tarball is needed because plain 'scp -r' from debugfs would
# copy only empty files

Annotation

Implementation Notes