sof/tools/tune/common/tplg2_write.m

46 lines
991 B
Matlab
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function tplg2_write(fn, blob8, component, comment)
% SPDX-License-Identifier: BSD-3-Clause
%
% Copyright (c) 2023, Intel Corporation. All rights reserved.
%
% Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
if nargin < 4
comment = 'Exported Control Bytes';
end
%% Check that blob length is multiple of 32 bits
n_blob = length(blob8);
n_test = ceil(n_blob/4)*4;
if (n_blob ~= n_test)
fprintf(1, 'Error: ´Blob length %d is not multiple of 32 bits\n', ...
n_blob);
error('Failed.');
end
%% Write blob
fh = fopen(fn, 'w');
nl = 8;
fprintf(fh, '# %s %s\n', comment, date());
fprintf(fh, 'Object.Base.data.\"%s\" {\n', component);
fprintf(fh, '\tbytes \"\n');
for i = 1:nl:n_blob
fprintf(fh, '\t\t');
for j = 0:nl-1
n = i + j;
if n < n_blob
fprintf(fh, '0x%02x,', blob8(n));
end
if n == n_blob
fprintf(fh, '0x%02x"', blob8(n));
end
end
fprintf(fh, '\n');
end
fprintf(fh, '}\n');
fclose(fh);
fprintf('Blob size %d was written to file %s\n', n_blob, fn);
end