rmbox: Add support for floating point clock freq in MHz
Allow timestamp clock frequency to be set in MHz Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
This commit is contained in:
parent
7a1105772d
commit
6bb4da421c
|
@ -99,23 +99,38 @@ static void usage(char *name)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float to_usecs(uint32_t time, uint32_t clk)
|
static float to_usecs(uint32_t time, float clk)
|
||||||
{
|
{
|
||||||
/* trace timestamp uses CPU system clock at default 25MHz ticks */
|
/* trace timestamp uses CPU system clock at default 25MHz ticks */
|
||||||
// TODO: support variable clock rates
|
// TODO: support variable clock rates
|
||||||
return (float)time / clk;
|
return (float)time / clk;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, uint32_t clk)
|
static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, float clk)
|
||||||
{
|
{
|
||||||
const char *trace;
|
const char *trace;
|
||||||
uint32_t class;
|
uint32_t class;
|
||||||
|
uint32_t delta = val - *timestamp;
|
||||||
|
float fdelta = to_usecs(delta, clk);
|
||||||
|
|
||||||
/* timestamp or value ? */
|
/* timestamp or value ? */
|
||||||
if ((addr % 8) == 0) {
|
if ((addr % 8) == 0) {
|
||||||
|
|
||||||
|
/* buffer wrap ? */
|
||||||
|
if (val < *timestamp) {
|
||||||
|
printf("----------------------------------------"
|
||||||
|
"----------------------------------------"
|
||||||
|
"--------------------------------------\n");
|
||||||
|
delta = 0;
|
||||||
|
fdelta = 0.0;
|
||||||
|
} else {
|
||||||
|
delta = val - *timestamp;
|
||||||
|
fdelta = to_usecs(delta, clk);
|
||||||
|
}
|
||||||
|
|
||||||
printf("trace.io: timestamp 0x%8.8x (%2.2f us) \tdelta 0x%8.8x (%2.2f us)\t",
|
printf("trace.io: timestamp 0x%8.8x (%2.2f us) \tdelta 0x%8.8x (%2.2f us)\t",
|
||||||
(uint32_t)val, to_usecs(val, clk),
|
(uint32_t)val, to_usecs(val, clk),
|
||||||
(uint32_t)val - *timestamp, to_usecs(val - *timestamp, clk));
|
(uint32_t)delta, fdelta);
|
||||||
*timestamp = val;
|
*timestamp = val;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +273,8 @@ int main(int argc, char *argv[])
|
||||||
const char * out_file = NULL, *in_file = "/sys/kernel/debug/sof/mbox";
|
const char * out_file = NULL, *in_file = "/sys/kernel/debug/sof/mbox";
|
||||||
FILE *in_fd = NULL, *out_fd = NULL;
|
FILE *in_fd = NULL, *out_fd = NULL;
|
||||||
char c, tmp[4] = {0};
|
char c, tmp[4] = {0};
|
||||||
uint32_t addr = 0, val, clk = 25, timestamp = 0;
|
uint32_t addr = 0, val, timestamp = 0;
|
||||||
|
float clk = 19.2f;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "ho:i:s:m:c:")) != -1) {
|
while ((opt = getopt(argc, argv, "ho:i:s:m:c:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
@ -269,7 +285,7 @@ int main(int argc, char *argv[])
|
||||||
in_file = optarg;
|
in_file = optarg;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
clk = atoi(optarg);
|
clk = atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
return snapshot(optarg);
|
return snapshot(optarg);
|
||||||
|
@ -301,6 +317,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* start to converting mailbox */
|
/* start to converting mailbox */
|
||||||
convert:
|
convert:
|
||||||
|
fprintf(stdout, "using %2.2fMHz timestamp clock\n", clk);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
count = fread(&tmp[0], 1, 4, in_fd);
|
count = fread(&tmp[0], 1, 4, in_fd);
|
||||||
if (count != 4)
|
if (count != 4)
|
||||||
|
|
Loading…
Reference in New Issue