In IEEE 1394 bus, each node exposes the range of address for data. The data is used by the other node to identify the node. The data is named as configuration rom.
This commit adds helper function to parse the configuration rom to detect supported models.
Signed-off-by: Takashi Sakamoto o-takashi@sakamocchi.jp --- efw-downloader/src/config-rom.c | 60 +++++++++++++++++++++++++++++++++ efw-downloader/src/config-rom.h | 26 ++++++++++++++ efw-downloader/src/meson.build | 2 ++ 3 files changed, 88 insertions(+) create mode 100644 efw-downloader/src/config-rom.c create mode 100644 efw-downloader/src/config-rom.h
diff --git a/efw-downloader/src/config-rom.c b/efw-downloader/src/config-rom.c new file mode 100644 index 0000000..ce37037 --- /dev/null +++ b/efw-downloader/src/config-rom.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include "config-rom.h" + +gboolean config_rom_detect_vendor_and_model(const guint8 *rom, guint32 *vendor_id, guint32 *model_id) +{ + gboolean detected = FALSE; + + if (rom[24] != 0x03) + return FALSE; + + *vendor_id = (rom[25] << 16) | (rom[26] << 8) | rom[27]; + + if (rom[32] != 0x17) + return FALSE; + + *model_id = (rom[33] << 16) | (rom[34] << 8) | rom[35]; + + switch (*vendor_id) { + case VENDOR_LOUD: + switch (*model_id) { + case MODEL_ONYX400F: + case MODEL_ONYX1200F: + detected = TRUE; + break; + default: + break; + } + break; + case VENDOR_ECHO_AUDIO: + switch (*model_id) { + case MODEL_AF2: + case MODEL_AF4: + case MODEL_AF8: + case MODEL_AF8P: + case MODEL_AF12: + case MODEL_AF12HD: + case MODEL_AF12_APPLE: + case MODEL_FWHDMI: + detected = TRUE; + break; + default: + break; + } + break; + case VENDOR_GIBSON: + switch (*model_id) { + case MODELRIP: + case MODELAUDIOPUNK: + detected = TRUE; + break; + default: + break; + } + default: + break; + } + + return detected; +} diff --git a/efw-downloader/src/config-rom.h b/efw-downloader/src/config-rom.h new file mode 100644 index 0000000..59bdc14 --- /dev/null +++ b/efw-downloader/src/config-rom.h @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __CONFIG_ROM_H__ +#define __CONFIG_ROM_H__ + +#include <glib.h> + +#define VENDOR_LOUD 0x000ff2 +#define MODEL_ONYX400F 0x00400f +#define MODEL_ONYX1200F 0x01200f +#define VENDOR_ECHO_AUDIO 0x001486 +#define MODEL_AF2 0x000af2 +#define MODEL_AF4 0x000af4 +#define MODEL_AF8 0x000af8 +#define MODEL_AF8P 0x000af9 +#define MODEL_AF12 0x00af12 +#define MODEL_AF12HD 0x0af12d +#define MODEL_AF12_APPLE 0x0af12a +#define MODEL_FWHDMI 0x00afd1 +#define VENDOR_GIBSON 0x00075b +#define MODELRIP 0x00afb2 +#define MODELAUDIOPUNK 0x00afb9 + +gboolean config_rom_detect_vendor_and_model(const guint8 *rom, guint32 *vendor_id, guint32 *model_id); + +#endif diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 07a6182..c006c8b 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -14,11 +14,13 @@ hinawa = dependency('hinawa', sources = [ 'main.c', 'efw-proto.c', + 'config-rom.c', 'subcmd-device.c', ]
headers = [ 'efw-proto.h', + 'config-rom.h', 'subcmds.h', ]