Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions topology/m4/mixercontrol.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,79 @@ define(`CONTROLMIXER_OPS',
` put STR($4)'
` }')

dnl KCONTROL_MONO_CHANNEL(reg)
define(`KCONTROL_MONO_CHANNEL',
`KCONTROL_CHANNEL(MONO, $1, 0)')

dnl KCONTROL_STEREO_CHANNELS(reg)
define(`KCONTROL_STEREO_CHANNELS',
`KCONTROL_CHANNEL(FL, $1, 0),'
`KCONTROL_CHANNEL(FR, $1, 1)')

dnl KCONTROL_THREE_CHANNELS(reg)
define(`KCONTROL_THREE_CHANNELS',
`KCONTROL_CHANNEL(FL, $1, 0),'
`KCONTROL_CHANNEL(FR, $1, 1),'
`KCONTROL_CHANNEL(FC, $1, 2)')

dnl KCONTROL_FOUR_CHANNELS(reg)
define(`KCONTROL_FOUR_CHANNELS',
`KCONTROL_CHANNEL(FL, $1, 0),'
`KCONTROL_CHANNEL(FR, $1, 1),'
`KCONTROL_CHANNEL(RL, $1, 2),'
`KCONTROL_CHANNEL(RR, $1, 3)')

dnl KCONTROL_FIVE_CHANNELS(reg)
define(`KCONTROL_FIVE_CHANNELS',
`KCONTROL_CHANNEL(FL, $1, 0),'
`KCONTROL_CHANNEL(FR, $1, 1),'
`KCONTROL_CHANNEL(RL, $1, 2),'
`KCONTROL_CHANNEL(RR, $1, 3),'
`KCONTROL_CHANNEL(FC, $1, 4)')

dnl KCONTROL_SIX_CHANNELS(reg)
define(`KCONTROL_SIX_CHANNELS',
`KCONTROL_CHANNEL(FL, $1, 0),'
`KCONTROL_CHANNEL(FR, $1, 1),'
`KCONTROL_CHANNEL(RL, $1, 2),'
`KCONTROL_CHANNEL(RR, $1, 3),'
`KCONTROL_CHANNEL(FC, $1, 4),'
`KCONTROL_CHANNEL(LFE, $1, 5)')

KCONTROL_SEVEN_CHANNELS(reg)
define(`KCONTROL_SEVEN_CHANNELS',
`KCONTROL_CHANNEL(FL, $1, 0),'
`KCONTROL_CHANNEL(FR, $1, 1),'
`KCONTROL_CHANNEL(RL, $1, 2),'
`KCONTROL_CHANNEL(RR, $1, 3),'
`KCONTROL_CHANNEL(FC, $1, 4),'
`KCONTROL_CHANNEL(SL, $1, 5),'
`KCONTROL_CHANNEL(SR, $1, 6)')

dnl KCONTROL_EIGHT_CHANNELS(reg)
define(`KCONTROL_EIGHT_CHANNELS',
`KCONTROL_CHANNEL(FL, $1, 0),'
`KCONTROL_CHANNEL(FR, $1, 1),'
`KCONTROL_CHANNEL(RL, $1, 2),'
`KCONTROL_CHANNEL(RR, $1, 3),'
`KCONTROL_CHANNEL(FC, $1, 4),'
`KCONTROL_CHANNEL(LFE, $1, 5),'
`KCONTROL_CHANNEL(SL, $1, 6),'
`KCONTROL_CHANNEL(SR, $1, 7)')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit controversial. It's not because there are 8 channels that they will follow the speaker arrangement that you describe here. It's probably a better idea to keep the names less precise, e.g. vol_ch0..vo_chl7, to avoid confusions.
Take the example of capture on the GP-MRB, the channels are FM, AUX and mic, nothing to do with 7.1 speaker notation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the topology definition in alsa lib, else it would be built failed

  • The channel map reg is the register offset for the control, shift is the
  • bit shift within the register for the channel and the section name is the
  • channel name and can be one of the following :-
    • mono # mono stream
    • fl # front left
    • fr # front right
    • rl # rear left
    • rr # rear right
    • fc # front center
    • lfe # LFE
    • sl # side left
    • sr # side right
    • rc # rear center


dnl KCONTROL_CHANNEL_ARRAY(size, reg)
define(`KCONTROL_CHANNEL_ARRAY',
`ifelse(
$1, `1', `KCONTROL_MONO_CHANNEL($2)',
$1, `2', `KCONTROL_STEREO_CHANNELS($2)',
$1, `3', `KCONTROL_THREE_CHANNELS($2)',
$1, `4', `KCONTROL_FOUR_CHANNELS($2)',
$1, `5', `KCONTROL_FIVE_CHANNELS($2)',
$1, `6', `KCONTROL_SIX_CHANNELS($2)',
$1, `7', `KCONTROL_SEVEN_CHANNELS($2)',
$1, `8', `KCONTROL_EIGHT_CHANNELS($2)',
`KCONTROL_STEREO_CHANNELS($2)')')

dnl C_CONTROLMIXER(name, index, ops, max, invert, tlv, KCONTROL_CHANNELS)
define(`C_CONTROLMIXER',
`SectionControlMixer."$1 PIPELINE_ID" {'
Expand Down
70 changes: 70 additions & 0 deletions topology/sof/pipe-multi-channels-volume-capture.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Passthrough with multi-channels volume Pipeline and PCM
#
# Pipeline Endpoints for connection are :-
#
# host PCM_C <-- B0 <-- Volume 0 <-- B1 <-- source DAI0

# Include topology builder
include(`utils.m4')
include(`buffer.m4')
include(`pcm.m4')
include(`pga.m4')
include(`dai.m4')
include(`mixercontrol.m4')
include(`pipeline.m4')

#
# Controls
#
# Volume Mixer control with max value of 32
C_CONTROLMIXER(Master Capture Volume, PIPELINE_ID,
CONTROLMIXER_OPS(volsw, volsw binds the mixer control to volume get/put handlers, 1, 1),
CONTROLMIXER_MAX(, 32),
false,
CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
Channel register and shift for Front Left/Right,
LIST(` ', KCONTROL_CHANNEL_ARRAY(PIPELINE_CHANNELS, 1)))

#
# Components and Buffers
#

# Host "Passthrough Capture" PCM
# with 0 sink and 2 source periods
W_PCM_CAPTURE(PCM_ID, Passthrough Capture, 0, 2, 2)

# "Volume" has 2 source and 2 sink periods
W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Capture Volume PIPELINE_ID"))

# Capture Buffers
W_BUFFER(0, COMP_BUFFER_SIZE(2,
COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES),
PLATFORM_HOST_MEM_CAP)
W_BUFFER(1, COMP_BUFFER_SIZE(2,
COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES),
PLATFORM_DAI_MEM_CAP)

#
# Pipeline Graph
#
# host PCM_P <-- B0 <-- Volume 0 <-- B1 <-- sink DAI0

P_GRAPH(pipe-pass-vol-capture-PIPELINE_ID, PIPELINE_ID,
LIST(` ',
`dapm(Passthrough Capture PCM_ID, N_PCMC(PCM_ID))',
`dapm(N_PCMC(PCM_ID), N_BUFFER(0))',
`dapm(N_BUFFER(0), N_PGA(0))',
`dapm(N_PGA(0), N_BUFFER(1))'))

#
# Pipeline Source and Sinks
#
indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(1))
indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID)

#
# PCM Configuration
#

PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536)

71 changes: 71 additions & 0 deletions topology/sof/pipe-multi-channels-volume-playback.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Low Latency Passthrough with multi-channels volume Pipeline and PCM
#
# Pipeline Endpoints for connection are :-
#
# host PCM_P --> B0 --> Volume 0 --> B1 --> sink DAI0

# Include topology builder
include(`utils.m4')
include(`buffer.m4')
include(`pcm.m4')
include(`pga.m4')
include(`dai.m4')
include(`mixercontrol.m4')
include(`pipeline.m4')

#
# Controls
#
# Volume Mixer control with max value of 32
C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID,
CONTROLMIXER_OPS(volsw, volsw binds the mixer control to volume get/put handlers, 1, 1),
CONTROLMIXER_MAX(, 32),
false,
CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3),
Channel register and shift for Front Left/Right,
LIST(` ', KCONTROL_CHANNEL_ARRAY(PIPELINE_CHANNELS, 1)))

#
# Components and Buffers
#

# Host "Passthrough Playback" PCM
# with 2 sink and 0 source periods
W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 2, 0, 2)

# "Volume" has 2 source and 2 sink periods
W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume PIPELINE_ID"))

# Playback Buffers
W_BUFFER(0, COMP_BUFFER_SIZE(2,
COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES),
PLATFORM_HOST_MEM_CAP)
W_BUFFER(1, COMP_BUFFER_SIZE(2,
COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES),
PLATFORM_DAI_MEM_CAP)

#
# Pipeline Graph
#
# host PCM_P --> B0 --> Volume 0 --> B1 --> sink DAI0

P_GRAPH(pipe-pass-vol-playback-PIPELINE_ID, PIPELINE_ID,
LIST(` ',
`dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)',
`dapm(N_BUFFER(0), N_PCMP(PCM_ID))',
`dapm(N_PGA(0), N_BUFFER(0))',
`dapm(N_BUFFER(1), N_PGA(0))'))

#
# Pipeline Source and Sinks
#
indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(1))
indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_ID)


#
# PCM Configuration

#
PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536)