Created
May 17, 2016 18:06
-
-
Save clivem/ff1ac5a793524bdd066aea7f906e1bf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/sound/soc/generic/hw-params-rules.c 2016-05-17 13:51:52.000000000 +0100 | |
+++ b/sound/soc/generic/hw-params-rules.c 2016-05-17 13:53:00.704744902 +0100 | |
@@ -40,7 +40,7 @@ | |
static int asoc_generic_hw_params_read_u32array( | |
struct device *dev, struct device_node *node, void **data) | |
{ | |
- int i, size, ret; | |
+ int size, ret; | |
struct snd_soc_size_u32array *array; | |
size = of_property_count_elems_of_size(node, "values", sizeof(u32)); | |
@@ -59,11 +59,9 @@ | |
array->size = size; | |
- for (i = 0; i < size; i++) { | |
- ret = of_property_read_u32(node, "values", &array->data[i]); | |
- if (ret) | |
- return ret; | |
- } | |
+ ret = of_property_read_u32_array(node, "values", &array->data[0], size); | |
+ if (ret) | |
+ return ret; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/sound/soc/generic/hw-params-rules.c 2016-05-17 15:07:27.977627158 +0 | |
100 | |
+++ b/sound/soc/generic/hw-params-rules.c 2016-05-17 17:20:53.198559366 +0100 | |
@@ -27,7 +27,9 @@ | |
struct snd_soc_hw_param_rule { | |
struct list_head list; | |
- const char *name; | |
+ const char *of_full_name; | |
+ const char *rule_name; | |
+ u32 priority; | |
struct list_head matches; | |
struct list_head actions; | |
}; | |
@@ -198,7 +200,8 @@ | |
struct snd_soc_hw_params_actionmatch *am; | |
int ret; | |
- dev_dbg(dev, "Trying to apply rule: %s\n", rule->name); | |
+ dev_dbg(dev, "Trying to apply rule: (%s) %s\n", rule->rule_name, | |
+ rule->of_full_name); | |
/* apply match rules */ | |
list_for_each_entry(am, &rule->matches, list) { | |
@@ -317,9 +320,18 @@ | |
if (!rule) | |
return -ENOMEM; | |
- rule->name = of_node_full_name(node); | |
+ rule->of_full_name = of_node_full_name(node); | |
+ | |
+ if (of_property_read_string(node, "rule-name", &rule->rule_name)) { | |
+ rule->rule_name = "undefined"; | |
+ } | |
+ | |
+ if (of_property_read_u32(node, "priority", &rule->priority)) { | |
+ rule->priority = 0; | |
+ } | |
- dev_dbg(dev, "\tadding Rule: %s\n", rule->name); | |
+ dev_dbg(dev, "\tadding Rule: (%s) %s\n", rule->rule_name, | |
+ rule->of_full_name); | |
/* parse all matches sub-nodes */ | |
ret = asoc_generic_hw_params_actionmatches_parse_of( | |
@@ -339,16 +351,17 @@ | |
return 0; | |
} | |
-static int asoc_generic_hw_params_rules_cmp_name( | |
+static int asoc_generic_hw_params_rules_cmp_priority( | |
void *data, struct list_head *a, struct list_head *b) | |
{ | |
struct snd_soc_hw_param_rule *rulea; | |
struct snd_soc_hw_param_rule *ruleb; | |
rulea = container_of(a, typeof(*rulea), list); | |
- ruleb = container_of(a, typeof(*rulea), list); | |
+ ruleb = container_of(b, typeof(*ruleb), list); | |
- return strcmp(rulea->name, ruleb->name); | |
+ return rulea->priority > ruleb->priority ? -1 | |
+ : (rulea->priority < ruleb->priority ? 1 : 0); | |
} | |
int asoc_generic_hw_params_rules_parse_of( | |
@@ -375,7 +388,7 @@ | |
} | |
/* and sort by name */ | |
- list_sort(NULL, list_head, asoc_generic_hw_params_rules_cmp_name); | |
+ list_sort(NULL, list_head, asoc_generic_hw_params_rules_cmp_priority); | |
/* iterate the sub-nodes */ | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Definitions for a generic board or HAT using ESS Sabre ES9023 DAC | |
/dts-v1/; | |
/plugin/; | |
/ { | |
compatible = "brcm,bcm2708"; | |
fragment@0 { | |
target = <&i2s>; | |
i2s_overlay: __overlay__ { | |
status = "okay"; | |
}; | |
}; | |
fragment@1 { | |
target-path = "/"; | |
__overlay__ { | |
es9023_codec: es9023-codec { | |
#sound-dai-cells = <0>; | |
compatible = "ess,es9023"; | |
status = "okay"; | |
}; | |
}; | |
}; | |
fragment@2 { | |
target = <&sound>; | |
sound_overlay: __overlay__ { | |
compatible = "simple-audio-card"; | |
simple-audio-card,format = "i2s"; | |
simple-audio-card,name = "es9023"; | |
status = "okay"; | |
simple-audio-card,cpu { | |
sound-dai = <&i2s>; | |
}; | |
simple-audio-card,codec { | |
sound-dai = <&es9023_codec>; | |
}; | |
// 2ch, default. | |
// set blck_ratio=0 (Let cpu driver decide bclk_ratio.) | |
hw-params-rule@0 { | |
rule-name = "DEFAULT_2CH_BCLK0"; | |
priority = <0>; | |
match@0 { | |
method = "asoc_generic_hw_params_match_channels"; | |
values = <2>; | |
}; | |
action@0 { | |
method = "asoc_generic_hw_params_set_fixed_bclk_size"; | |
value = <0>; | |
}; | |
}; | |
// 2ch, 32bit @ 8/16/32/48/64/96kHz. | |
// set bclk_ratio=100 | |
hw-params-rule@1 { | |
rule-name = "x8kHz_32BIT_2CH_BCLK100"; | |
priority = <99>; | |
match@0 { | |
method = "asoc_generic_hw_params_match_sample_bits"; | |
values = <32>; | |
}; | |
match@1 { | |
method = "asoc_generic_hw_params_match_rate"; | |
values = <8000>, <16000>, <32000>, <48000>, <64000>, <96000>; | |
}; | |
match@2 { | |
method = "asoc_generic_hw_params_match_channels"; | |
values = <2>; | |
}; | |
action@0 { | |
method = "asoc_generic_hw_params_set_fixed_bclk_size"; | |
value = <100>; | |
}; | |
}; | |
// 2ch, 16bit @ 8/16/32/48/64/96kHz. | |
// set bclk_ratio=50 | |
hw-params-rule@2 { | |
rule-name = "x8kHz_16BIT_2CH_BCLK50"; | |
priority = <99>; | |
match@0 { | |
method = "asoc_generic_hw_params_match_sample_bits"; | |
values = <16>; | |
}; | |
match@1 { | |
method = "asoc_generic_hw_params_match_rate"; | |
values = <8000>, <16000>, <32000>, <48000>, <64000>, <96000>; | |
}; | |
match@2 { | |
method = "asoc_generic_hw_params_match_channels"; | |
values = <2>; | |
}; | |
action@0 { | |
method = "asoc_generic_hw_params_set_fixed_bclk_size"; | |
value = <50>; | |
}; | |
}; | |
// set bclk_ratio=50 | |
hw-params-rule@2 { | |
rule-name = "x8kHz_16BIT_2CH_BCLK50"; | |
priority = <99>; | |
match@0 { | |
method = "asoc_generic_hw_params_match_sample_bits"; | |
values = <16>; | |
}; | |
match@1 { | |
method = "asoc_generic_hw_params_match_rate"; | |
values = <8000>, <16000>, <32000>, <48000>, <64000>, <96000>; | |
}; | |
match@2 { | |
method = "asoc_generic_hw_params_match_channels"; | |
values = <2>; | |
}; | |
action@0 { | |
method = "asoc_generic_hw_params_set_fixed_bclk_size"; | |
value = <50>; | |
}; | |
}; | |
}; | |
}; | |
__overrides__ { | |
384k = <&es9023_codec>,"es9023,384k?"; | |
bclk_ratio_integer_div = <&i2s_overlay>,"brcm,bclk_ratio_integer_div?"; | |
card-name = <&sound_overlay>,"simple-audio-card,name"; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment