mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-14 01:34:43 +08:00
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
|
/*
|
||
|
* simple-card-core.c
|
||
|
*
|
||
|
* Copyright (c) 2016 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License version 2 as
|
||
|
* published by the Free Software Foundation.
|
||
|
*/
|
||
|
#include <linux/of.h>
|
||
|
#include <sound/simple_card_utils.h>
|
||
|
|
||
|
int asoc_simple_card_parse_daifmt(struct device *dev,
|
||
|
struct device_node *node,
|
||
|
struct device_node *codec,
|
||
|
char *prefix,
|
||
|
unsigned int *retfmt)
|
||
|
{
|
||
|
struct device_node *bitclkmaster = NULL;
|
||
|
struct device_node *framemaster = NULL;
|
||
|
int prefix_len = prefix ? strlen(prefix) : 0;
|
||
|
unsigned int daifmt;
|
||
|
|
||
|
daifmt = snd_soc_of_parse_daifmt(node, prefix,
|
||
|
&bitclkmaster, &framemaster);
|
||
|
daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
|
||
|
|
||
|
if (prefix_len && !bitclkmaster && !framemaster) {
|
||
|
/*
|
||
|
* No dai-link level and master setting was not found from
|
||
|
* sound node level, revert back to legacy DT parsing and
|
||
|
* take the settings from codec node.
|
||
|
*/
|
||
|
dev_dbg(dev, "Revert to legacy daifmt parsing\n");
|
||
|
|
||
|
daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) |
|
||
|
(daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
|
||
|
} else {
|
||
|
if (codec == bitclkmaster)
|
||
|
daifmt |= (codec == framemaster) ?
|
||
|
SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS;
|
||
|
else
|
||
|
daifmt |= (codec == framemaster) ?
|
||
|
SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS;
|
||
|
}
|
||
|
|
||
|
of_node_put(bitclkmaster);
|
||
|
of_node_put(framemaster);
|
||
|
|
||
|
*retfmt = daifmt;
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt);
|