Skip to content

Commit 3d44dea

Browse files
jajanuszlbetlej
authored andcommitted
Revert "kpb: refactor some of KPBs macros"
This reverts commit 0eabf51.
1 parent a5a6e70 commit 3d44dea

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

src/audio/kpb.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static struct comp_dev *kpb_new(struct sof_ipc_comp *comp)
136136
return NULL;
137137
}
138138

139-
if (kpb->config.channels > KPB_MAX_SUPPORTED_CHANNELS) {
139+
if (kpb->config.no_channels > KPB_MAX_SUPPORTED_CHANNELS) {
140140
trace_kpb_error_with_ids(dev, "kpb_new() error: "
141141
"no of channels exceeded the limit");
142142
return NULL;
@@ -895,7 +895,7 @@ static void kpb_init_draining(struct comp_dev *dev, struct kpb_client *cli)
895895
struct comp_data *kpb = comp_get_drvdata(dev);
896896
bool is_sink_ready = (kpb->host_sink->sink->state == COMP_STATE_ACTIVE);
897897
size_t sample_width = kpb->config.sampling_width;
898-
size_t history_depth = cli->history_depth * kpb->config.channels *
898+
size_t history_depth = cli->history_depth * kpb->config.no_channels *
899899
(kpb->config.sampling_freq / 1000) *
900900
(KPB_SAMPLE_CONTAINER_SIZE(sample_width) / 8);
901901
struct hb *buff = kpb->history_buffer;
@@ -907,9 +907,9 @@ static void kpb_init_draining(struct comp_dev *dev, struct kpb_client *cli)
907907
size_t host_period_size = kpb->host_period_size;
908908
size_t host_buffer_size = kpb->host_buffer_size;
909909
size_t ticks_per_ms = clock_ms_to_ticks(PLATFORM_DEFAULT_CLOCK, 1);
910-
size_t bytes_per_ms = KPB_SAMPLES_PER_MS *
910+
size_t bytes_per_ms = KPB_SAMPLING_WIDTH *
911911
(KPB_SAMPLE_CONTAINER_SIZE(sample_width) / 8) *
912-
kpb->config.channels;
912+
kpb->config.no_channels;
913913
size_t period_bytes_limit = 0;
914914

915915
trace_kpb_with_ids(dev, "kpb_init_draining(): requested draining "
@@ -1188,7 +1188,7 @@ static void kpb_drain_samples(void *source, struct comp_buffer *sink,
11881188
size_t frames = KPB_BYTES_TO_FRAMES(size, sample_width);
11891189

11901190
for (i = 0; i < frames; i++) {
1191-
for (channel = 0; channel < KPB_NUM_OF_CHANNELS; channel++) {
1191+
for (channel = 0; channel < KPB_NR_OF_CHANNELS; channel++) {
11921192
switch (sample_width) {
11931193
#if CONFIG_FORMAT_S16LE
11941194
case 16:
@@ -1235,7 +1235,7 @@ static void kpb_buffer_samples(struct comp_buffer *source, uint32_t start,
12351235
size_t frames = KPB_BYTES_TO_FRAMES(size, sample_width);
12361236

12371237
for (i = 0; i < frames; i++) {
1238-
for (channel = 0; channel < KPB_NUM_OF_CHANNELS; channel++) {
1238+
for (channel = 0; channel < KPB_NR_OF_CHANNELS; channel++) {
12391239
switch (sample_width) {
12401240
case 16:
12411241
src = buffer_read_frag_s16(source, j);
@@ -1332,7 +1332,7 @@ static void kpb_copy_samples(struct comp_buffer *sink,
13321332
size_t frames = KPB_BYTES_TO_FRAMES(size, sample_width);
13331333

13341334
for (i = 0; i < frames; i++) {
1335-
for (channel = 0; channel < KPB_NUM_OF_CHANNELS; channel++) {
1335+
for (channel = 0; channel < KPB_NR_OF_CHANNELS; channel++) {
13361336
switch (sample_width) {
13371337
#if CONFIG_FORMAT_S16LE
13381338
case 16:

src/include/sof/audio/kpb.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,21 @@ struct comp_buffer;
3333

3434
/* KPB internal defines */
3535
#define KPB_MAX_BUFF_TIME 2100 /**< time of buffering in miliseconds */
36-
#define KPB_MAX_SUPPORTED_CHANNELS 2 /**< number of supported channels */
37-
/**< number of samples taken each milisecond */
38-
#define KPB_SAMPLES_PER_MS (KPB_SAMPLNG_FREQUENCY / 1000)
39-
#define KPB_SAMPLNG_FREQUENCY 16000 /**< supported sampling frequency in Hz */
40-
#define KPB_NUM_OF_CHANNELS 2
36+
#define KPB_MAX_SUPPORTED_CHANNELS 2
37+
#define KPB_SAMPLING_WIDTH 16 /**< number of bits */
38+
#define KPB_SAMPLNG_FREQUENCY 16000 /* max sampling frequency in Hz */
39+
#define KPB_NR_OF_CHANNELS 2
4140
#define KPB_SAMPLE_CONTAINER_SIZE(sw) ((sw == 16) ? 16 : 32)
4241
#define KPB_MAX_BUFFER_SIZE(sw) ((KPB_SAMPLNG_FREQUENCY / 1000) * \
4342
(KPB_SAMPLE_CONTAINER_SIZE(sw) / 8) * KPB_MAX_BUFF_TIME * \
44-
KPB_NUM_OF_CHANNELS)
43+
KPB_NR_OF_CHANNELS)
4544
#define KPB_MAX_NO_OF_CLIENTS 2
4645
#define KPB_NO_OF_HISTORY_BUFFERS 2 /**< no of internal buffers */
4746
#define KPB_ALLOCATION_STEP 0x100
4847
#define KPB_NO_OF_MEM_POOLS 3
4948
#define KPB_BYTES_TO_FRAMES(bytes, sample_width) \
5049
(bytes / ((KPB_SAMPLE_CONTAINER_SIZE(sample_width) / 8) * \
51-
KPB_NUM_OF_CHANNELS))
50+
KPB_NR_OF_CHANNELS))
5251

5352
enum kpb_state {
5453
KPB_STATE_DISABLED = 0,

src/include/user/kpb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
struct sof_kpb_config {
1515
uint32_t size; /**< kpb size in bytes */
1616
uint32_t caps; /**< SOF_MEM_CAPS_ */
17-
uint32_t channels; /**< number of channels */
17+
uint32_t no_channels; /**< no of channels */
1818
uint32_t history_depth; /**< time of buffering in milliseconds */
1919
uint32_t sampling_freq; /**< frequency in hertz */
2020
uint32_t sampling_width; /**< number of bits */

test/cmocka/src/audio/kpb/kpb_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int buffering_test_setup(void **state)
113113
.size = sizeof(struct sof_kpb_config),
114114
.no_channels = 2,
115115
.sampling_freq = KPB_SAMPLNG_FREQUENCY,
116-
.sampling_width = KPB_SAMPLE_CONTAINER_SIZE(16),
116+
.sampling_width = KPB_SAMPLING_WIDTH,
117117
};
118118

119119
/* Register KPB component to use its internal functions */

0 commit comments

Comments
 (0)