-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tools: Tune: Collection of patches to produce ALSA UCM friendly binary control blobs #9070
Changes from all commits
e67ce01
616765b
8b698a4
44ba747
9ece79c
6908a5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function sof_ucm_blob_write(fn, blob8) | ||
|
||
% Export blob to UCM2 cset-tlv binary format | ||
% | ||
% sof_ucm_blob_write(fn, blob) | ||
% | ||
% Input parameters | ||
% fn - Filename for the blob | ||
% blob - Vector of data with uint8 type | ||
% | ||
|
||
% SPDX-License-Identifier: BSD-3-Clause | ||
% | ||
% Copyright (c) 2024, Intel Corporation. All rights reserved. | ||
|
||
% Export for UCM cset-tlv with additional 8 bytes header | ||
SOF_CTRL_CMD_BINARY = 3; | ||
nh = 8; | ||
nb = length(blob8); | ||
ublob8 = zeros(nb + nh, 1, 'uint8'); | ||
ublob8(1:4) = w32b(SOF_CTRL_CMD_BINARY); | ||
ublob8(5:8) = w32b(nb); | ||
ublob8(9:end) = blob8; | ||
|
||
%% Write blob | ||
check_create_dir(fn); | ||
fh = fopen(fn, 'wb'); | ||
fwrite(fh, ublob8, 'uint8'); | ||
fclose(fh); | ||
|
||
%% Print as 8 bit hex | ||
nb = length(ublob8); | ||
nl = ceil(nb/16); | ||
for i = 1:nl | ||
m = min(16, nb-(i-1)*16); | ||
for j = 1:m | ||
fprintf(1, "%02x ", ublob8((i-1)*16 + j)); | ||
end | ||
fprintf(1, "\n"); | ||
end | ||
|
||
fprintf(1, "\n"); | ||
end | ||
|
||
function bytes = w32b(word) | ||
sh = [0 -8 -16 -24]; | ||
bytes = uint8(zeros(1,4)); | ||
bytes(1) = bitand(bitshift(word, sh(1)), 255); | ||
bytes(2) = bitand(bitshift(word, sh(2)), 255); | ||
bytes(3) = bitand(bitshift(word, sh(3)), 255); | ||
bytes(4) = bitand(bitshift(word, sh(4)), 255); | ||
end |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,17 +10,19 @@ function example_fir_eq() | |
|
||
%% Common definitions | ||
fs = 48e3; | ||
fn.cpath3 = '../../ctl/ipc3'; | ||
fn.cpath4 = '../../ctl/ipc4'; | ||
fn.cpath3 = '../../ctl/ipc3/eq_fir'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no check to see if these directories exist before writing files into them, which may lead to errors. Can you consider adding checks and possibly creating directories that do not currently exist? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to leave to another PR. There could be a function dir = sof_directory_create_check(dir); |
||
fn.cpath4 = '../../ctl/ipc4/eq_fir'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here - same as well? |
||
fn.tpath1 = '../../topology/topology1/m4'; | ||
fn.tpath2 = '../../topology/topology2/include/components/eqfir'; | ||
fn.priv = 'DEF_EQFIR_PRIV'; | ||
|
||
addpath ../common | ||
|
||
%% ------------------- | ||
%% Example 1: Loudness | ||
%% ------------------- | ||
fn.bin = 'eq_fir_loudness.bin'; | ||
fn.txt = 'eq_fir_loudness.txt'; | ||
fn.bin = 'loudness.blob'; | ||
fn.txt = 'loudness.txt'; | ||
fn.tplg1 = 'eq_fir_coef_loudness.m4'; | ||
fn.tplg2 = 'loudness.conf'; | ||
comment = 'Loudness effect, created with example_fir_eq.m'; | ||
|
@@ -50,8 +52,8 @@ function example_fir_eq() | |
%% ------------------- | ||
%% Example 2: Mid boost | ||
%% ------------------- | ||
fn.bin = 'eq_fir_mid.bin'; | ||
fn.txt = 'eq_fir_mid.txt'; | ||
fn.bin = 'mid.blob'; | ||
fn.txt = 'mid.txt'; | ||
fn.tplg1 = 'eq_fir_coef_mid.m4'; | ||
fn.tplg2 = 'midboost.conf'; | ||
comment = 'Mid boost, created with example_fir_eq.m'; | ||
|
@@ -77,8 +79,8 @@ function example_fir_eq() | |
%% ------------------- | ||
%% Example 3: Flat EQ | ||
%% ------------------- | ||
fn.bin = 'eq_fir_flat.bin'; | ||
fn.txt = 'eq_fir_flat.txt'; | ||
fn.bin = 'flat.blob'; | ||
fn.txt = 'flat.txt'; | ||
fn.tplg1 = 'eq_fir_coef_flat.m4'; | ||
fn.tplg2 = 'flat.conf'; | ||
comment = 'Flat response, created with example_fir_eq.m'; | ||
|
@@ -104,8 +106,8 @@ function example_fir_eq() | |
%% -------------------------- | ||
%% Example 4: Pass-through EQ | ||
%% -------------------------- | ||
fn.bin = 'eq_fir_pass.bin'; | ||
fn.txt = 'eq_fir_pass.txt'; | ||
fn.bin = 'pass.blob'; | ||
fn.txt = 'pass.txt'; | ||
fn.tplg1 = 'eq_fir_coef_pass.m4'; | ||
fn.tplg2 = 'passthrough.conf'; | ||
comment = 'Pass-through response, created with example_fir_eq.m'; | ||
|
@@ -133,6 +135,8 @@ function example_fir_eq() | |
%% Done. | ||
%% -------------------------- | ||
|
||
rmpath ../common | ||
|
||
end | ||
|
||
%% ------------------- | ||
|
@@ -221,7 +225,7 @@ function eq_pack_export(bm, fn, note) | |
|
||
bp = eq_fir_blob_pack(bm, 3); % IPC3 | ||
if ~isempty(fn.bin) | ||
eq_blob_write(fullfile(fn.cpath3, fn.bin), bp); | ||
sof_ucm_blob_write(fullfile(fn.cpath3, fn.bin), bp); | ||
end | ||
if ~isempty(fn.txt) | ||
eq_alsactl_write(fullfile(fn.cpath3, fn.txt), bp); | ||
|
@@ -232,7 +236,7 @@ function eq_pack_export(bm, fn, note) | |
|
||
bp = eq_fir_blob_pack(bm, 4); % IPC4 | ||
if ~isempty(fn.bin) | ||
eq_blob_write(fullfile(fn.cpath4, fn.bin), bp); | ||
sof_ucm_blob_write(fullfile(fn.cpath4, fn.bin), bp); | ||
end | ||
if ~isempty(fn.txt) | ||
eq_alsactl_write(fullfile(fn.cpath4, fn.txt), bp); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@singalsu presumably an OEM or integrator will have multiple SKUs to tune. Should there be some sort of prefix for the blobs so that the storage can be specified as SKU-specific?
And while I am at it, can those tuning scripts actually be used in a script that generates blobs for multiple platforms, just taking input parameters for each SKU?