Skip to content

Commit 8fba8ac

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: cadence: add debugfs interface for PDI loopbacks
For debug, it's interesting to create a loopback stream for each link and use debugfs to set a source and target PDI. The target PDI would need to be an RX port and use the same register configurations as the source PDI. This capability allows e.g. for the headphone playback stream to be snooped on the headset capture stream, or alternatively for the addition of a dedicated loopback stream, in addition of regular capture for that link. This patch only adds the debugfs part, the port/PDI handling will be handled in the next patches. Signed-off-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Rander Wang <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 24f08b3 commit 8fba8ac

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

drivers/soundwire/cadence_master.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,40 @@ static int cdns_parity_error_injection(void *data, u64 value)
450450
DEFINE_DEBUGFS_ATTRIBUTE(cdns_parity_error_fops, NULL,
451451
cdns_parity_error_injection, "%llu\n");
452452

453+
static int cdns_set_pdi_loopback_source(void *data, u64 value)
454+
{
455+
struct sdw_cdns *cdns = data;
456+
unsigned int pdi_out_num = cdns->pcm.num_bd + cdns->pcm.num_out;
457+
458+
if (value > pdi_out_num)
459+
return -EINVAL;
460+
461+
/* Userspace changed the hardware state behind the kernel's back */
462+
add_taint(TAINT_USER, LOCKDEP_STILL_OK);
463+
464+
cdns->pdi_loopback_source = value;
465+
466+
return 0;
467+
}
468+
DEFINE_DEBUGFS_ATTRIBUTE(cdns_pdi_loopback_source_fops, NULL, cdns_set_pdi_loopback_source, "%llu\n");
469+
470+
static int cdns_set_pdi_loopback_target(void *data, u64 value)
471+
{
472+
struct sdw_cdns *cdns = data;
473+
unsigned int pdi_in_num = cdns->pcm.num_bd + cdns->pcm.num_in;
474+
475+
if (value > pdi_in_num)
476+
return -EINVAL;
477+
478+
/* Userspace changed the hardware state behind the kernel's back */
479+
add_taint(TAINT_USER, LOCKDEP_STILL_OK);
480+
481+
cdns->pdi_loopback_target = value;
482+
483+
return 0;
484+
}
485+
DEFINE_DEBUGFS_ATTRIBUTE(cdns_pdi_loopback_target_fops, NULL, cdns_set_pdi_loopback_target, "%llu\n");
486+
453487
/**
454488
* sdw_cdns_debugfs_init() - Cadence debugfs init
455489
* @cdns: Cadence instance
@@ -464,6 +498,16 @@ void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root)
464498

465499
debugfs_create_file("cdns-parity-error-injection", 0200, root, cdns,
466500
&cdns_parity_error_fops);
501+
502+
cdns->pdi_loopback_source = -1;
503+
cdns->pdi_loopback_target = -1;
504+
505+
debugfs_create_file("cdns-pdi-loopback-source", 0200, root, cdns,
506+
&cdns_pdi_loopback_source_fops);
507+
508+
debugfs_create_file("cdns-pdi-loopback-target", 0200, root, cdns,
509+
&cdns_pdi_loopback_target_fops);
510+
467511
}
468512
EXPORT_SYMBOL_GPL(sdw_cdns_debugfs_init);
469513

drivers/soundwire/cadence_master.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ struct sdw_cdns {
129129
struct sdw_cdns_streams pcm;
130130
struct sdw_cdns_streams pdm;
131131

132+
int pdi_loopback_source;
133+
int pdi_loopback_target;
134+
132135
void __iomem *registers;
133136

134137
bool link_up;

0 commit comments

Comments
 (0)