[PATCH 18/25] efw-downloader: efw-commands: add support for a part of hardware command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fireworks protocol includes command to retrieve information about
hardware.

This commit implements the command and local helper functions.

Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx>
---
 efw-downloader/src/efw-commands.c | 30 +++++++++++++++++++++
 efw-downloader/src/efw-commands.h | 45 +++++++++++++++++++++++++++++++
 efw-downloader/src/meson.build    |  2 ++
 3 files changed, 77 insertions(+)
 create mode 100644 efw-downloader/src/efw-commands.c
 create mode 100644 efw-downloader/src/efw-commands.h

diff --git a/efw-downloader/src/efw-commands.c b/efw-downloader/src/efw-commands.c
new file mode 100644
index 0000000..08b0114
--- /dev/null
+++ b/efw-downloader/src/efw-commands.c
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (c) 2020 Takashi Sakamoto
+#include <stdio.h>
+#include <errno.h>
+#include <time.h>
+
+#include "efw-commands.h"
+
+// Categories in Echo Audio Fireworks protocol.
+#define CATEGORY_HW             0
+
+// Commands in hardware category.
+#define HW_CMD_INFO             0
+
+#define TIMEOUT 200
+
+#define CAP_HAS_DSP     0x00000010
+#define CAP_HAS_FPGA    0x00000020
+
+void efw_hw_info(EfwProto *proto, struct hw_info *info, GError **error)
+{
+    gsize param_count = sizeof(*info) / sizeof(guint32);
+    efw_proto_transaction(proto, CATEGORY_HW, HW_CMD_INFO, NULL, 0,
+                          (guint32 *const *)&info, &param_count, TIMEOUT, error);
+}
+
+void efw_hw_info_has_fpga(struct hw_info *info, gboolean *has_fpga)
+{
+    *has_fpga = !!(info->flags & CAP_HAS_FPGA);
+}
diff --git a/efw-downloader/src/efw-commands.h b/efw-downloader/src/efw-commands.h
new file mode 100644
index 0000000..fd2dbe3
--- /dev/null
+++ b/efw-downloader/src/efw-commands.h
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (c) 2020 Takashi Sakamoto
+#ifndef __EFW_CMDS_H__
+#define __EFW_CMDS_H__
+
+#include "efw-proto.h"
+
+struct hw_info {
+    guint32 flags;
+    guint32 guid_hi;
+    guint32 guid_lo;
+    guint32 type;
+    guint32 version;
+    guint32 vendor_name[8];
+    guint32 model_name[8];
+    guint32 supported_clocks;
+    guint32 amdtp_rx_pcm_channels;
+    guint32 amdtp_tx_pcm_channels;
+    guint32 phys_out;
+    guint32 phys_in;
+    guint32 phys_out_grp_count;
+    guint32 phys_out_grp[4];
+    guint32 phys_in_grp_count;
+    guint32 phys_in_grp[4];
+    guint32 midi_out_ports;
+    guint32 midi_in_ports;
+    guint32 max_sample_rate;
+    guint32 min_sample_rate;
+    guint32 dsp_version;
+    guint32 arm_version;
+    guint32 mixer_playback_channels;
+    guint32 mixer_capture_channels;
+    guint32 fpga_version;
+    guint32 amdtp_rx_pcm_channels_2x;
+    guint32 amdtp_tx_pcm_channels_2x;
+    guint32 amdtp_rx_pcm_channels_4x;
+    guint32 amdtp_tx_pcm_channels_4x;
+    guint32 reserved[16];
+};
+
+void efw_hw_info(EfwProto *proto, struct hw_info *info, GError **error);
+
+void efw_hw_info_has_fpga(struct hw_info *info, gboolean *has_fpga);
+
+#endif
diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build
index c43c332..73a0f36 100644
--- a/efw-downloader/src/meson.build
+++ b/efw-downloader/src/meson.build
@@ -16,6 +16,7 @@ sources = [
   'efw-proto.c',
   'config-rom.c',
   'node-dispatcher.c',
+  'efw-commands.c',
   'subcmd-device.c',
 ]
 
@@ -23,6 +24,7 @@ headers = [
   'efw-proto.h',
   'config-rom.h',
   'node-dispatcher.h',
+  'efw-commands.h',
   'subcmds.h',
 ]
 
-- 
2.25.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux