Skip to content
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
20 changes: 10 additions & 10 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ static int asrc_params(struct comp_dev *dev,
*/
cd->source_frames_max = cd->source_frames + 10;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does it mean 'Zephyr compatibility' ? Is Zephyr using Z_MAX naming instead of MAX?

cd->sink_frames_max = cd->sink_frames + 10;
cd->frames = MAX(cd->source_frames_max, cd->sink_frames_max);
cd->frames = Z_MAX(cd->source_frames_max, cd->sink_frames_max);

comp_info(dev, "asrc_params(), source_rate=%u, sink_rate=%u, source_frames_max=%d, sink_frames_max=%d",
cd->source_rate, cd->sink_rate,
Expand Down Expand Up @@ -785,8 +785,8 @@ static int asrc_control_loop(struct comp_dev *dev, struct comp_data *cd)
/* Track skew variation, it helps to analyze possible problems
* with slave DAI frame clock stability.
*/
cd->skew_min = MIN(cd->skew, cd->skew_min);
cd->skew_max = MAX(cd->skew, cd->skew_max);
cd->skew_min = Z_MIN(cd->skew, cd->skew_min);
cd->skew_max = Z_MAX(cd->skew, cd->skew_max);
comp_cl_dbg(&comp_asrc, "skew %d %d %d %d", delta_sample, delta_ts,
skew, cd->skew);
return 0;
Expand Down Expand Up @@ -852,22 +852,22 @@ static int asrc_copy(struct comp_dev *dev)
* The amount cd->sink_frames will be produced while
* consumption varies.
*/
cd->source_frames = MIN(frames_src, cd->source_frames_max);
cd->source_frames = Z_MIN(frames_src, cd->source_frames_max);
cd->sink_frames = cd->source_frames * cd->sink_rate /
cd->source_rate;
cd->sink_frames = MIN(cd->sink_frames, cd->sink_frames_max);
cd->sink_frames = MIN(cd->sink_frames, frames_snk);
cd->sink_frames = Z_MIN(cd->sink_frames, cd->sink_frames_max);
cd->sink_frames = Z_MIN(cd->sink_frames, frames_snk);
} else {
/* In push mode maximize the sink buffer write potential.
* ASRC will consume from source cd->source_frames while
* production varies.
*/
cd->sink_frames = MIN(frames_snk, cd->sink_frames_max);
cd->sink_frames = Z_MIN(frames_snk, cd->sink_frames_max);
cd->source_frames = cd->sink_frames * cd->source_rate /
cd->sink_rate;
cd->source_frames = MIN(cd->source_frames,
cd->source_frames_max);
cd->source_frames = MIN(cd->source_frames, frames_src);
cd->source_frames = Z_MIN(cd->source_frames,
cd->source_frames_max);
cd->source_frames = Z_MIN(cd->source_frames, frames_src);
}

if (cd->source_frames && cd->sink_frames)
Expand Down
8 changes: 4 additions & 4 deletions src/audio/codec_adapter/codec_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ int codec_adapter_prepare(struct comp_dev *dev)
}

/* Allocate local buffer */
buff_size = MAX(cd->period_bytes, codec->cpd.out_buff_size) * buff_periods;
buff_size = Z_MAX(cd->period_bytes, codec->cpd.out_buff_size) * buff_periods;
if (cd->local_buff) {
ret = buffer_set_size(cd->local_buff, buff_size);
if (ret < 0) {
Expand Down Expand Up @@ -297,7 +297,7 @@ codec_adapter_copy_from_source_to_lib(const struct audio_stream *source,
size_t bytes)
{
/* head_size - available data until end of local buffer */
uint32_t head_size = MIN(bytes, audio_stream_bytes_without_wrap(source,
uint32_t head_size = Z_MIN(bytes, audio_stream_bytes_without_wrap(source,
source->r_ptr));
/* tail_size - residue data to be copied starting from the beginning
* of the buffer
Expand All @@ -319,7 +319,7 @@ codec_adapter_copy_from_lib_to_sink(const struct codec_processing_data *cpd,
size_t bytes)
{
/* head_size - free space until end of local buffer */
uint32_t head_size = MIN(bytes, audio_stream_bytes_without_wrap(sink,
uint32_t head_size = Z_MIN(bytes, audio_stream_bytes_without_wrap(sink,
sink->w_ptr));
/* tail_size - rest of the bytes that needs to be written
* starting from the beginning of the buffer
Expand Down Expand Up @@ -352,7 +352,7 @@ static void generate_zeroes(struct comp_buffer *sink, uint32_t bytes)
ptr = audio_stream_wrap(&sink->stream, sink->stream.w_ptr);
tmp = audio_stream_bytes_without_wrap(&sink->stream,
ptr);
tmp = MIN(tmp, copy_bytes);
tmp = Z_MIN(tmp, copy_bytes);
ptr = (char *)ptr + tmp;
copy_bytes -= tmp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ static int crossover_copy(struct comp_dev *dev)
buffer_lock(sinks[i], &flags);
avail = audio_stream_avail_frames(&source->stream,
&sinks[i]->stream);
frames = MIN(frames, avail);
frames = Z_MIN(frames, avail);
buffer_unlock(sinks[i], flags);
}

Expand Down
6 changes: 3 additions & 3 deletions src/audio/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,16 +833,16 @@ static int dai_copy(struct comp_dev *dev)
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
src_samples = audio_stream_get_avail_samples(&buf->stream);
sink_samples = free_bytes / get_sample_bytes(dma_fmt);
samples = MIN(src_samples, sink_samples);
samples = Z_MIN(src_samples, sink_samples);
} else {
src_samples = avail_bytes / get_sample_bytes(dma_fmt);
sink_samples = audio_stream_get_free_samples(&buf->stream);
samples = MIN(src_samples, sink_samples);
samples = Z_MIN(src_samples, sink_samples);

/* limit bytes per copy to one period for the whole pipeline
* in order to avoid high load spike
*/
samples = MIN(samples, dd->period_bytes /
samples = Z_MIN(samples, dd->period_bytes /
get_sample_bytes(dma_fmt));
}
copy_bytes = samples * get_sample_bytes(dma_fmt);
Expand Down
4 changes: 2 additions & 2 deletions src/audio/drc/drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inline int drc_set_pre_delay_time(struct drc_state *state,
pre_delay_frames = Q_MULTSR_32X32((int64_t)pre_delay_time, rate, 30, 0, 0);
if (pre_delay_frames < 0)
return -EINVAL;
pre_delay_frames = MIN(pre_delay_frames, DRC_MAX_PRE_DELAY_FRAMES - 1);
pre_delay_frames = Z_MIN(pre_delay_frames, DRC_MAX_PRE_DELAY_FRAMES - 1);

/* Make pre_delay_frames multiplies of DIVISION_FRAMES. This way we
* won't split a division of samples into two blocks of memory, so it is
Expand All @@ -107,7 +107,7 @@ inline int drc_set_pre_delay_time(struct drc_state *state,

/* We need at least one division buffer, so the incoming data won't
* overwrite the output data */
pre_delay_frames = MAX(pre_delay_frames, DRC_DIVISION_FRAMES);
pre_delay_frames = Z_MAX(pre_delay_frames, DRC_DIVISION_FRAMES);

if (state->last_pre_delay_frames != pre_delay_frames) {
state->last_pre_delay_frames = pre_delay_frames;
Expand Down
25 changes: 13 additions & 12 deletions src/audio/drc/drc_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void drc_update_detector_average(struct drc_state *state,
sample16_p =
(int16_t *)state->pre_delay_buffers[ch] + div_start + i;
sample = Q_SHIFT_LEFT((int32_t)*sample16_p, 15, 31);
abs_input_array[i] = MAX(abs_input_array[i], ABS(sample));
abs_input_array[i] = Z_MAX(abs_input_array[i], ABS(sample));
}
}
} else { /* 4 bytes per sample */
Expand All @@ -114,7 +114,7 @@ void drc_update_detector_average(struct drc_state *state,
sample32_p =
(int32_t *)state->pre_delay_buffers[ch] + div_start + i;
sample = *sample32_p;
abs_input_array[i] = MAX(abs_input_array[i], ABS(sample));
abs_input_array[i] = Z_MAX(abs_input_array[i], ABS(sample));
}
}
}
Expand Down Expand Up @@ -154,7 +154,7 @@ void drc_update_detector_average(struct drc_state *state,
detector_average = gain;
}

detector_average = MIN(detector_average, ONE_Q30);
detector_average = Z_MIN(detector_average, ONE_Q30);
}

state->detector_average = detector_average;
Expand Down Expand Up @@ -203,8 +203,8 @@ void drc_update_envelope(struct drc_state *state, const struct sof_drc_params *p
* -12 -> 0 then scale to go from 0 -> 3
*/
x = compression_diff_db; /* Q11.21 */
x = MAX(-TWELVE_Q21, x);
x = MIN(0, x);
x = Z_MAX(-TWELVE_Q21, x);
x = Z_MIN(0, x);
/* x = 0.25f * (x + 12) */
x = Q_SHIFT_RND(x + TWELVE_Q21, 21, 19);

Expand Down Expand Up @@ -235,11 +235,11 @@ void drc_update_envelope(struct drc_state *state, const struct sof_drc_params *p
* the largest compression_diff_db we've encountered so far.
*/
state->max_attack_compression_diff_db =
MAX(state->max_attack_compression_diff_db,
sat_int32(Q_SHIFT_LEFT((int64_t)compression_diff_db, 21, 24)));
Z_MAX(state->max_attack_compression_diff_db,
sat_int32(Q_SHIFT_LEFT((int64_t)compression_diff_db, 21, 24)));

eff_atten_diff_db =
MAX(HALF_Q24, state->max_attack_compression_diff_db); /* Q8.24 */
Z_MAX(HALF_Q24, state->max_attack_compression_diff_db); /* Q8.24 */

/* x = 0.25f / eff_atten_diff_db;
* => x = 1.0f / (eff_atten_diff_db << 2);
Expand Down Expand Up @@ -419,7 +419,8 @@ void drc_compress_output(struct drc_state *state,
break;

for (j = 0; j < 4; j++)
x[j] = MIN(ONE_Q30, Q_MULTSR_32X32((int64_t)x[j], r4, 30, 30, 30));
x[j] = Z_MIN(ONE_Q30,
Q_MULTSR_32X32((int64_t)x[j], r4, 30, 30, 30));
}

state->compressor_gain = x[3];
Expand Down Expand Up @@ -554,7 +555,7 @@ static void drc_s16_default(const struct comp_dev *dev,
/* Copy fragment data from source to pre-delay buffers, and copy the output fragment
* to sink.
*/
fragment = MIN(DRC_DIVISION_FRAMES - offset, frames - i);
fragment = Z_MIN(DRC_DIVISION_FRAMES - offset, frames - i);
pd_write_index = state->pre_delay_write_index;
pd_read_index = state->pre_delay_read_index;
for (ch = 0; ch < nch; ++ch) {
Expand Down Expand Up @@ -660,7 +661,7 @@ static void drc_s24_default(const struct comp_dev *dev,
/* Copy fragment data from source to pre-delay buffers, and copy the output fragment
* to sink.
*/
fragment = MIN(DRC_DIVISION_FRAMES - offset, frames - i);
fragment = Z_MIN(DRC_DIVISION_FRAMES - offset, frames - i);
pd_write_index = state->pre_delay_write_index;
pd_read_index = state->pre_delay_read_index;
for (ch = 0; ch < nch; ++ch) {
Expand Down Expand Up @@ -769,7 +770,7 @@ static void drc_s32_default(const struct comp_dev *dev,
/* Copy fragment data from source to pre-delay buffers, and copy the output fragment
* to sink.
*/
fragment = MIN(DRC_DIVISION_FRAMES - offset, frames - i);
fragment = Z_MIN(DRC_DIVISION_FRAMES - offset, frames - i);
pd_write_index = state->pre_delay_write_index;
pd_read_index = state->pre_delay_read_index;
for (ch = 0; ch < nch; ++ch) {
Expand Down
12 changes: 6 additions & 6 deletions src/audio/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static uint32_t host_dma_get_split(struct host_data *hd, uint32_t bytes)
(hd->sink->current_end - local_elem->dest);

/* get max split, so the current copy will be minimum */
return MAX(split_src, split_dst);
return Z_MAX(split_src, split_dst);
}

static void host_update_position(struct comp_dev *dev, uint32_t bytes)
Expand Down Expand Up @@ -351,12 +351,12 @@ static uint32_t host_get_copy_bytes_normal(struct comp_dev *dev)
/* limit bytes per copy to one period for the whole pipeline
* in order to avoid high load spike
*/
copy_bytes = MIN(hd->period_bytes,
MIN(avail_bytes,
audio_stream_get_free_bytes(&hd->local_buffer->stream)));
copy_bytes = Z_MIN(hd->period_bytes,
Z_MIN(avail_bytes,
audio_stream_get_free_bytes(&hd->local_buffer->stream)));
else
copy_bytes = MIN(
audio_stream_get_avail_bytes(&hd->local_buffer->stream), free_bytes);
copy_bytes = Z_MIN(audio_stream_get_avail_bytes(&hd->local_buffer->stream),
free_bytes);

buffer_unlock(hd->local_buffer, flags);

Expand Down
6 changes: 3 additions & 3 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ static int kpb_copy(struct comp_dev *dev)
/* Update buffered size. NOTE! We only record buffered
* data up to the size of history buffer.
*/
kpb->hd.buffered += MIN(kpb->hd.buffer_size -
kpb->hd.buffered += Z_MIN(kpb->hd.buffer_size -
kpb->hd.buffered,
copy_bytes);
} else {
Expand Down Expand Up @@ -756,7 +756,7 @@ static int kpb_copy(struct comp_dev *dev)
/* In draining and init draining we only buffer data in
* the internal history buffer.
*/
copy_bytes = MIN(audio_stream_get_avail_bytes(&source->stream), kpb->hd.free);
copy_bytes = Z_MIN(audio_stream_get_avail_bytes(&source->stream), kpb->hd.free);
ret = PPL_STATUS_PATH_STOP;
if (copy_bytes) {
buffer_invalidate(source, copy_bytes);
Expand Down Expand Up @@ -1242,7 +1242,7 @@ static enum task_state kpb_draining_task(void *arg)
drain_req -= size_to_copy;
drained += size_to_copy;
period_bytes += size_to_copy;
kpb->hd.free += MIN(kpb->hd.buffer_size -
kpb->hd.free += Z_MIN(kpb->hd.buffer_size -
kpb->hd.free, size_to_copy);

if (move_buffer) {
Expand Down
8 changes: 4 additions & 4 deletions src/audio/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static int mixer_copy(struct comp_dev *dev)
/* write zeros if all sources are inactive */
if (num_mix_sources == 0) {
buffer_lock(sink, &flags);
frames = MIN(frames, audio_stream_get_free_frames(&sink->stream));
frames = Z_MIN(frames, audio_stream_get_free_frames(&sink->stream));
sink_bytes = frames * audio_stream_frame_bytes(&sink->stream);
buffer_unlock(sink, flags);

Expand All @@ -316,9 +316,9 @@ static int mixer_copy(struct comp_dev *dev)
/* check for underruns */
for (i = 0; i < num_mix_sources; i++) {
buffer_lock(sources[i], &flags);
frames = MIN(frames,
audio_stream_avail_frames(sources_stream[i],
&sink->stream));
frames = Z_MIN(frames,
audio_stream_avail_frames(sources_stream[i],
&sink->stream));
buffer_unlock(sources[i], flags);
}

Expand Down
8 changes: 4 additions & 4 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ static int demux_copy(struct comp_dev *dev)
buffer_lock(sinks[i], &flags);
avail = audio_stream_avail_frames(&source->stream,
&sinks[i]->stream);
frames = MIN(frames, avail);
frames = Z_MIN(frames, avail);
buffer_unlock(sinks[i], flags);
}

Expand Down Expand Up @@ -573,9 +573,9 @@ static int mux_copy(struct comp_dev *dev)
for (i = 0; i < MUX_MAX_STREAMS; i++) {
if (!sources[i])
continue;
frames = MIN(frames,
audio_stream_avail_frames(sources_stream[i],
&sink->stream));
frames = Z_MIN(frames,
audio_stream_avail_frames(sources_stream[i],
&sink->stream));
buffer_unlock(sources[i], flags);
}

Expand Down
8 changes: 4 additions & 4 deletions src/audio/mux/mux_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static void demux_s16le(struct comp_dev *dev, struct audio_stream *sink,
demux_calc_frames_without_wrap_s16(dev, sink, source,
lookup);

frames_without_wrap = MIN(frames, frames_without_wrap);
frames_without_wrap = Z_MIN(frames, frames_without_wrap);

for (i = 0; i < frames_without_wrap; i++) {
for (elem = 0; elem < lookup->num_elems; elem++) {
Expand Down Expand Up @@ -341,7 +341,7 @@ static void mux_s16le(struct comp_dev *dev, struct audio_stream *sink,
mux_calc_frames_without_wrap_s16(dev, sink, sources,
lookup);

frames_without_wrap = MIN(frames, frames_without_wrap);
frames_without_wrap = Z_MIN(frames, frames_without_wrap);

for (i = 0; i < frames_without_wrap; i++) {
for (elem = 0; elem < lookup->num_elems; elem++) {
Expand Down Expand Up @@ -397,7 +397,7 @@ static void demux_s32le(struct comp_dev *dev, struct audio_stream *sink,
demux_calc_frames_without_wrap_s32(dev, sink, source,
lookup);

frames_without_wrap = MIN(frames, frames_without_wrap);
frames_without_wrap = Z_MIN(frames, frames_without_wrap);

for (i = 0; i < frames_without_wrap; i++) {
for (elem = 0; elem < lookup->num_elems; elem++) {
Expand Down Expand Up @@ -451,7 +451,7 @@ static void mux_s32le(struct comp_dev *dev, struct audio_stream *sink,
mux_calc_frames_without_wrap_s32(dev, sink, sources,
lookup);

frames_without_wrap = MIN(frames, frames_without_wrap);
frames_without_wrap = Z_MIN(frames, frames_without_wrap);

for (i = 0; i < frames_without_wrap; i++) {
for (elem = 0; elem < lookup->num_elems; elem++) {
Expand Down
4 changes: 2 additions & 2 deletions src/audio/pcm_converter/pcm_converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ int pcm_convert_as_linear(const struct audio_stream *source, uint32_t ioffset,
log2_s_size_in;
N2 = audio_stream_bytes_without_wrap(sink, w_ptr) >>
log2_s_size_out;
chunk = MIN(N1, N2);
chunk = MIN(chunk, samples - i);
chunk = Z_MIN(N1, N2);
chunk = Z_MIN(chunk, samples - i);

/* run conversion on linear memory region */
converter(r_ptr, w_ptr, chunk);
Expand Down
4 changes: 2 additions & 2 deletions src/audio/smart_amp/smart_amp.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ static int smart_amp_copy(struct comp_dev *dev)
avail_feedback_frames =
audio_stream_get_avail_frames(&sad->feedback_buf->stream);

avail_frames = MIN(avail_passthrough_frames,
avail_feedback_frames);
avail_frames = Z_MIN(avail_passthrough_frames,
avail_feedback_frames);

feedback_bytes = avail_frames *
audio_stream_frame_bytes(&sad->feedback_buf->stream);
Expand Down
Loading