In Fireworks protocol, response frame from target device arrives at offset 0xecc080000000 on 1394 OHCI controller and the maximum size is 0x200U. It seems to be inspired by Function Control Protocol in IEC 61883-1. This commit adds functions to construct and destruct the instance of EfwProto object, to bind and unbind the Fireworks protocol to the the given instance of HinawaFwNode. When calling the bind function, the instance requests Linux firewire subsystem to allocate the range of address. It's possible to encounter conflict in the case that the range of address is also allocated by ALSA fireworks driver, thus this tool can not be used when the driver is loaded. Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx> --- efw-downloader/src/efw-proto.c | 62 ++++++++++++++++++++++++++++++++-- efw-downloader/src/efw-proto.h | 5 +++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index 63fd2c5..a6a6055 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -9,17 +9,73 @@ * @include: fw_fcp.h * * Fireworks board module from Echo Digital Audio corporation supports specific protocol based on - * a pair of asynchronous transactions in IEEE 1394 bus. The EfwProto class is an implementation - * for the protocol. + * a pair of asynchronous transactions in IEEE 1394 bus for command and response. The #EfwProto class + * is an implementation for the protocol. The Fireworks device transfers response against the + * command to a certain address region on 1394 OHCI controller. The instance of #EfwProto reserves + * the address region at call of #efw_proto_bind(), releases at call of #efw_proto_unbind(). */ G_DEFINE_TYPE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) +#define EFW_RESP_ADDR 0xecc080000000ull +#define EFW_MAX_FRAME_SIZE 0x200u + +static void proto_finalize(GObject *obj) +{ + EfwProto *self = EFW_PROTO(obj); + + efw_proto_unbind(self); + + G_OBJECT_CLASS(efw_proto_parent_class)->finalize(obj); +} + static void efw_proto_class_init(EfwProtoClass *klass) { - return; + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->finalize = proto_finalize; } static void efw_proto_init(EfwProto *self) { return; } + +/** + * efw_proto_new: + * + * Instantiate and return #EfwProto object. + * + * Returns: An instance of #EfwProto. + */ +EfwProto *efw_proto_new() +{ + return g_object_new(EFW_TYPE_PROTO, NULL); +} + +/** + * efw_proto_bind: + * @self: A #EfwProto. + * @node: A #HinawaFwNode. + * @error: A #GError. The error can be generated with domain of #hinawa_fw_node_error_quark(). + * + * Bind to Fireworks protocol for communication to the given node. + */ +void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error) +{ + g_return_if_fail(EFW_IS_PROTO(self)); + + hinawa_fw_resp_reserve(HINAWA_FW_RESP(self), node, EFW_RESP_ADDR, EFW_MAX_FRAME_SIZE, error); +} + +/** + * efw_proto_unbind: + * @self: A #EfwProto. + * + * Unbind from Fireworks protocol. + */ +void efw_proto_unbind(EfwProto *self) +{ + g_return_if_fail(EFW_IS_PROTO(self)); + + hinawa_fw_resp_release(HINAWA_FW_RESP(self)); +} diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index 83e52be..b0e519d 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -35,6 +35,11 @@ struct _EfwProtoClass { HinawaFwRespClass parent_class; }; +EfwProto *efw_proto_new(); + +void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error); +void efw_proto_unbind(EfwProto *self); + G_END_DECLS #endif -- 2.25.1