From patchwork Fri Aug 21 07:30:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728383 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A48D0913 for ; Fri, 21 Aug 2020 07:33:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C4C62078D for ; Fri, 21 Aug 2020 07:33:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="AyVMsQel"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="KWvlgt7J"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fSD4AdCr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C4C62078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7F0221684; Fri, 21 Aug 2020 09:32:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7F0221684 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995192; bh=wgSXPWKNzGOVjQhBiyRxQYH1nHH0oZ0HenK+5ldt92w=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AyVMsQelyNU3VCa1ixCg1LiXqrdJdwyFJ69VM7xxKzSzD5qsn2Xl5N7qHRzYr9gAf VJNcXE5hTRm6fy0XGi/RXH9JyWZWixuKPWVlWpxEUViz/BCx4qIIWbqzBsUI9Wr6eI 67ow1KKOJcDjftY1y6MDws30B0Eheu+6I5SIe7l0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 10E2EF802D2; Fri, 21 Aug 2020 09:31:36 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id A54C9F800C0; Fri, 21 Aug 2020 09:31:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,PRX_BODY_135,PRX_BODY_65,PRX_BODY_78,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C90E4F800C0 for ; Fri, 21 Aug 2020 09:31:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C90E4F800C0 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="KWvlgt7J"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fSD4AdCr" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 40703858; Fri, 21 Aug 2020 03:31:18 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=PGTn8Twnbgmak s1cI0Z2hVd3EW77C7E3ceN7E2KcjHQ=; b=KWvlgt7JMA83jEDIaVeaGY2g04llj TGljeKH7NnuXct8Xz/S65txSA3TEJckgsD8HYPGsXO6UxfXP4iKVoEO5nsn0BDrz wPPGBwrT8GlIb/wR7b9A78FmFUoujpMFBVFhSDJvbK93tlLnPTPVQQ82Kpg6HWWe 2atiQQaH/mgTk2KMdO9JGYokiU9yWrd/Kbv7VFuP48A/TmoNG22mTkh+GKQhiNtv Ln+kA8k/a0MKmENwaccB9ZUvzdnje3j+ZFI0EanNN13fRLZBpIRDszr0UcueocER Vy4laEz31IXsv1KvIEfd9jzOlLcz8QXvU7WYF/NVEt0mO+zHTRMTrkJqQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=PGTn8Twnbgmaks1cI0Z2hVd3EW77C7E3ceN7E2KcjHQ=; b=fSD4AdCr G12uCJvv7Aqru+hOoH9nKEdaPkDIQlz5T+8EAHhqrbMeiLfSzYb0QXccqik//0qf FaqxBKWQqElyRZrLztBycBgx77AmjR3VHbPOTTg3peBepVmEQJWlY8h6GX1A4wFl 3F4Vcu9j26GKofKNah5m7J8NYTHdhxpeYI7jWaSQ5cvBmZiRYb3NJSeFWHN+emVC dKRtQf0A0qMUL0RLGJF/jBDpt4YwSiuUuH46Gj8HXaTAUNCPz/+mMhISq62mz1Xd u59+dcp3eQlIgDdywOvHusXX2DGatw5G85nmkYa/N8QE7WNHMW3RxMTwDnmH8Uf3 yoYrb9+k8Y6zcg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpefhjefhud eujeekueelgffhtdejhfelueelhfehhfdttddvfeejieevfeelfffhvdenucffohhmrghi nhepfhhsfhdrohhrghdpghhnuhdrohhrghenucfkphepudektddrvdefhedrfedrheegne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgr khgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 4541630600A6; Fri, 21 Aug 2020 03:31:16 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 01/25] efw-downloader: start a new project to operate on-board flash memory for Fireworks board module Date: Fri, 21 Aug 2020 16:30:47 +0900 Message-Id: <20200821073111.134857-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Fireworks board module was designed by Echo Digital Audio corporation. The board module has on-board flash memory to store firmware blob and session data. The contents of flash memory can be operated by software by a pair of asynchronous transactions defined by Echo Digital Audio corporation. The firmware blob is used by below ICs: * Texus Instruments TSB43Cx43A (IceLynx Micro) * Texus Instruments TMS320C6713B (DSP) * Xilinx Spartan XC35250E (FPGA) All of Fireworks models use the IceLynx Micro for packet processing on IEEE 1394 bus. On the other hand, a part of the models use the DSP and the others use FPGA. The vendors of models ships several versions of a set of firmware. This project produces a command-line tool named as 'efw-downloader' to operate contents of on-board flash memory for firmware of the above ICs. This software is licensed under the GNU public license v3.0 or later. Meson build system is used to build the tool. Signed-off-by: Takashi Sakamoto --- efw-downloader/COPYING | 674 +++++++++++++++++++++++++++++++++ efw-downloader/meson.build | 10 + efw-downloader/src/main.c | 8 + efw-downloader/src/meson.build | 11 + 4 files changed, 703 insertions(+) create mode 100644 efw-downloader/COPYING create mode 100644 efw-downloader/meson.build create mode 100644 efw-downloader/src/main.c create mode 100644 efw-downloader/src/meson.build diff --git a/efw-downloader/COPYING b/efw-downloader/COPYING new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/efw-downloader/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/efw-downloader/meson.build b/efw-downloader/meson.build new file mode 100644 index 0000000..9664100 --- /dev/null +++ b/efw-downloader/meson.build @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# Copyright (c) 2020 Takashi Sakamoto + +project('efw-downloader', 'c', + version: '0.1.0', + license: 'GPL-3.0+', + meson_version: '>= 0.46.0', +) + +subdir('src') diff --git a/efw-downloader/src/main.c b/efw-downloader/src/main.c new file mode 100644 index 0000000..31ac349 --- /dev/null +++ b/efw-downloader/src/main.c @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include + +int main(int argc, char **argv) +{ + return EXIT_SUCCESS; +} diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build new file mode 100644 index 0000000..b837e92 --- /dev/null +++ b/efw-downloader/src/meson.build @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# Copyright (c) 2020 Takashi Sakamoto + +sources = [ + 'main.c', +] + +executable('efw-downloader', + sources: sources, + install: true, +) From patchwork Fri Aug 21 07:30:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B228E16B1 for ; Fri, 21 Aug 2020 07:36:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 47AFF2078D for ; Fri, 21 Aug 2020 07:36:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="LxHvvpmh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="F6lgjzCD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="b0BHf2EX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47AFF2078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CEC041670; Fri, 21 Aug 2020 09:35:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CEC041670 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995382; bh=fhHD7IMMF9mUTUGiwX2FECTy6+NcrCyDYHMR9+HIuks=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LxHvvpmhNqj9seXVm+3q542U8GHM1maFkcJOEP+EiuBZFkhdf2dZjIRT79oGl7n5E zbTxpyVyi+GEDIaaYZWcQiYOmwaSebhLhbWvX9sATMwEKGN/LUisbhJl7oyYwiIAGq Le1CrDk9pcMlpPmwzOSQoE8aFnudpM/ntw9YjgMU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1A545F80306; Fri, 21 Aug 2020 09:31:54 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 12F56F802E7; Fri, 21 Aug 2020 09:31:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B198DF80218 for ; Fri, 21 Aug 2020 09:31:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B198DF80218 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="F6lgjzCD"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="b0BHf2EX" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id D01CC6F0; Fri, 21 Aug 2020 03:31:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=IHL0xumbb5SCV VFEZYwR9Fn70hgzcQxVEDDhjaewpJI=; b=F6lgjzCDDjj/tOAyPFfEnLXHUCrqF aYcXb3G1R0BUjI3Sd3p709RF/3qSbyJEH4mmNgkIq/xg32TK0w4bXe0zfTDWQT4t Q7oqW3TETIXzM9MsoaYNmIUyA/4+pR2Hdb7w/ByW/8zYvrg1RfJxO8a8ly1FhzZe LzzbNmP1Hvin2RyAwBVZL3XcBGuEUdlFp2ZWfGyCiu0bCEWoFBth6ouTOr3YALr5 dhKODmSuMzH++ZN6KK8hWtTMZornRmo5twYGB2xqv6e4jX8XM4V69sKLnaJkzIGO R42se5BoAdq9nFOeDRnaQSq45kwsxF4L82ARor0mBY6a3LAB1ew10HZlQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=IHL0xumbb5SCVVFEZYwR9Fn70hgzcQxVEDDhjaewpJI=; b=b0BHf2EX AjYtHGfEMYj6i5buerO0zX8m7j35fNzHcQAVC+/Ck6YIMZXMa7VkjUfQUhfDRbaa bGCwSc0yxj2LkB7tJlZMaYezfCNxMpiLj/vIXWAPRJhk/mK/oCY8rK3/Zk1YhLSq /be5V7/bCT/hoirHANil9ltbvDGyFuM1UUpF1Qd//s6FPwQ5EWi8BAX8wRGEghVv sr1fXwNziUIQvtY2q2wIHa6DL12BXasc5fSawxpqc/v/CpIOUQX6phEqoF0iameM Awc0/u/k9mm59MnzTickaKaP1gpqn5cU+h0YvatRmtpVj6exdQfaXyVGlMMl2B3E lJ1BFB0vuEkQiA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 0BC8B30600B1; Fri, 21 Aug 2020 03:31:17 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 02/25] efw-downloader: efw-proto: define EfwProto as derived object of HinawaFwResp Date: Fri, 21 Aug 2020 16:30:48 +0900 Message-Id: <20200821073111.134857-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Echo Digital Audio corporation designed specific protocol to operate Fireworks board module. The protocol includes a pair of asynchronous transactions on IEEE 1394 bus to transfer command frame and receive response frame. This commit adds EfwProto GObject object. This object inherits HinawaFwResp to receive the response frame from Linux 1394 OHCI driver, thus libglib-2.0, libgobject-2.0 and libhinawa 2.1 is added for build and runtime dependency. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/efw-proto.c | 25 +++++++++++++++++++++ efw-downloader/src/efw-proto.h | 40 ++++++++++++++++++++++++++++++++++ efw-downloader/src/meson.build | 21 +++++++++++++++++- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 efw-downloader/src/efw-proto.c create mode 100644 efw-downloader/src/efw-proto.h diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c new file mode 100644 index 0000000..63fd2c5 --- /dev/null +++ b/efw-downloader/src/efw-proto.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include "efw-proto.h" + +/** + * SECTION:efw_proto + * @Title: EfwProto + * @Short_description: Transaction implementation for Fireworks protocol + * @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. + */ +G_DEFINE_TYPE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) + +static void efw_proto_class_init(EfwProtoClass *klass) +{ + return; +} + +static void efw_proto_init(EfwProto *self) +{ + return; +} diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h new file mode 100644 index 0000000..83e52be --- /dev/null +++ b/efw-downloader/src/efw-proto.h @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __EFW_PROTO_H__ +#define __EFW_PROTO_H__ + +#include +#include + +#include + +G_BEGIN_DECLS + +#define EFW_TYPE_PROTO (efw_proto_get_type()) + +#define EFW_PROTO(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), EFW_TYPE_PROTO, EfwProto)) +#define EFW_IS_PROTO(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), EFW_TYPE_PROTO)) + +#define EFW_PROTO_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), EFW_TYPE_PROTO, EfwProtoClass)) +#define EFW_IS_PROTO_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), EFW_TYPE_PROTO)) +#define EFW_PROTO_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), EFW_TYPE_PROTO, EfwProtoClass)) + +typedef struct _EfwProto EfwProto; +typedef struct _EfwProtoClass EfwProtoClass; + +struct _EfwProto { + HinawaFwResp parent_instance; +}; + +struct _EfwProtoClass { + HinawaFwRespClass parent_class; +}; + +G_END_DECLS + +#endif diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index b837e92..b7992a2 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -1,11 +1,30 @@ # SPDX-License-Identifier: GPL-3.0-or-later # Copyright (c) 2020 Takashi Sakamoto +# Depends on glib-2.0 and gobject-2.0. +gobject = dependency('gobject-2.0', + version: '>=2.34.0', +) + +# Depends on libhinawa v2.1.0 or later. +hinawa = dependency('hinawa', + version: '>=2.1', +) + sources = [ 'main.c', + 'efw-proto.c', +] + +headers = [ + 'efw-proto.h', ] executable('efw-downloader', - sources: sources, + sources: sources + headers, + dependencies: [ + gobject, + hinawa, + ], install: true, ) From patchwork Fri Aug 21 07:30:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728385 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14AEB722 for ; Fri, 21 Aug 2020 07:34:05 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98E842078D for ; Fri, 21 Aug 2020 07:34:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Qcq7icO5"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="nc/DRFEz"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YcFUHwXg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98E842078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0A68B169C; Fri, 21 Aug 2020 09:33:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0A68B169C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995243; bh=XrZH+LLb4Xp6i3fKT5dN7dzSnnRsamf2oncPMnSy/q8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Qcq7icO5VI/qI+U/x0V+K/v03uGyLPUb+/LOFWrREq4lK6BClXELr8G1CLZAeAlYd /VUUjvp5YJXl96d6WIU3IPpiRWaYyNH3yvDWd+6CqiA3lo6LIa+3IdntXU4njvoNOX CTO/0KcNsJJK2zkFP4nVOruJS83thhjRKRQ82SVY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D8588F800D3; Fri, 21 Aug 2020 09:31:41 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 62649F802EA; Fri, 21 Aug 2020 09:31:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C4924F800D3 for ; Fri, 21 Aug 2020 09:31:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4924F800D3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="nc/DRFEz"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YcFUHwXg" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 701C6839; Fri, 21 Aug 2020 03:31:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=cvkhDFrmVXOO0 NlRW+1FPGG5nVNKOzj8jgWingxFv4I=; b=nc/DRFEzhYXSWhsTgB82e5r3Elj+n 2DfgmuSbQkIwY5BzI+NXFoThHk2WZ6hX3B6e3xy454b1d+jgfpAnvQPV84MFu9iT BtgpgrHp5yYx2tGiUwCV1jukHudDXHmdEiqrjpsq64BXKdUdCWUdXvzEEYZeYSnC LtPBiEQ43DWvZortk4sRk6pUt0R2x2lfcNyszoWqavRsg1LYaBU6qFtfGxBBPeGu NG+lGqMbzA9sWQHB88If52wciQ2mR0Ohf+2HVra9yt+VdKz7l5D5pIhi3/Zx4zH2 WTDC/z3Gvbi9mVkRH94yV6+ctDtxiufE8ZAFsy9HB6DM1NelQqsCJ3CgQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=cvkhDFrmVXOO0NlRW+1FPGG5nVNKOzj8jgWingxFv4I=; b=YcFUHwXg fjDE0YUY9/UwA71Fnbm0TlJ8WTPKDLvm7/ztvdQEEFeAWW+Bhl71n6jZGMgWCYbm 4h1bpXuYN6CioXYglBDYfFqeTXJIf/lSCuCU2bjMZxn9vm6U+Fh44nEbxs2wDNBs tTEDsVyuETZ0P763iw1Oehdjwv5Uu+pTyc53OXDHxEKCbah6iQZlF4b3sAAH1ucY kKevwVEFqbPSUzVMZMvRfbjytw9i7ud1Qqnkzpakqb9sqa5IgnQqqBlv+KLEukmI mCW/oxR1R/CFlfhJe30HDsgs0FdkTWnqHviUr3YXIeYuyzdZasdaanL8/uI+HBOJ +1pJ0O5hAbMzBg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id A049130600B4; Fri, 21 Aug 2020 03:31:19 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 03/25] efw-downloader: efw-proto: add constructor, destructor, bind, unbind functions Date: Fri, 21 Aug 2020 16:30:49 +0900 Message-Id: <20200821073111.134857-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- 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 From patchwork Fri Aug 21 07:30:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE99D16B1 for ; Fri, 21 Aug 2020 07:34:59 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 631592078D for ; Fri, 21 Aug 2020 07:34:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="N4ZLl2w7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Me/ieQ89"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mGz+S2Ql" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 631592078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CC2CA1687; Fri, 21 Aug 2020 09:34:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CC2CA1687 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995297; bh=02kgDYO3g8sN0N4zec5cLghBy6Zx2WAnN/DOSYcvCaE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=N4ZLl2w7pZhcXf093PQGsOX4C05q3641X5DNi2vue0Yhz3J1DiryMvOJcjJjWChFw YlYG12jMOQVfx11kTR6eIs5kICXkqBM6y5Vx2TSzXVqnTGjiUHUl/kJFqxT0yM6AyH 7Go+blqX3PhDWvGhFqaF7DGO9tXByI7uz1ctXnc0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8EBF5F802FD; Fri, 21 Aug 2020 09:31:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3A237F802E7; Fri, 21 Aug 2020 09:31:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8AF8DF8025A for ; Fri, 21 Aug 2020 09:31:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8AF8DF8025A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Me/ieQ89"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mGz+S2Ql" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id D9EAF874; Fri, 21 Aug 2020 03:31:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=s9E+MFXVnhMSF mbIpbJVREX6/j7qFbqK6L8U1zPCKac=; b=Me/ieQ89W9wZBQqgqIyaSRjp5IM/a snSQC3SpzjItWxhirAcJQK6G1X9qF5ZpjQNeXkvaNC2ePb4pxpmtI9bHvGeQkwYs 3QhH6Gtj9QkBdgzTt5eapAj5EdrNmZFwHzOiLkbVsUeMkCm+ZfX+h5R8/DGNEl+c pIPna5MeA4aM3r1QugN8W7agrcvw0ARrlkysptutBiqNGRuk1XvnwDPpgXPwoY+L fYzl7EKgv8xLtqplrbKgM7DaFXV5Vat5iGq/xm8ycC0/JApz5f8jwdFiwepKv9/q 8iz4wVW++7M+rRwNAQZrzcrv8V3zm1yZlLPIIWRoYfbRnAd24ILH8R+dQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=s9E+MFXVnhMSFmbIpbJVREX6/j7qFbqK6L8U1zPCKac=; b=mGz+S2Ql LvUr0o0iBmT9UdnIkrSjeQV0MOAFbXm/CyleyozNgsDTOfk7AC9oijKmlSkycv/y MVX6XFWSbbe8qSslQrDlA9QH/IN0DOtktNAP91KaTZadOXgbgxOYD+ZZmiqyudVW 1/KuxGYua5aGlh5YB5qXUTwJzmxi8y3d1iCXE044qi/8bSBxZBsM1AgLozJZ9bgs OQkW3xRZMjTsJ1Q5svRPrlX9pN+w//u5F50MyWUkKrmtlAxXKKXln5OSjzAMF9b0 WjmcVdE01KuwH9QJTLS84qmgUuJWb20iY7twDjkqMOGSgyr6KTbOD/Ekz8arsOnl loHun2DhNhp4FQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 2E86430600B1; Fri, 21 Aug 2020 03:31:21 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 04/25] efw-downloader: efw-proto: add responded signal Date: Fri, 21 Aug 2020 16:30:50 +0900 Message-Id: <20200821073111.134857-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" GObject has a feature of 'signal'. It's emitted in event dispatcher asynchronously to application which register own callback function in advance. This commit adds 'responded' GObject signal to handle data in response frame. In future commit, the signal is emitted actually. Signed-off-by: Takashi Sakamoto --- .../src/efw-proto-sigs-marshal.list | 1 + efw-downloader/src/efw-proto.c | 32 +++++++++++++++++++ efw-downloader/src/efw-proto.h | 1 + efw-downloader/src/meson.build | 8 +++++ 4 files changed, 42 insertions(+) create mode 100644 efw-downloader/src/efw-proto-sigs-marshal.list diff --git a/efw-downloader/src/efw-proto-sigs-marshal.list b/efw-downloader/src/efw-proto-sigs-marshal.list new file mode 100644 index 0000000..c489d58 --- /dev/null +++ b/efw-downloader/src/efw-proto-sigs-marshal.list @@ -0,0 +1 @@ +VOID:ENUM,UINT,UINT,UINT,POINTER,UINT diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index a6a6055..6502957 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (c) 2020 Takashi Sakamoto #include "efw-proto.h" +#include "efw-proto-sigs-marshal.h" /** * SECTION:efw_proto @@ -19,6 +20,12 @@ G_DEFINE_TYPE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) #define EFW_RESP_ADDR 0xecc080000000ull #define EFW_MAX_FRAME_SIZE 0x200u +enum efw_proto_sig_type { + EFW_PROTO_SIG_TYPE_RESPONDED = 1, + EFW_PROTO_SIG_COUNT, +}; +static guint efw_proto_sigs[EFW_PROTO_SIG_COUNT] = { 0 }; + static void proto_finalize(GObject *obj) { EfwProto *self = EFW_PROTO(obj); @@ -33,6 +40,31 @@ static void efw_proto_class_init(EfwProtoClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS(klass); gobject_class->finalize = proto_finalize; + + /** + * EfwProto::responded: + * @self: A #EfwProto. + * @status: One of #HinawaSndEfwStatus. + * @seqnum: The sequence number of response. + * @category: The value of category field in the response. + * @command: The value of command field in the response. + * @frame: (array length=frame_size)(element-type guint32): The array with elements for + * quadlet data of response for Echo Fireworks protocol. + * @frame_size: The number of elements of the array. + * + * When the unit transfers asynchronous packet as response for Fireworks protocol, and the + * process successfully reads the content of response from ALSA Fireworks driver, the + * #EfwProto::responded signal handler is called with parameters of the response. + */ + efw_proto_sigs[EFW_PROTO_SIG_TYPE_RESPONDED] = + g_signal_new("responded", + G_OBJECT_CLASS_TYPE(klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + efw_proto_sigs_marshal_VOID__ENUM_UINT_UINT_UINT_POINTER_UINT, + G_TYPE_NONE, + 6, HINAWA_TYPE_SND_EFW_STATUS, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_POINTER, G_TYPE_UINT); } static void efw_proto_init(EfwProto *self) diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index b0e519d..fbd4366 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -7,6 +7,7 @@ #include #include +#include G_BEGIN_DECLS diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index b7992a2..ca894d9 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -20,6 +20,14 @@ headers = [ 'efw-proto.h', ] +gnome = import('gnome') +marshallers = gnome.genmarshal('efw-proto-sigs-marshal', + prefix: 'efw_proto_sigs_marshal', + sources: 'efw-proto-sigs-marshal.list', + stdinc: true, +) +sources += marshallers + executable('efw-downloader', sources: sources + headers, dependencies: [ From patchwork Fri Aug 21 07:30:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47350175D for ; Fri, 21 Aug 2020 07:35:44 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D219E207DF for ; Fri, 21 Aug 2020 07:35:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="toEZ9RjR"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="GW+E40S7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oo1CzkwM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D219E207DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 04912166F; Fri, 21 Aug 2020 09:34:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 04912166F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995342; bh=DXaP1tpGX1zKV+YxWs4LTpnx3JDNKUF7BR1fuoD633o=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=toEZ9RjRJa1Nqq4Yzj2teAv26IdWTZ7VKcOKKfz1w730ZEcx3XamsbHxZaBWNnDJP XdiDVNhsPAJuUmkEKmNj6mEhzbwTOFYIwgR28g2IeS2FBVK4DlUkcHNkVs1duqOYvJ 1W2cHiiLgDgJqk2HeaReiWTSz7phmdW78hf6ttGU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ACD9FF802FF; Fri, 21 Aug 2020 09:31:51 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6D412F8025A; Fri, 21 Aug 2020 09:31:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 68A44F80253 for ; Fri, 21 Aug 2020 09:31:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 68A44F80253 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="GW+E40S7"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oo1CzkwM" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 590ED310; Fri, 21 Aug 2020 03:31:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=/XqfIqyu18uSn jcHyC2m9YLXcfLh7soh6af9AtUQNBo=; b=GW+E40S7AYviY+khl9tkkW6U/POe6 s7Y8Bn4ZjnGZb783QcfiFtyQs1NXXwcuwlsbJm9Hj3Mkst3CHdNFypP8MvHbD8I9 ZXPBJNWMoDdo1yDtPlFirHPabMfVOPBOsHQwBIrJ+RGLIkf6XFGLR2PCMg3P6b3T SJaGIvonUu5Wc8jDFcW8CPdEWOBnBRKWGoZHPJWCERT6QeFXQTxVJN28ewUcj3gv OKc69Pmpm1JdoW+eRwbnfQ5PhET7GI7R5iH2QwjnNK3tuNXN3a3zh+lR1Xi1kF2j H+LTjFz/rzIdyr3BSHidfLlTwzBkIqYn62FrRk3LoD2DsiHl3ZKiBr8Hg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=/XqfIqyu18uSnjcHyC2m9YLXcfLh7soh6af9AtUQNBo=; b=oo1CzkwM EbdFzUcSf2urR1K4WB8epIV7QVU8tEUh/39hASdKh3INQtPGvowbPrw/Ip6+MV54 /468h8g/5D6lHUvC06QsLXV9JLs/Hh9gmWuyICwVIG41IZ7k5HxTMSYEOf9Slsjr KwJ/PK+7+tSy8lWMfOUgWscWIR2B46+dMG4iWwiIp++muVdb4Ji5mW6oTduZsWjx FWDqnsFQYfhotiece5diB1wPU+5oyXNp2b7ifFUbaXxHMwjAUcJuNfHbFRTbT1Df w5DaufgKMZO/wpeJevHPj5v+uARnIQoc6OiidPd26HQ5l5iYtnXWyB8LO5vL/TNv OT4X2hL1ceQimg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id A171530600DC; Fri, 21 Aug 2020 03:31:22 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 05/25] efw-downloader: efw-proto: add class virtual method to handle responded signal Date: Fri, 21 Aug 2020 16:30:51 +0900 Message-Id: <20200821073111.134857-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" GObject allows applications to override class virtual method with own method implementation in inheritance. This commit adds the class virtual method to handle 'responded' signal added in the former commit. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/efw-proto.c | 2 +- efw-downloader/src/efw-proto.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index 6502957..72b7655 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -60,7 +60,7 @@ static void efw_proto_class_init(EfwProtoClass *klass) g_signal_new("responded", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, - 0, + G_STRUCT_OFFSET(EfwProtoClass, responded), NULL, NULL, efw_proto_sigs_marshal_VOID__ENUM_UINT_UINT_UINT_POINTER_UINT, G_TYPE_NONE, diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index fbd4366..fdbcbc8 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -34,6 +34,24 @@ struct _EfwProto { struct _EfwProtoClass { HinawaFwRespClass parent_class; + + /** + * EfwProtoClass::responded: + * @self: A #EfwProto. + * @status: One of #HinawaSndEfwStatus. + * @seqnum: The sequence number of response. + * @category: The value of category field in the response. + * @command: The value of command field in the response. + * @frame: (array length=frame_size)(element-type guint32): The array with elements for + * quadlet data of response for Echo Fireworks protocol. + * @frame_size: The number of elements of the array. + * + * When the unit transfers asynchronous packet as response for Fireworks protocol, and the + * process successfully reads the content of response from ALSA Fireworks driver, the + * #EfwProto::responded signal handler is called with parameters of the response. + */ + void (*responded)(EfwProto *self, HinawaSndEfwStatus status, guint seqnum, + guint category, guint command, const guint32 *frame, guint frame_size); }; EfwProto *efw_proto_new(); From patchwork Fri Aug 21 07:30:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728387 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C227722 for ; Fri, 21 Aug 2020 07:34:48 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2EAA22078D for ; Fri, 21 Aug 2020 07:34:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="C5k2Dt0R"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="NvyF0vRd"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="j0kiJ2uT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2EAA22078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7BB221670; Fri, 21 Aug 2020 09:34:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7BB221670 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995286; bh=eZaL1CatvTHWznqV742+LRhjRj4c5Mbt5WbqdEvo2Ck=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=C5k2Dt0RTY/iyr65YRHzTOlxTszyz3wh6nl6RQ9ddWUKtVfEDnnxt4z7uqMM0Ko2m U1ulqAlcgIZS8AT6yMrIUE8KL/W38W1/qaUJJAOcmfHp9W2R5TasXBcssSU4TG15iV P2sp3d5L3JxUXsiEgFPDgfv78ea1BXV3Qsl5Sh0Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D4753F802EA; Fri, 21 Aug 2020 09:31:44 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 199E1F802E9; Fri, 21 Aug 2020 09:31:41 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 72F36F80255 for ; Fri, 21 Aug 2020 09:31:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 72F36F80255 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="NvyF0vRd"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="j0kiJ2uT" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 1D2BB338; Fri, 21 Aug 2020 03:31:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=fA4cTsRV7fXvW LR7nLE/higt9EkmbireVuRQmBQEbV4=; b=NvyF0vRdyXSuFEmPsGN11VdEKQ2NB IGG31bfxGTP3iMtQxdfjlsrA6hcYk1IW+zWWetE5MdV+zN3yHTZ/bwX+4bFR/hzQ QRLu3maGFi+nJKn49lM7Chwu7w7UYrd082nIGzwV+6D0eakvmSaDhSS7xsV5KEIl GwO0llumUe7lC65Q/xbgvone0oRoJlQ6MwvcorRtym8DcOIFo+s5h2XqbjIIRVyG CzADA7q5uuZVe+L/5diKeFxxieBNzK+dor3xlqx6JJesvzCNSADLCIChoSQI3Oys PjP25kJl560IjjI0ptd60Tz70WwqF1xS6Y81CH0oxpziJRU+xCvZh9DDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=fA4cTsRV7fXvWLR7nLE/higt9EkmbireVuRQmBQEbV4=; b=j0kiJ2uT xNyfTfcJMfMBp9qm4S2K+nTufOKzpEeqEuVfgMwe0nDnq11p9QhQesY4p99EsjrY 0BvahsEZJ6+M15P8KRBzD7O8Jfg9NK/L2H2mWXJwJDpWBdB3RnyI8lcQoO+dq3S3 U3Jp92SnJaWjZNzD6chQP10QrM+utnLasHFImrUvyxeIRzeRmFVnV36SON6Y/CNx Nml/33CwKmjGOoZUrCXlC7P+I9Tqtuez+lcR++dc6yU6+hWXatdmR6paIoFqBWyF gsPsAt0x8n/uYY+oUt1dnYIGTZtTjeEpW3WbSjEiSBJDVAkeJ9rveVGwvXAU7JRu ffGCw420rto63A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 3BF2330600B4; Fri, 21 Aug 2020 03:31:23 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 06/25] efw-downloader: efw-proto: add instance private structure Date: Fri, 21 Aug 2020 16:30:52 +0900 Message-Id: <20200821073111.134857-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" GObject allows instance to have private data. This commit adds private structure to EfwProto instance. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/efw-proto.c | 17 ++++++++++++++++- efw-downloader/src/efw-proto.h | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index 72b7655..72959ac 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -15,7 +15,10 @@ * 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) +struct _EfwProtoPrivate { + guint32 *buf; +}; +G_DEFINE_TYPE_WITH_PRIVATE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) #define EFW_RESP_ADDR 0xecc080000000ull #define EFW_MAX_FRAME_SIZE 0x200u @@ -94,9 +97,16 @@ EfwProto *efw_proto_new() */ void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error) { + EfwProtoPrivate *priv; + g_return_if_fail(EFW_IS_PROTO(self)); + priv = efw_proto_get_instance_private(self); hinawa_fw_resp_reserve(HINAWA_FW_RESP(self), node, EFW_RESP_ADDR, EFW_MAX_FRAME_SIZE, error); + if (*error != NULL) + return; + + priv->buf = g_malloc0(EFW_MAX_FRAME_SIZE); } /** @@ -107,7 +117,12 @@ void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error) */ void efw_proto_unbind(EfwProto *self) { + EfwProtoPrivate *priv; + g_return_if_fail(EFW_IS_PROTO(self)); + priv = efw_proto_get_instance_private(self); hinawa_fw_resp_release(HINAWA_FW_RESP(self)); + + g_free(priv->buf); } diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index fdbcbc8..bc179dc 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -27,9 +27,12 @@ G_BEGIN_DECLS typedef struct _EfwProto EfwProto; typedef struct _EfwProtoClass EfwProtoClass; +typedef struct _EfwProtoPrivate EfwProtoPrivate; struct _EfwProto { HinawaFwResp parent_instance; + + EfwProtoPrivate *priv; }; struct _EfwProtoClass { From patchwork Fri Aug 21 07:30:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728401 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8527D1392 for ; Fri, 21 Aug 2020 07:36:40 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12024207DF for ; Fri, 21 Aug 2020 07:36:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="bI5OVkRq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="B8wYT3eY"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nRY9f26B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12024207DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 845711691; Fri, 21 Aug 2020 09:35:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 845711691 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995398; bh=1FNxYcdaZ2MqbmSfb6XXlvjUmLr5I0McuKwPUpDAQ68=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bI5OVkRq8uNqkneuHGn8fliNRE+6NbxARaLENHywy//uaa+d4dyH0Zyhk0VAHayJc 2pd4G46eXi3fPwzyMfVq8IA59BwvEB4ztYRzh3n5gUfgcYtRQqGatYemo682mJUaxb TPjVwiOFpcc/lDrhGFp5dIzWyh+ze5uZhFz+XVGc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 31974F80315; Fri, 21 Aug 2020 09:31:56 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id BEB30F802F9; Fri, 21 Aug 2020 09:31:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 65FBBF80260 for ; Fri, 21 Aug 2020 09:31:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 65FBBF80260 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="B8wYT3eY"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nRY9f26B" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id A29B22E3; Fri, 21 Aug 2020 03:31:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=CO1en39JIi6Uz AIoH2m+sP93P2k6nrsw1RLmt6kL1wY=; b=B8wYT3eYpaxIukigq8St4HKqRL/qM Ie1+EwmgzTbvejof6UdtHHDdLxpeHaziBfUM6WHvsDZMrf1bGgmwtZ09AYxnsTG4 NdziSwLkiyQEEjPuLIDT8THtBUvbpq4Y+Cl92O1fGUfHow3kRS/oJhAP/aRlw6HP iZ3nr1AjAnGL58+vFg0+sFEpVllyg9Ej/BnVjOzu2ZcBg+r057fSucT1ywEm/k51 M5J0ldcd/J3xQsdX/HQ2w8LTEsVEllk9/qqxLYOyTcJdSImFhxCO6KWE/0cJDlyJ ZUQ4S6nZ3WZ/x7ALhoVX1ZL1nCLefhJb3pz4WwdKY6ZXZBNhce+YsZ4ug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=CO1en39JIi6UzAIoH2m+sP93P2k6nrsw1RLmt6kL1wY=; b=nRY9f26B 3KrbdBHdoxGZNc3ZZC7cXW7sAlrzBptzYZl6/p3QIFoBC4btwxzV4G3lICSt1bl2 FpiOkg/Rw8b+mgXtR7ZTUV+gpKoOMLY8FjB76xDR4fVmrexagKBvyQ7NPmN391Vd Dh2/6VtXHD2zhpaTOSl8ZTZp6jao10mSLodbtMoZZT3DfgDuIJb/hCx1glGvk5bu l+2BUlsSng/f5U2/qm9iRc1lOxOruSjcfw4Fx33cj7UK2QT79SxbTWH3vw0vqqpZ NI7t/HEEukdSL8PtTwNrJfCpcxEOvEwBUc+xbJt2Lu8aZyM/acx2AeJV1X16lhkn +4WaCXLhyFVdQQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id EAAA830600B1; Fri, 21 Aug 2020 03:31:25 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 07/25] efw-downloader: efw-proto: emit responded signal at receiving response Date: Fri, 21 Aug 2020 16:30:53 +0900 Message-Id: <20200821073111.134857-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" HinawaFwResp has class virtual method for applications to handle received frame on 1394 OHCI controller by overriding the method with own function implementation. This commit overrides the class virtual method and emits 'responded' signal with the data of received response frame. The content of frame is aligned to host-endianness, then passed to signal handlers. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/efw-proto.c | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index 72959ac..bef81b3 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -3,6 +3,8 @@ #include "efw-proto.h" #include "efw-proto-sigs-marshal.h" +#include + /** * SECTION:efw_proto * @Title: EfwProto @@ -38,12 +40,16 @@ static void proto_finalize(GObject *obj) G_OBJECT_CLASS(efw_proto_parent_class)->finalize(obj); } +static HinawaFwRcode proto_handle_response(HinawaFwResp *resp, HinawaFwTcode tcode); + static void efw_proto_class_init(EfwProtoClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); gobject_class->finalize = proto_finalize; + HINAWA_FW_RESP_CLASS(klass)->requested = proto_handle_response; + /** * EfwProto::responded: * @self: A #EfwProto. @@ -126,3 +132,40 @@ void efw_proto_unbind(EfwProto *self) g_free(priv->buf); } + +static HinawaFwRcode proto_handle_response(HinawaFwResp *resp, HinawaFwTcode tcode) +{ + EfwProto *self = EFW_PROTO(resp); + EfwProtoPrivate *priv = efw_proto_get_instance_private(self); + const guint8 *req_frame = NULL; + gsize length = 0; + const struct snd_efw_transaction *frame; + guint status; + guint seqnum; + guint category; + guint command; + guint param_count; + int i; + + hinawa_fw_resp_get_req_frame(resp, &req_frame, &length); + if (length < sizeof(*frame)) + return HINAWA_FW_RCODE_DATA_ERROR; + frame = (const struct snd_efw_transaction *)req_frame; + + status = GUINT32_FROM_BE(frame->status); + if (status > HINAWA_SND_EFW_STATUS_BAD_PARAMETER) + status = HINAWA_SND_EFW_STATUS_BAD; + + seqnum = GUINT32_FROM_BE(frame->seqnum); + category = GUINT32_FROM_BE(frame->category); + command = GUINT32_FROM_BE(frame->command); + param_count = GUINT32_FROM_BE(frame->length) - sizeof(*frame) / sizeof(guint32); + + for (i = 0; i < param_count; ++i) + priv->buf[i] = GUINT32_FROM_BE(frame->params[i]); + + g_signal_emit(self, efw_proto_sigs[EFW_PROTO_SIG_TYPE_RESPONDED], 0, + status, seqnum, category, command, priv->buf, param_count); + + return HINAWA_FW_RCODE_COMPLETE; +} From patchwork Fri Aug 21 07:30:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728403 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 386681392 for ; Fri, 21 Aug 2020 07:37:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF96C207DF for ; Fri, 21 Aug 2020 07:37:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="fSpuX64O"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="OZYl7xPq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="usRBNots" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF96C207DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2CCF916A0; Fri, 21 Aug 2020 09:36:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2CCF916A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995439; bh=B11VIHrx2Cr0vmED2Icrqgcvqnif5YeQqF5gQGwUscc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fSpuX64OXLrsE7p3KjosejLFKadm8khc1OynRKw6cCK1aeN+BRjS2/Oh8GcWaT/ED T2u2o8TQQMCwjQGj6zf6qNj4iFZBxpyY047VbUBDeZ9kNZ5Wvk4oz31IR4fMveqo2I GEdmLK1sRuS5od/mAWfC1xbMAItEakv/UQISKFoc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 508FEF80317; Fri, 21 Aug 2020 09:32:00 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1EC47F80303; Fri, 21 Aug 2020 09:31:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F14FCF80257 for ; Fri, 21 Aug 2020 09:31:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F14FCF80257 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="OZYl7xPq"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="usRBNots" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 2AB66353; Fri, 21 Aug 2020 03:31:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=Esvn1uBkEGqFy 4AR844sK6dGLVtVJaEX7qo7Vmz95ig=; b=OZYl7xPqAqFBIW1GJ1VyHwcz9JMZd CxLpOHtXo/KubAQV7Apq2/ImqWeWfKJlBdZi1QwIw7hB+M50KstuPdll51H2ZLCM jwYp2Q2avrWgQvQlzc9OpJJ3u99FoNJ7WwIu8JnNj4bc/gE+wjQ7KxE9l9dws9kH 9nwvde+S2BRbWxxNA6F1++q3gtruMB9km44KBXtpRWFmB1ZG/aPWsYuX6KVYUxrm +hGo6Gy8n5oBDn0JasTSSraw0wi6JK1CiXV8B/Rg/KAgIHr66kiCQIYAzqPXSUGe QZvsy51/sykQxVTcrwsgyBBVDet+QYNxF9uGxP0z6M/BByzTy6xczjaXQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=Esvn1uBkEGqFy4AR844sK6dGLVtVJaEX7qo7Vmz95ig=; b=usRBNots 7lMuBJi9+vLH5w6KOr/JKiAy76tHxOBzmXs65MeJvOPM7L3TV+HeaCpVI1aA6b5q vGQKdxMInfQSvzk0r85xTGxOMLEuzsoANltogt1iOSRVhWV0rPI+jEnL1QO5bCft wCp11piOnZ9aPCzSrd/1ATyV001JJxCSjf3ei/WgcTTDZWCVFvL1xWop7XSDWiST wxkY0xPOJlUmm3KrzozzHvxzJn9aAJpNCwPXMDevKQu4ruHdj1AOVryg0ZN+xrdz TEilEAZwRndlp9DY3ro64HaGygn1gBlEIY51XssZVf21x7Vxir9qprBnYYXV0Nhn ZjPLhH0Ao3P/iw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 7479230600B4; Fri, 21 Aug 2020 03:31:27 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 08/25] efw-downloader: efw-proto: add function to finish transaction for command frame Date: Fri, 21 Aug 2020 16:30:54 +0900 Message-Id: <20200821073111.134857-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" In Fireworks protocol, asynchronous transaction is used to deliver command frame from software to device. The transaction is done to offset 0xecc000000000 with variable length of data up to 0x200. The transaction includes header and data in its payload. The header includes sequence field. The target device increments the value of sequence field, then transfers response frame with the value so that software can correspond the response frame with command frame according to the sequence numbers. The header also includes version field but version 1 is always used as long as I investigate. The header includes category and command field to determine the type of data. The status field is used to report operation result from the target device. This commit adds a function to finish transaction for command frame. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/efw-proto.c | 86 +++++++++++++++++++++++++++++++++- efw-downloader/src/efw-proto.h | 4 ++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index bef81b3..cb8dad1 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -5,6 +5,8 @@ #include +#include + /** * SECTION:efw_proto * @Title: EfwProto @@ -19,11 +21,16 @@ */ struct _EfwProtoPrivate { guint32 *buf; + guint32 seqnum; + HinawaFwNode *node; + GMutex mutex; }; G_DEFINE_TYPE_WITH_PRIVATE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) +#define EFW_CMD_ADDR 0xecc000000000ull #define EFW_RESP_ADDR 0xecc080000000ull #define EFW_MAX_FRAME_SIZE 0x200u +#define MINIMUM_VERSION 1 enum efw_proto_sig_type { EFW_PROTO_SIG_TYPE_RESPONDED = 1, @@ -34,9 +41,12 @@ static guint efw_proto_sigs[EFW_PROTO_SIG_COUNT] = { 0 }; static void proto_finalize(GObject *obj) { EfwProto *self = EFW_PROTO(obj); + EfwProtoPrivate *priv = efw_proto_get_instance_private(self); efw_proto_unbind(self); + g_mutex_clear(&priv->mutex); + G_OBJECT_CLASS(efw_proto_parent_class)->finalize(obj); } @@ -78,7 +88,10 @@ static void efw_proto_class_init(EfwProtoClass *klass) static void efw_proto_init(EfwProto *self) { - return; + EfwProtoPrivate *priv = efw_proto_get_instance_private(self); + + priv->seqnum = 0; + g_mutex_init(&priv->mutex); } /** @@ -113,6 +126,7 @@ void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error) return; priv->buf = g_malloc0(EFW_MAX_FRAME_SIZE); + priv->node = node; } /** @@ -131,6 +145,76 @@ void efw_proto_unbind(EfwProto *self) hinawa_fw_resp_release(HINAWA_FW_RESP(self)); g_free(priv->buf); + priv->buf = NULL; + priv->node = NULL; +} + +/** + * efw_proto_command: + * @self: A #EfwProto. + * @category: One of category for the transaction. + * @command: One of category for the transaction. + * @args: (array length=arg_count)(nullable): An array with elements for quadlet data as arguments + * for command. + * @arg_count: The number of quadlets in the args array. + * @resp_seqnum: (out): The sequence number for response transaction. + * @error: A #GError. Error can be generated with two domains of #hinawa_fw_req_error_quark() and + * #hinawa_fw_req_error_quark(). + * + * Transfer asynchronous transaction for command frame of Fireworks protocol. When receiving + * asynchronous transaction for response frame, #EfwProto::responded GObject signal is emitted. + */ +void efw_proto_command(EfwProto *self, guint category, guint command, + const guint32 *args, gsize arg_count, guint32 *resp_seqnum, + GError **error) +{ + EfwProtoPrivate *priv; + HinawaFwReq *req; + gsize length; + struct snd_efw_transaction *frame; + int i; + + g_return_if_fail(EFW_IS_PROTO(self)); + g_return_if_fail(sizeof(*args) * arg_count + sizeof(*frame) < EFW_MAX_FRAME_SIZE); + g_return_if_fail(resp_seqnum != NULL); + g_return_if_fail(error == NULL || *error == NULL); + + priv = efw_proto_get_instance_private(self); + + length = sizeof(*frame); + if (args != NULL) + length += sizeof(guint32) * arg_count; + + frame = g_malloc0(length); + + // Fill request frame for transaction. + frame->length = GUINT32_TO_BE(length / sizeof(guint32)); + frame->version = GUINT32_TO_BE(MINIMUM_VERSION); + frame->category = GUINT32_TO_BE(category); + frame->command = GUINT32_TO_BE(command); + if (args != NULL) { + for (i = 0; i < arg_count; ++i) + frame->params[i] = GUINT32_TO_BE(args[i]); + } + + // Increment the sequence number for next transaction. + g_mutex_lock(&priv->mutex); + frame->seqnum = GUINT32_TO_BE(priv->seqnum); + *resp_seqnum = priv->seqnum + 1; + priv->seqnum += 2; + if (priv->seqnum > SND_EFW_TRANSACTION_USER_SEQNUM_MAX) + priv->seqnum = 0; + g_mutex_unlock(&priv->mutex); + + // Send this request frame. + req = hinawa_fw_req_new(); + + hinawa_fw_req_transaction_sync(req, priv->node, HINAWA_FW_TCODE_WRITE_BLOCK_REQUEST, + EFW_CMD_ADDR, length, (guint8 *const *)&frame, &length, 100, + error); + + g_object_unref(req); + g_free(frame); } static HinawaFwRcode proto_handle_response(HinawaFwResp *resp, HinawaFwTcode tcode) diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index bc179dc..94f4a94 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -62,6 +62,10 @@ EfwProto *efw_proto_new(); void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error); void efw_proto_unbind(EfwProto *self); +void efw_proto_command(EfwProto *self, guint category, guint command, + const guint32 *args, gsize arg_count, guint32 *resp_seqnum, + GError **exception); + G_END_DECLS #endif From patchwork Fri Aug 21 07:30:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728415 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 913FD739 for ; Fri, 21 Aug 2020 07:39:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25E452087D for ; Fri, 21 Aug 2020 07:39:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="KPeyvC2v"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="FcD/Hq7E"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="aWbF0+gK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25E452087D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A2656169B; Fri, 21 Aug 2020 09:38:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A2656169B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995538; bh=epR7CdKBZXBADdEE9REyiu7QqwCEY2gX6F329SgrVwM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KPeyvC2vqqBmJm00j2IdgL3vMYCExUFq5XcMleRQPW+L8W+74S6Unxb2DK6e7UQ5y Vzbb/frPk/Dn5veWXXedyQT7fDwa/LcI5ox+CFO1CctGDvIYh1IfYXMnXlrNcpxFnv c07s9fQ6RSaVsu4hipFo0KWHP9bDqvSJmiY5kKXg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AA102F80338; Fri, 21 Aug 2020 09:32:05 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id DC862F802DD; Fri, 21 Aug 2020 09:31:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9A3C1F802C2 for ; Fri, 21 Aug 2020 09:31:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9A3C1F802C2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="FcD/Hq7E"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="aWbF0+gK" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id B246B880; Fri, 21 Aug 2020 03:31:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=k7p0I/ezfZWct IEf1zoQCaRp1KXbmMCKv61+Y5rS6fc=; b=FcD/Hq7Ee75//GOkmL+Up0Yc+pdsv rXVFBrH81I+oGDOpvB4IYwA9bxhMkMcDNLSQ71iaxrnMeGD/kWrbkmWruz+PnlcF yxKNOFXFozbw4cTCM6kH7GVzI/Xhn/aZTSiRnomvu0A+Sok/CbI4pRbQEwv33hVI IvBmwN45e9xmdLaqyAGjwqzt0IZiRTtMF7aSskjWn014H0kL7ni9DfDDGaRIvtra /ISqVMahrD6enMj0azOGmGHpOrsxImfDAyI6wCOT2cCOfW+6eEn+6V835p9pGv1M UmHorCDu6HD2oVjO6mPG+weAPvcN2FZgKish05Z23QI2zshUOxm9KLEtg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=k7p0I/ezfZWctIEf1zoQCaRp1KXbmMCKv61+Y5rS6fc=; b=aWbF0+gK w6Csdq7E/2Sv44fENXkRpzDI8mFiZxUAnfmWvfdIsLB2IYxPFQfHKOP5sOqb+fqa cmxsn6XUxGoOXFsvvhOH+1vkdMl8oNj6IwoCkpa3JhRfycYe+hCF1E/vYQRKMUBb B5M3JiVqlRTSZ11xDhbViNQsqCHyfJDsXJchkJMGmtq5rvzrFHUOjTYpXc6O/Rm9 9OjHLJ2/RPbPzZL1giBTynjTQgNcbyWmQ+grBNLMuuuH5FcNWMDncabfC7oS1MNu 0ZoVeWnrzdVruTfSz6qy4FrxxaTCYiy+bA5djc+n3k8q+UIf5jOUPN/lbfK40Hon fEuEGQmYIbVjZQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 2D2D630600B7; Fri, 21 Aug 2020 03:31:28 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 09/25] efw-downloader: efw-proto: add function to finish a pair of transactions Date: Fri, 21 Aug 2020 16:30:55 +0900 Message-Id: <20200821073111.134857-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" In Fireworks protocol, the target device increments sequence number in command frame transferred by software, then transfers response frame with the number so that software can correspond the response frame to the command frame. This commit adds function to finish the pair of transactions for command and response frames. The frames are matched according to sequence number. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/efw-proto.c | 146 +++++++++++++++++++++++++++++++++ efw-downloader/src/efw-proto.h | 9 ++ 2 files changed, 155 insertions(+) diff --git a/efw-downloader/src/efw-proto.c b/efw-downloader/src/efw-proto.c index cb8dad1..f8c1d88 100644 --- a/efw-downloader/src/efw-proto.c +++ b/efw-downloader/src/efw-proto.c @@ -27,6 +27,15 @@ struct _EfwProtoPrivate { }; G_DEFINE_TYPE_WITH_PRIVATE(EfwProto, efw_proto, HINAWA_TYPE_FW_RESP) +/** + * efw_proto_error_quark: + * + * Return the GQuark for error domain of GError which has code in #HinawaSndEfwStatus. + * + * Returns: A #GQuark. + */ +G_DEFINE_QUARK(efw-proto-error-quark, efw_proto_error) + #define EFW_CMD_ADDR 0xecc000000000ull #define EFW_RESP_ADDR 0xecc080000000ull #define EFW_MAX_FRAME_SIZE 0x200u @@ -217,6 +226,143 @@ void efw_proto_command(EfwProto *self, guint category, guint command, g_free(frame); } +struct waiter { + guint32 seqnum; + + guint32 category; + guint32 command; + HinawaSndEfwStatus status; + guint32 *params; + gsize param_count; + + GCond cond; + GMutex mutex; +}; + +static void handle_responded_signal(EfwProto *self, HinawaSndEfwStatus status, guint32 seqnum, + guint category, guint command, + const guint32 *params, guint32 param_count, gpointer user_data) +{ + struct waiter *w = (struct waiter *)user_data; + + if (seqnum == w->seqnum) { + g_mutex_lock(&w->mutex); + + if (category != w->category || command != w->command) + status = HINAWA_SND_EFW_STATUS_BAD; + w->status = status; + + if (param_count > 0 && param_count <= w->param_count) + memcpy(w->params, params, param_count * sizeof(*params)); + w->param_count = param_count; + + g_cond_signal(&w->cond); + + g_mutex_unlock(&w->mutex); + } +} + +static const char *const err_msgs[] = { + [HINAWA_SND_EFW_STATUS_OK] = "The transaction finishes successfully", + [HINAWA_SND_EFW_STATUS_BAD] = "The request or response includes invalid header", + [HINAWA_SND_EFW_STATUS_BAD_COMMAND] = "The request includes invalid category or command", + [HINAWA_SND_EFW_STATUS_COMM_ERR] = "The transaction fails due to communication error", + [HINAWA_SND_EFW_STATUS_BAD_QUAD_COUNT] = "The number of quadlets in transaction is invalid", + [HINAWA_SND_EFW_STATUS_UNSUPPORTED] = "The request is not supported", + [HINAWA_SND_EFW_STATUS_TIMEOUT] = "The transaction is canceled due to response timeout", + [HINAWA_SND_EFW_STATUS_DSP_TIMEOUT] = "The operation for DSP did not finish within timeout", + [HINAWA_SND_EFW_STATUS_BAD_RATE] = "The request includes invalid value for sampling frequency", + [HINAWA_SND_EFW_STATUS_BAD_CLOCK] = "The request includes invalid value for source of clock", + [HINAWA_SND_EFW_STATUS_BAD_CHANNEL] = "The request includes invalid value for the number of channel", + [HINAWA_SND_EFW_STATUS_BAD_PAN] = "The request includes invalid value for panning", + [HINAWA_SND_EFW_STATUS_FLASH_BUSY] = "The on-board flash is busy and not operable", + [HINAWA_SND_EFW_STATUS_BAD_MIRROR] = "The request includes invalid value for mirroring channel", + [HINAWA_SND_EFW_STATUS_BAD_LED] = "The request includes invalid value for LED", + [HINAWA_SND_EFW_STATUS_BAD_PARAMETER] = "The request includes invalid value of parameter", + [HINAWA_SND_EFW_STATUS_LARGE_RESP] = "The size of response is larger than expected", +}; + +#define generate_error(error, code) \ + g_set_error_literal(error, EFW_PROTO_ERROR, code, err_msgs[code]) + +/** + * efw_proto_transaction: + * @self: A #EfwProto. + * @category: One of category for the transaction. + * @command: One of category for the transaction. + * @args: (array length=arg_count)(nullable): An array with elements for quadlet data as arguments + * for command. + * @arg_count: The number of quadlets in the args array. + * @params: (array length=param_count)(inout)(nullable): An array with elements for quadlet data to + * save parameters in response frame. + * @param_count: The number of quadlets in the params array. + * @timeout_ms: The timeout to wait for response of the transaction since request is initiated, in + * milliseconds. + * @error: A #GError. Error can be generated with two domains of #hinawa_fw_node_error_quark(), + * #hinawa_fw_req_error_quark(), and #efw_proto_error_quark(). + * + * Transfer asynchronous transaction for command frame of Fireworks protocol. When receiving + * asynchronous transaction for response frame, #EfwProto::responded GObject signal is emitted. + */ +void efw_proto_transaction(EfwProto *self, guint category, guint command, + const guint32 *args, gsize arg_count, + guint32 *const *params, gsize *param_count, + guint timeout_ms, GError **error) +{ + gulong handler_id; + struct waiter w; + guint64 expiration; + + g_return_if_fail(EFW_IS_PROTO(self)); + g_return_if_fail(param_count != NULL); + g_return_if_fail(error == NULL || *error == NULL); + + // This predicates against suprious wakeup. + w.status = 0xffffffff; + w.category = category; + w.command = command; + if (*param_count > 0) + w.params = *params; + else + w.params = NULL; + w.param_count = *param_count; + g_cond_init(&w.cond); + g_mutex_init(&w.mutex); + + handler_id = g_signal_connect(self, "responded", (GCallback)handle_responded_signal, &w); + + // Timeout is set in advance as a parameter of this object. + expiration = g_get_monotonic_time() + timeout_ms * G_TIME_SPAN_MILLISECOND; + + efw_proto_command(self, category, command, args, arg_count, &w.seqnum, error); + if (*error != NULL) { + g_signal_handler_disconnect(self, handler_id); + goto end; + } + + g_mutex_lock(&w.mutex); + while (w.status == 0xffffffff) { + // Wait for a response with timeout, waken by the response handler. + if (!g_cond_wait_until(&w.cond, &w.mutex, expiration)) + break; + } + g_signal_handler_disconnect(self, handler_id); + g_mutex_unlock(&w.mutex); + + if (w.status == 0xffffffff) + generate_error(error, HINAWA_SND_EFW_STATUS_TIMEOUT); + else if (w.status != HINAWA_SND_EFW_STATUS_OK) + generate_error(error, w.status); + else if (w.param_count > *param_count) + generate_error(error, HINAWA_SND_EFW_STATUS_LARGE_RESP); + else + *param_count = w.param_count; +end: + g_cond_clear(&w.cond); + g_mutex_clear(&w.mutex); +} + + static HinawaFwRcode proto_handle_response(HinawaFwResp *resp, HinawaFwTcode tcode) { EfwProto *self = EFW_PROTO(resp); diff --git a/efw-downloader/src/efw-proto.h b/efw-downloader/src/efw-proto.h index 94f4a94..0b700a8 100644 --- a/efw-downloader/src/efw-proto.h +++ b/efw-downloader/src/efw-proto.h @@ -57,6 +57,10 @@ struct _EfwProtoClass { guint category, guint command, const guint32 *frame, guint frame_size); }; +#define EFW_PROTO_ERROR efw_proto_error_quark() + +GQuark efw_proto_error_quark(); + EfwProto *efw_proto_new(); void efw_proto_bind(EfwProto *self, HinawaFwNode *node, GError **error); @@ -66,6 +70,11 @@ void efw_proto_command(EfwProto *self, guint category, guint command, const guint32 *args, gsize arg_count, guint32 *resp_seqnum, GError **exception); +void efw_proto_transaction(EfwProto *self, guint category, guint command, + const guint32 *args, gsize arg_count, + guint32 *const *params, gsize *param_count, + guint timeout_ms, GError **error); + G_END_DECLS #endif From patchwork Fri Aug 21 07:30:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728409 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1976739 for ; Fri, 21 Aug 2020 07:38:19 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37D672078D for ; Fri, 21 Aug 2020 07:38:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="UZaJugyV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="jzzAi2Rc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="tg/bXBPn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37D672078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BD0A8167C; Fri, 21 Aug 2020 09:37:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BD0A8167C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995497; bh=Un9gcCkuhjkfDslARqhayeEeecn/Amxz9mQCFQ8OTl0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UZaJugyVpujVhM+1TjRGE2lMButpcPGoj5K/jjo62xVMpcZOOQwjhKSvDBqVB+3S1 hoSLpJHQmZZdJQ/38POwPIkU+84QryW4WLvtJGjKxHIL5tOsooNkfmsQkd1d8fY8Fg KhJhYN7e04+iyx6lAcpD58d0VJ1cI3/gdXIARtRI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7FEDCF80334; Fri, 21 Aug 2020 09:32:03 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id A9051F80303; Fri, 21 Aug 2020 09:31:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9F50AF802DC for ; Fri, 21 Aug 2020 09:31:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9F50AF802DC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="jzzAi2Rc"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="tg/bXBPn" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id B90B135B; Fri, 21 Aug 2020 03:31:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=4IJgN3kapfojz XX3lCjkvMyQ0pm2+CwQAbJceSsrHTc=; b=jzzAi2RcyWOL/WdgnUeKepPgQvIoQ pbTs86YEVzCV+ZklXb3uwQ5E2aafdvgr3o6wYpgXTUeYWRsRqL6gmpPJOm0t6rCf Jn9ySuMqXQaHU4g9wKkRaNRdW1DQRSE8TgnYNjsO5SDdmT6bSwh5bgc9+qOxTF4L wdJIpbGw0JTROMDm6isckm5QPtEbGtbOR5kQDHSoWizUFR6NXumAVmM+cVzAwosp WplLJed9RVSLTpdeGudEhQmP+brWMvfc1vVBC37/v1pCLP5eNpruSOS8jvy2yvd8 dmbgHE7y9Bu0dcvDN17cO5SmIQY1hqyYzB6AHsie0jPlcmd6NNcnsLmRA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=4IJgN3kapfojzXX3lCjkvMyQ0pm2+CwQAbJceSsrHTc=; b=tg/bXBPn +c/g2tiwKWX3xbTvh5R8nYlziQM0gPaQjKTSfLoDZE+oA40hRpjzVJscHClxTAiu X5i03T7dov8aLwo5l5Df+S9WCFYRSWJve1M+CwrM9jkogNiIw4gUndHYQ6+hT/aM COSSMsZJzjUuW6yeztdUIvlnUHDZ5tJ3+9ocd/HUHKaOlVjaONbpyYN828wHklSl iNGlDam1IM8K4/MzyQ8lljzaF35+uL60g5IEZSxzSTJWVuACwHAsD6bekIxixulR c8/WiAMEKOycSI7VvQO81B9SBHfxORjMoRyVzCIrfQny3munBNlynx+rK/r+GTfg jEiTZG1M5Ajukw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepkeenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id E097D30600B1; Fri, 21 Aug 2020 03:31:31 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 10/25] efw-downloader: add parser for sub commands Date: Fri, 21 Aug 2020 16:30:56 +0900 Message-Id: <20200821073111.134857-11-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This tool consists of sub commands for different functionalities. This commit adds parser for sub commands. Actual implementation for each sub command will be added in future commits. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/main.c | 42 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/efw-downloader/src/main.c b/efw-downloader/src/main.c index 31ac349..499e67e 100644 --- a/efw-downloader/src/main.c +++ b/efw-downloader/src/main.c @@ -1,8 +1,48 @@ // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (c) 2020 Takashi Sakamoto +#include #include +#include + +static void print_help() +{ + printf("Usage\n" + " efw-downloader SUBCOMMAND OPTIONS\n" + "\n" + "where:\n" + " SUBCOMMAND:\n" + " help: print help\n" + " OPTIONS: optional arguments dependent on the subcommand\n"); +} int main(int argc, char **argv) { - return EXIT_SUCCESS; + static const struct { + const char *name; + size_t size; + int (*op)(int argc, char **argv); + } *entry, entries[] = { + }; + const char *subcmd; + int i; + + if (argc < 2) { + print_help(); + return EXIT_FAILURE; + } + subcmd = argv[1]; + + for (i = 0; i < sizeof(entries) / sizeof(entries[0]); ++i) { + entry = entries + i; + if (strncmp(subcmd, entry->name, entry->size) == 0) { + entry = &entries[i]; + break; + } + } + if (i == sizeof(entries) / sizeof(entries[0])) { + print_help(); + return EXIT_FAILURE; + } + + return entry->op(argc, argv); } From patchwork Fri Aug 21 07:30:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32F651392 for ; Fri, 21 Aug 2020 07:38:03 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9BA02078D for ; Fri, 21 Aug 2020 07:38:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="vanOkEpI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="ArKOieeD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="M+HstCdl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9BA02078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 043FD83D; Fri, 21 Aug 2020 09:37:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 043FD83D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995481; bh=JvandNNP245hzJHkq7tZRYkB6WPc6xjhvjL517RrU9g=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vanOkEpIHD24gYY3m4H9LfEunl/ZHHSnV4sx2VU3qkAD3XnviXbWevx3uvAWSOXsP Gi1D1C72rpkkjJsbadlTEsAyWYgiof08n8z2BioGImuammsLfo2Tj4LrBq/4Hi2Dh/ aWe/lxyyVXO85gmlIKeF6xDcUnPhJZg0uFET9wno= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D061BF8032A; Fri, 21 Aug 2020 09:32:01 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3415BF802DD; Fri, 21 Aug 2020 09:31:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 569AEF802DD for ; Fri, 21 Aug 2020 09:31:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 569AEF802DD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="ArKOieeD"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="M+HstCdl" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 87F0E89D; Fri, 21 Aug 2020 03:31:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=nCeOuln1DQD8W hM5ui/6o3n/TLutmQMHIgbn/AwpBX8=; b=ArKOieeDXhGrykTrk76UZR9P//hbU S5lOJIfoKX7aNC0T9nwnNSx44d3NN6BP+33/ZN+jQkAD0AhK/XKX48sdrIC8Dv0V g2NN6C9Rs6qsv2klnf+JfMoOEKCrn6nzHyM1dF/Sh5z2dBcoIGXAC2JYCJXgnVUd zqEXDrlJbA2ewJcpeatIfHtqkZC2ovV1mu8uuk8PD2XrLCsqhTdmW5fIjE0yGXM0 SrLV5z2Ayx7sscNvIVERxOmEZFv5bB/3iym6acRVxyl4fsu/R5kI9HYvvyDHB+bk iEltHmDVzxgGr/2UioTMH2r+36NFUHCOGZsFh2yXUcLUlLc+R1E+yAZuQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=nCeOuln1DQD8WhM5ui/6o3n/TLutmQMHIgbn/AwpBX8=; b=M+HstCdl 529xK2yDkX3AAnH0Td6I5X1YnHVS6u6axj5JO5MK67Qnt8lXj5OjT49zZXi02i7r wP9He2RM6l43TJglCibW+1S2p9AeuJaE7/xcnddkp+39VvkgZwL4na+uSkEr7QdD M0jvLwqOjgCQhdrQDZdp2P3mJnP+Lt5x77kZ9LAxRpJfcAeHtd0Kz4JPtpUPH0fH QoM2+iueGuDKEXNHdmtrhX1Z2ZkH9B0L8pg98wwwvvbE1QePUfm4lc5L+pJBm4BU BnI07RfL9RfDi79QI/7btuD4JGMXrHB5RrErXkTO791LawRWwFTI54+jnWQkBJfl dR6WpewIBIR6tQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepkeenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id A42653060272; Fri, 21 Aug 2020 03:31:33 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 11/25] efw-downloader: subcmd-device: implement 'device' sub command to operate actual device Date: Fri, 21 Aug 2020 16:30:57 +0900 Message-Id: <20200821073111.134857-12-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit implements 'device' sub command to operate the target device. This sub command consists of several operations and parser for the operation will be implemented in future commits. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/main.c | 4 ++ efw-downloader/src/meson.build | 2 + efw-downloader/src/subcmd-device.c | 77 ++++++++++++++++++++++++++++++ efw-downloader/src/subcmds.h | 8 ++++ 4 files changed, 91 insertions(+) create mode 100644 efw-downloader/src/subcmd-device.c create mode 100644 efw-downloader/src/subcmds.h diff --git a/efw-downloader/src/main.c b/efw-downloader/src/main.c index 499e67e..e150cc8 100644 --- a/efw-downloader/src/main.c +++ b/efw-downloader/src/main.c @@ -4,6 +4,8 @@ #include #include +#include "subcmds.h" + static void print_help() { printf("Usage\n" @@ -11,6 +13,7 @@ static void print_help() "\n" "where:\n" " SUBCOMMAND:\n" + " device: operate for device for unit on IEEE 1394 bus\n" " help: print help\n" " OPTIONS: optional arguments dependent on the subcommand\n"); } @@ -22,6 +25,7 @@ int main(int argc, char **argv) size_t size; int (*op)(int argc, char **argv); } *entry, entries[] = { + { "device", sizeof("device"), subcmd_device }, }; const char *subcmd; int i; diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index ca894d9..07a6182 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -14,10 +14,12 @@ hinawa = dependency('hinawa', sources = [ 'main.c', 'efw-proto.c', + 'subcmd-device.c', ] headers = [ 'efw-proto.h', + 'subcmds.h', ] gnome = import('gnome') diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c new file mode 100644 index 0000000..739944e --- /dev/null +++ b/efw-downloader/src/subcmd-device.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include +#include +#include +#include + +#include "efw-proto.h" + +static int print_help() +{ + printf("Usage\n" + " efw-downloader device CDEV OPERATION ARGUMENTS\n" + "\n" + "where:\n" + " CDEV: The firewire character device corresponding to the node for transaction\n" + " OPERATION:\n" + " help: print this help message\n" + " ARGUMENTS:\n" + " depending on OPERATION\n" + "\n"); + return EXIT_FAILURE; +} + +static int parse_args(int argc, char **argv, const char **path, const char **op_name) +{ + if (argc < 2) + return -EINVAL; + assert(strncmp(argv[1], "device", sizeof("device")) == 0); + + if (argc < 3) + return -EINVAL; + *path = argv[2]; + + if (argc < 4) + return -EINVAL; + *op_name = argv[3]; + + return 0; +} + +int subcmd_device(int argc, char **argv) +{ + struct { + const char *name; + size_t size; + void (*op)(int argc, char **argv, EfwProto *proto, GError **error); + } *entry, entries[] = { + }; + GError *error = NULL; + const char *path; + const char *op_name; + EfwProto *proto; + int err; + int i; + + err = parse_args(argc, argv, &path, &op_name); + if (err < 0) + return print_help(0, NULL, NULL, NULL); + + for (i = 0; i < G_N_ELEMENTS(entries); ++i) { + entry = entries + i; + if (strncmp(op_name, entry->name, entry->size) == 0) + break; + } + if (i == G_N_ELEMENTS(entries)) + return print_help(); + + entry->op(argc, argv, proto, &error); + + if (error != NULL) { + g_clear_error(&error); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/efw-downloader/src/subcmds.h b/efw-downloader/src/subcmds.h new file mode 100644 index 0000000..f10c420 --- /dev/null +++ b/efw-downloader/src/subcmds.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __SUBCMDS_H__ +#define __SUBCMDS_H__ + +int subcmd_device(int argc, char **argv); + +#endif From patchwork Fri Aug 21 07:30:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB0DD739 for ; Fri, 21 Aug 2020 07:39:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 59EF22078D for ; Fri, 21 Aug 2020 07:39:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="GhIBXLtJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="LWkUCJWm"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AtKxHcXU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59EF22078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E1CE9169A; Fri, 21 Aug 2020 09:39:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E1CE9169A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995590; bh=EKIKsc8vlf/RDEl9LA+TfayqGKAGbb//XfIH5hFFcn4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GhIBXLtJecpA1vt95kEDFuCIhJ8qa73ANxgttzNHPH2kmMiVMq52mk4RWsZsOhlHW Wd6n1RR3pmiFeKoKSknDsGekP2m1wDAmspOAdX68zugxUnJvJCfUnUc7LdGkFkvXxm tK4UEndcagClJ9pSl9sVhph/JFSNqHVp84QZCtiA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 69B96F80344; Fri, 21 Aug 2020 09:32:14 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 847B0F80305; Fri, 21 Aug 2020 09:31:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E11F5F802E8 for ; Fri, 21 Aug 2020 09:31:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E11F5F802E8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="LWkUCJWm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AtKxHcXU" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 19203891; Fri, 21 Aug 2020 03:31:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=7fM+qijIwANP7 giKcnjmRQFWV/rTRfKbQ0qtthdRPyY=; b=LWkUCJWmDxfsEbuegYaTTHKjOST3f 3wXxuJH3RxbO0TJsEQ5dhm1/dDDLs8P4xPBXeuWg8SU7T4eJLafeYEII/vG/j0jt XmJZK/z1xwizq2x74yXbL8WXLH/TSGNjlHkQWze5DnwVq64Ld0Nht4UARKRPgBRq zJYz36XJfOD4Q5CCRnJNnHDKqKxyUo52uf4JgbkttHXKyoxAufhSAP9gtLMyMBkg 1yvzzYq7B9E8Cm4+nIFbL+GxeLXzuGs6gbdhLa2UhimkpR1sk5lHIB8wxaDaEd2y I6JGP7Sg/6X271TX/2WuR4/Vw/TU5o5gqBeYFXL1vdXCE1GBvTXkVvNhw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=7fM+qijIwANP7giKcnjmRQFWV/rTRfKbQ0qtthdRPyY=; b=AtKxHcXU KAEQkEhF8Uwl4z2/AhJH+Sis5RCfvjjv0wqmp/i8xD4muJq8JE8eRwyBNIBViTPu vfS+ZP1Xob7WSICC7S3q4UfcyVp/2MEGaErhsPWOakizf8MyAxvb1KvqVNQhHCbM +nJDnXGPosGIgTjxoKn1nABkRXSDbVoHWj2QctSARbmF+TPQlRjoMvMdU+Eh4U6l p+KHz+mfFk5FQiiaWpO3iaJfhSSRa8ZLYrbdmje1Ny34lx3rpu1iggFxNcGMXtod m4aPWQ/b8W1ylkgCopfxyV2Die8oukuJjL4h32C6xVYZJNvPNzbRZREWtBVUL6f+ dYTciC4amJhE9A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepkeenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 5AEF230600B4; Fri, 21 Aug 2020 03:31:35 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 12/25] efw-downloader: subcmd-device: open firewire character device by HinawaFwNode Date: Fri, 21 Aug 2020 16:30:58 +0900 Message-Id: <20200821073111.134857-13-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" In device sub command, all of operations require actual communication to the target device. Linux firewire subsystem allows applications to do it via call of ioctl to firewire character device. This commit opens firewire character device, with assist of HinawaFwNode. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/subcmd-device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index 739944e..e1be025 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -7,6 +7,10 @@ #include "efw-proto.h" +#define report_error(error, msg) \ + fprintf(stderr, "Fail to %s: %s %d %s\n", \ + msg, g_quark_to_string(error->domain), error->code, error->message) + static int print_help() { printf("Usage\n" @@ -50,6 +54,7 @@ int subcmd_device(int argc, char **argv) GError *error = NULL; const char *path; const char *op_name; + HinawaFwNode *node; EfwProto *proto; int err; int i; @@ -66,8 +71,22 @@ int subcmd_device(int argc, char **argv) if (i == G_N_ELEMENTS(entries)) return print_help(); + node = hinawa_fw_node_new(); + hinawa_fw_node_open(node, path, &error); + if (error != NULL) { + if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) + fprintf(stderr, "File not found: %s\n", path); + else if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_ACCES)) + fprintf(stderr, "Permission denied: %s\n", path); + else + report_error(error, "open the node"); + goto err; + } + entry->op(argc, argv, proto, &error); + g_object_unref(node); +err: if (error != NULL) { g_clear_error(&error); return EXIT_FAILURE; From patchwork Fri Aug 21 07:30:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 97CA61575 for ; Fri, 21 Aug 2020 07:40:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2AA1921775 for ; Fri, 21 Aug 2020 07:40:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="sveMEO2Y"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="LPes8KDf"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ErGjARVK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2AA1921775 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B33E416A9; Fri, 21 Aug 2020 09:40:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B33E416A9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995645; bh=GXx1jp7kxwc0AJl58yY1WGSnCP664nmJaqeoKNNBLzk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sveMEO2Y91u2zpvseYvD6BcGJuI3bAvUGgl+Ve33tq0uMOEnMM27cezPBB/HX16M6 SIcjavKAXlKtO/OR7cGVwiy72t0hcKNWMJUcpQVkFajsNjmr2jtgaWSqUMk9Z0ysdo XtnLqJuvY8TwPP1PnZrJ06zMB/2ofYsYZimsYLAM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CB541F8034D; Fri, 21 Aug 2020 09:32:18 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7024FF8031A; Fri, 21 Aug 2020 09:31:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7A92EF80253 for ; Fri, 21 Aug 2020 09:31:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7A92EF80253 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="LPes8KDf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ErGjARVK" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 9B40828A; Fri, 21 Aug 2020 03:31:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=/1kXJ5EnNWuIn wtKakugyFCNGf74wLBdhLPndyx0Y/U=; b=LPes8KDfjmyruabB85yX0dvMzPNes iZPHrqperUmeH+HNNgk3iwM5bAIxVpmXJSyax6mS68+42b5pryiix3gvfzWuAm5G uompRz3ZF5cH/xgDvujnRBE0nvYWfGo7B7VKLcdLC7nw+ABdtOYfUmWKLv1/Gzf2 OriP2zWAwWd7fJrM64WYqedvyCTPeMJD2ruskWpudjYx8VF2ZeYbeTJbwr4aHoJa ZZxqb9oPtLBO30JsOE1wf2DI0UD1fxoRM25IW9QZ4bXuHMZr3mpnxYSKpZnJsAs/ +8z4mwTQwR8ui8BGDhXJjcDV7TAROenkAjBJ/AbPjdPfFSzkDMlOSknuQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=/1kXJ5EnNWuInwtKakugyFCNGf74wLBdhLPndyx0Y/U=; b=ErGjARVK AQlJXljhuvw7JEI/B/REUPXTDOBfN9xQXKm8222OqMSAYiBdf6ffhV3KbZHqB+Ku L+PWpO43DYA+S2xcxVEAtJn+Chkaq6aMEPDw0j3jmOmciG2XtBD4WrrbD6T91ppG KWI1acU7ck3mHEm1jVKdtWhtQ6R+qgLVQScuKOmPaLad0q0xHtSCmlmPn8LAMPQq 9tKYSMvJIuYdnJGADOYkKR9W2fsjRvp0h/myqF2OEcgk5cuAV0trLHkPcTNp10lO CzMt+PXGsNloR2oBKBysb2z0GmismbwZ34a9w/0QGxTpoLwxMpCzmImFG+kwkEMk 5bBW3wlWKxCrWw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepkeenucfrrghrrghmpehmrg hilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id DC26A30600B1; Fri, 21 Aug 2020 03:31:36 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 13/25] efw-downloader: config-rom: parse config rom to detect supported device Date: Fri, 21 Aug 2020 16:30:59 +0900 Message-Id: <20200821073111.134857-14-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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 --- 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 + +#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', ] From patchwork Fri Aug 21 07:31:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728515 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8186B1392 for ; Fri, 21 Aug 2020 07:41:30 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 188462078D for ; Fri, 21 Aug 2020 07:41:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="qiPeW5Af"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="OUlZJHhi"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IkHv2Ous" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 188462078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 98416168D; Fri, 21 Aug 2020 09:40:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 98416168D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995688; bh=iLpf9j3bHT8tVO3YogU0k313skhdEyHAAGgtsoCaLYU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qiPeW5AfzBYUWTfZV6n1Drp8BP3ztx57e7nWSByZ4v2GImDjC7+8HSyyfoV3coQMJ we/FK+oJXz32Mk2DdTrv3hL4seLzQq3TmC+LX4+n0gehaG0zNnkP43XIX/0eM/Mxjk edUNi//SBOobT+euK5wV5zwtG+WfaghLG4uKDiG4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EB32BF8034E; Fri, 21 Aug 2020 09:32:19 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id C792FF80317; Fri, 21 Aug 2020 09:31:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CA5CFF80218 for ; Fri, 21 Aug 2020 09:31:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CA5CFF80218 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="OUlZJHhi"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IkHv2Ous" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 129F48D5; Fri, 21 Aug 2020 03:31:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=0Do/PKfM1uNzR ZmES9ekz1wc/pZqDt02aIEOkzvwxjg=; b=OUlZJHhiOt06Cjimyu6yDfmR27HR/ 2SnQEODovz+fqj/scoHTD+FeH/mP9+om+1MTyByUjszbXOisilw2iO3vWkeGfRMp JBSSbTkv2Mxr4uDE4BB5LE2ZgMZQ1hHLX1lERejAMCWNPRSWK4aKP+7GcDKiDgQ/ 6sM+N+LecrkWUdTQoH7OgpBzSwAOUgxtQJC1qACk/aWYDRbS/hfxFuEATdHz3nqS 2iZj/SlJOY5cCVQxt8M4EiK93txB7YWEAgjRord6n/L2gFCyIBj1v4bMWSIvtpma ArKaAhQAQMJ4cxMd52DMtBhvL3uKZ/sC6mp8YerP7OsZkrjlcDrk0mOpw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=0Do/PKfM1uNzRZmES9ekz1wc/pZqDt02aIEOkzvwxjg=; b=IkHv2Ous dKN93r5EgY3j1rYwZRB+u4Ax++2WiBWgW+4vV4h/vERqSTCoMG3c76TfFWj1FnLz zmuMrG3X9aZMGCSS3AUIF5vcwdHhwhM2b3xpRoC9kJFCpI42UyQ4cnmuUALaHMzA UKTMtwmscIjeF7287Lpf6uqpCATI9NnBel9boStYyFaHEV3D3RalwAu/tkGye8oW UilvPWP1pB5yFn6dUSz5u8Ik9KV7PfqWEkfj/DN4K9K96Gxk/L2XbHKszn8eHw5B Q/BT24UEEm/cJ/gr087IDvNtkpj7krzMhphxaVDG3DHN1PNiNMz0DJKJWXShjdB5 ZgAIo53ifCSbCg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepuddvnecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 656EC30600B4; Fri, 21 Aug 2020 03:31:38 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 14/25] efw-downloader: subcmd-device: check supported models or not Date: Fri, 21 Aug 2020 16:31:00 +0900 Message-Id: <20200821073111.134857-15-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit checks whether the device for node is supported models or not. When it's unsupported, the runtime exits with EXIT_FAILURE. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/subcmd-device.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index e1be025..b93d62d 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -6,6 +6,7 @@ #include #include "efw-proto.h" +#include "config-rom.h" #define report_error(error, msg) \ fprintf(stderr, "Fail to %s: %s %d %s\n", \ @@ -55,6 +56,9 @@ int subcmd_device(int argc, char **argv) const char *path; const char *op_name; HinawaFwNode *node; + const guint8 *rom; + gsize length; + guint32 vendor_id, model_id; EfwProto *proto; int err; int i; @@ -83,8 +87,21 @@ int subcmd_device(int argc, char **argv) goto err; } - entry->op(argc, argv, proto, &error); + hinawa_fw_node_get_config_rom(node, &rom, &length, &error); + if (error != NULL) { + report_error(error, "get config rom"); + goto err_node; + } + if (!config_rom_detect_vendor_and_model(rom, &vendor_id, &model_id)) { + fprintf(stderr, "The node is not for Fireworks device: %s\n", path); + g_set_error_literal(&error, G_FILE_ERROR, g_file_error_from_errno(ENXIO), + "The node is not for Fireworks device"); + goto err_node; + } + + entry->op(argc, argv, proto, &error); +err_node: g_object_unref(node); err: if (error != NULL) { From patchwork Fri Aug 21 07:31:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B8D91392 for ; Fri, 21 Aug 2020 07:40:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EFA85207DF for ; Fri, 21 Aug 2020 07:40:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="feKloBLy"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="VQ9PkG0Y"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AW759oA+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFA85207DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 55DF81684; Fri, 21 Aug 2020 09:39:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 55DF81684 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995616; bh=Vl9s7JAgREnsqVor5Vpph2X9bS0EiKI1WbybFzrMQhk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=feKloBLyri0MGq+Z/cvDShc7pPfYj0Y6ZMappKTUilxleSuYUnZL3uM6xfiquXCH/ J3sUwm6S/pUZwcE2gwmT1/foZAPAFuRCpfncku0MI0UT6yBQGG3jpijJWe0rsx2/pM R9tkKHLuDk7bQmE8M9B/uB+7w28gsMpO1UmRf570= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 893BBF80347; Fri, 21 Aug 2020 09:32:17 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 584D9F80321; Fri, 21 Aug 2020 09:31:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5F5F9F802E9 for ; Fri, 21 Aug 2020 09:31:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5F5F9F802E9 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="VQ9PkG0Y"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AW759oA+" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 92F2C8F5; Fri, 21 Aug 2020 03:31:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=LA6eHpvSCwcym rcvvVEvgAPxk6WC1hJ7d//CaT5mpN4=; b=VQ9PkG0YbMJ44JNWNwcma+xisAhUB k588B92rzQYvSeXiFt8c4GiWXa+U2UiXZELlqZNgJ6wFW+Zf9eNnU61LGS3ueYIO GsAn9vwNtB6okJQYyiGrzFVPh4l/4iFJfWqRAzoBLh0E9ZBJ5wXRsO5Bpk5ai2Vj gn9VvSvZN7YtSNvKOmSj+aNeX8yprN2WSCDe0QE0/Heu/SVi+PVt+0Zc0U1fa6vp F0IQ8kBH634EwmVEpWWQxLxPLnpnjyKNuevNqnJSaBNY8Ai/YPewj9jg4yUXRmuD 6yV1ihQbzR9oPBszqce1riUkmO+gX10Kfvzz0kg1T0WuL19pG8z2Da30A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=LA6eHpvSCwcymrcvvVEvgAPxk6WC1hJ7d//CaT5mpN4=; b=AW759oA+ fCXmkKK8x1qdq8iZnlUX24cN5QDIpP1rzDvnuWcOpB0HusmL5qeIEXRKDnF/tn+b vMVCBnaiZhs+ZfoyvfEUblACHj3AqcxlLJwd7Ksd+oEFrOJ9xOp1ajERFMSRFTRb WTlV5e+AL8SNU5Ti8FoDzKIreQj9mcfOXFHc+rXEgfPiYAWjigOsYH8wG2KmazrZ R3XXbzPjtpj/2zAKzHzIpHWIOYGWIVCEbW3WgsebuwFR5F1COJz5SRE0RJgEXBHy RVuvbwB0SBZOJ+aUQk3EZt/6+sWb6j9M5v08OTJaqbIcbj556BfiZedhOm09B9Ng 6+oPan8bZAUN5w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepuddvnecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id E6E5430600A6; Fri, 21 Aug 2020 03:31:39 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 15/25] efw-downloader: subcmd-device: bind Fireworks protocol Date: Fri, 21 Aug 2020 16:31:01 +0900 Message-Id: <20200821073111.134857-16-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit binds Fireworks protocol for the given node. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/subcmd-device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index b93d62d..1bfa1f2 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -100,7 +100,26 @@ int subcmd_device(int argc, char **argv) goto err_node; } + proto = efw_proto_new(); + efw_proto_bind(proto, node, &error); + if (error != NULL) { + if (g_error_matches(error, HINAWA_FW_NODE_ERROR, HINAWA_FW_NODE_ERROR_FAILED)) { + if (strstr(error->message, "16") != NULL) { + fprintf(stderr, "The range of address on 1394 OHCI controller already used by " + "ALSA fireworks driver.\n"); + } else { + report_error(error, "bind protocol"); + } + } else { + report_error(error, "bind protocol"); + } + goto err_node; + } + entry->op(argc, argv, proto, &error); + + efw_proto_unbind(proto); + g_object_unref(proto); err_node: g_object_unref(node); err: From patchwork Fri Aug 21 07:31:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A37651392 for ; Fri, 21 Aug 2020 07:41:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A3FE2078D for ; Fri, 21 Aug 2020 07:41:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="lFZVymp2"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="n358xPkX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="uB7N8Vax" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A3FE2078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B53CF168F; Fri, 21 Aug 2020 09:41:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B53CF168F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995710; bh=lzoyOM1XJAP/fbsMw7XN6WHTcvxGO+7/OIZUtr+Inuc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lFZVymp2iknY02OwffTKsvQaBdxZ2QZPAkkQp1hmjIuPISNDxqjxBVtJrMcVehjea aAPtt7rF2v/kus1XY3qyX8uvXWsL2bjDKlHBCgFwo6rnSEkT3yruklCBDsvmB/PVeg bIWK9tP3LGLrH9D3V8Z/IJ/qY+xiTQUhRjOtl834= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 22904F80351; Fri, 21 Aug 2020 09:32:21 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2958CF802E9; Fri, 21 Aug 2020 09:31:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D95ACF80260 for ; Fri, 21 Aug 2020 09:31:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D95ACF80260 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="n358xPkX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="uB7N8Vax" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 1ED06896; Fri, 21 Aug 2020 03:31:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=VoOoFW+q3+2EB HGoml9SX+R4sH5rVMML8h8pqfWEvyE=; b=n358xPkXqNYPk2tk3ZyuGTQqAyoVJ Z2U5Bw41AD+RT8vQgqvuyvuqWwa68dQH1zlVS8JCdZlbgysCIxq2gDe68zE3m8IW qj7y19htYif1G7SPAYY/ArXpPjTzfy/RIKloSQUcgjHUoh43gwMINbPs/JOLfAKW 3CyK6nLvA9Rg2tCikk3GifIOekkDOGZ+ebyPUIPqbphPATiHWVtNpNhLaA/XAo0X ietSzMIphJD7W3xs4oWTrEK47YuD3NKFlYAj7tmY11XVDIThhApnshnMjiIESp+s SAugFaww4tkAYDCaGkFW3yKpmdCU4M1t2rmX5yDl/obt3RoFms3xQy82A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=VoOoFW+q3+2EBHGoml9SX+R4sH5rVMML8h8pqfWEvyE=; b=uB7N8Vax qUbQrfj/UTv0I8maY1QVcUixNmH2+S1ViUnJsqtZXYXXMQMsfUuTZVyfY6kVAEs8 Uu8ZdMAUQeBYdsGiTxgKZIj9gx//+WgdmydTZdErI/tdr+Tr3XQdZGf3uSHimK6D Yj6u1tSP/qMtJzje/1o9AcI7TcqVb9gMlps8wJvnoRr9oIp3xanA4QSBWM7Nt+li pqQ1nnheUYjHX3AugsonI4VIB1OsPiIJPA6f2i9/AmhghvNiSAOp6FxyjfHfy0Ra yXpMN5qGZjDwsH9eSX+rxuvISOXgvcKG1ZshuUX4n8Jr3nDBrQysJZ24OgegAD+b NQh3zQtNZppArg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepuddvnecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 6275030600B9; Fri, 21 Aug 2020 03:31:41 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 16/25] efw-downloader: node_dispatcher: add event dispatcher utilizing GLib MainContext/MainLoop Date: Fri, 21 Aug 2020 16:31:02 +0900 Message-Id: <20200821073111.134857-17-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" HinawaFwNode creates GSource for GLib MainContext. It's easy to GLib MainLoop as event dispatcher. This commit adds local application of GLib MainContext/MainLoop to dispatch events for HinawaFwNode. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/meson.build | 2 + efw-downloader/src/node-dispatcher.c | 86 ++++++++++++++++++++++++++++ efw-downloader/src/node-dispatcher.h | 21 +++++++ efw-downloader/src/subcmd-device.c | 10 ++++ 4 files changed, 119 insertions(+) create mode 100644 efw-downloader/src/node-dispatcher.c create mode 100644 efw-downloader/src/node-dispatcher.h diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index c006c8b..c43c332 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -15,12 +15,14 @@ sources = [ 'main.c', 'efw-proto.c', 'config-rom.c', + 'node-dispatcher.c', 'subcmd-device.c', ] headers = [ 'efw-proto.h', 'config-rom.h', + 'node-dispatcher.h', 'subcmds.h', ] diff --git a/efw-downloader/src/node-dispatcher.c b/efw-downloader/src/node-dispatcher.c new file mode 100644 index 0000000..8394600 --- /dev/null +++ b/efw-downloader/src/node-dispatcher.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include "node-dispatcher.h" +#include + +struct thread_arg { + GMainLoop *loop; + GCond cond; + GMutex mutex; +}; + +static gpointer run_node_dispatcher(gpointer data) +{ + struct thread_arg *args = (struct thread_arg *)data; + + g_mutex_lock(&args->mutex); + g_cond_signal(&args->cond); + g_mutex_unlock(&args->mutex); + + g_main_loop_run(args->loop); + + return NULL; +} + +void node_dispatcher_start(struct node_dispatcher *dispatcher, HinawaFwNode *node, GError **error) +{ + struct thread_arg args; + GSource *src; + + dispatcher->ctx = g_main_context_new(); + + hinawa_fw_node_create_source(node, &src, error); + if (*error != NULL) + return; + + g_source_attach(src, dispatcher->ctx); + g_source_unref(src); + + dispatcher->loop = g_main_loop_new(dispatcher->ctx, FALSE); + + args.loop = dispatcher->loop; + g_cond_init(&args.cond); + g_mutex_init(&args.mutex); + + dispatcher->th = g_thread_try_new("node-dispatcher", run_node_dispatcher, &args, error); + if (*error != NULL) { + g_main_loop_quit(dispatcher->loop); + g_main_loop_unref(dispatcher->loop); + dispatcher->loop = NULL; + + g_main_context_unref(dispatcher->ctx); + dispatcher->ctx = NULL; + + goto end; + } + + g_mutex_lock(&args.mutex); + while (!g_main_loop_is_running(dispatcher->loop)) + g_cond_wait(&args.cond, &args.mutex); + g_mutex_unlock(&args.mutex); +end: + g_cond_clear(&args.cond); + g_mutex_clear(&args.mutex); +} + +void node_dispatcher_stop(struct node_dispatcher *dispatcher) +{ + if (dispatcher->loop != NULL) + g_main_loop_quit(dispatcher->loop); + + if (dispatcher->th != NULL) { + g_thread_join(dispatcher->th); + g_thread_unref(dispatcher->th); + dispatcher->th = NULL; + } + + if (dispatcher->loop != NULL) { + g_main_loop_unref(dispatcher->loop); + dispatcher->loop = NULL; + } + + if (dispatcher->ctx != NULL) { + g_main_context_unref(dispatcher->ctx); + dispatcher->ctx = NULL; + } +} diff --git a/efw-downloader/src/node-dispatcher.h b/efw-downloader/src/node-dispatcher.h new file mode 100644 index 0000000..9e47e00 --- /dev/null +++ b/efw-downloader/src/node-dispatcher.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __NODE_DISPATCHER_H__ +#define __NODE_DISPATCHER_H__ + +#include +#include + +#include +#include + +struct node_dispatcher { + GMainContext *ctx; + GMainLoop *loop; + GThread *th; +}; + +void node_dispatcher_start(struct node_dispatcher *dispatcher, HinawaFwNode *node, GError **error); +void node_dispatcher_stop(struct node_dispatcher *dispatcher); + +#endif diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index 1bfa1f2..5ac0ac6 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -7,6 +7,7 @@ #include "efw-proto.h" #include "config-rom.h" +#include "node-dispatcher.h" #define report_error(error, msg) \ fprintf(stderr, "Fail to %s: %s %d %s\n", \ @@ -60,6 +61,7 @@ int subcmd_device(int argc, char **argv) gsize length; guint32 vendor_id, model_id; EfwProto *proto; + struct node_dispatcher dispatcher = {0}; int err; int i; @@ -116,8 +118,16 @@ int subcmd_device(int argc, char **argv) goto err_node; } + node_dispatcher_start(&dispatcher, node, &error); + if (error != NULL) { + report_error(error, "begin dispatcher"); + goto err_proto; + } + entry->op(argc, argv, proto, &error); + node_dispatcher_stop(&dispatcher); +err_proto: efw_proto_unbind(proto); g_object_unref(proto); err_node: From patchwork Fri Aug 21 07:31:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728551 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED2E81392 for ; Fri, 21 Aug 2020 07:42:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D9442078D for ; Fri, 21 Aug 2020 07:42:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="E+Hmetou"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="bhGu4L7i"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="b6ryquQq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D9442078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 03C9F169C; Fri, 21 Aug 2020 09:41:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 03C9F169C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995752; bh=MQtjZaIVZyTzc9dyMPygL4g1QsFUr2tmc+xmbd1ksUA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=E+HmetouwVyJjUTT5XIjsjFao7JCjxJzm388BNf7xk2LiuM1q6TjmRVh465EpBX1S 56T9+CP7p4GpIfUFap66QNzUi05wk2JgBW5r3TcloqP/1CH3Ttm3upbKpVlQdxwmYM Z3+e5+re8Rxu1DRtnwy9Ssg9Vor24lypsH7gBoio= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D3902F8036C; Fri, 21 Aug 2020 09:32:22 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 22CFEF80317; Fri, 21 Aug 2020 09:31:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AD62FF802EC for ; Fri, 21 Aug 2020 09:31:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AD62FF802EC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="bhGu4L7i"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="b6ryquQq" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id DD32790F; Fri, 21 Aug 2020 03:31:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=Y/8SJwzWWXRjh 6+YEEYfAEplJzDhuvEcF6U2dQH01G8=; b=bhGu4L7i6ELzlRlNHD/6umionDFH2 /fqMv305MiHDyS43jwjszJ94P9Om0M5SW9PotZTUofAnkgTzRXKscWvr2OmwFZeS qTLgjIMPJKcoTkD/XlIclK3raV9SyzSG54Vf4ClOVHLAvK73zRPAF8jz7b35Rrda Gv1PsyOWAs128wZsr/f50k62IxZBH1AenD4RPYUK0HHp8mWjUALo4Re1jkT7Sjm/ PxCshHARsBnf0Tma+GFanL9zhrmH1Zjjk2apT3ogVZm1YITb+jw5bI4lM5ms8Cb+ pOK34haauAWtkuOLprwRBdIGlPfITOIOUu1nSBSImAOOPhBQAV9AYoFMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=Y/8SJwzWWXRjh6+YEEYfAEplJzDhuvEcF6U2dQH01G8=; b=b6ryquQq /pCc2RaoDq0ZR8KofYLOUoEBP5ymIYp9tUrunC4xHHPHq6fDgMa7+NcuursSX5n6 Hqfpiv1PPJrdRK97a9jHVO1sBNIG0PTpbSz4UAReJcneuwVjtyaZUsT/FykAPsKv +WZBlEbtArItdIjlhZfqQ581oghbJdB3jaJimuchstaSJLUXeISliPvuD1GCDxFY W1SfYrHZjoJHIlqKudJIM+Ls6yXS5MiJ0UrYpFrclbTDvHkDCjX/bcC0V1JkCF0Q ZJSGnnHEYOfWiyGtptv+yVZrlbCzNUHRhWJwL3APFNDeSXf/NjJcxyGyebCIPSI2 FfOWYU/vnNVCrA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepuddvnecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id EA93030600A6; Fri, 21 Aug 2020 03:31:42 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 17/25] efw-downloader: subcmd-device: support debug output for response of Fireworks protocol Date: Fri, 21 Aug 2020 16:31:03 +0900 Message-Id: <20200821073111.134857-18-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" It's helpful to dump communication result optionally. This commit adds debug option for the purpose. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/subcmd-device.c | 40 ++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index 5ac0ac6..329eef0 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -28,8 +28,31 @@ static int print_help() return EXIT_FAILURE; } -static int parse_args(int argc, char **argv, const char **path, const char **op_name) +static void handle_responded_signal(EfwProto *proto, HinawaSndEfwStatus status, guint seqnum, + guint category, guint command, const guint32 *frame, guint frame_size) { + gchar *label = g_enum_to_string(HINAWA_TYPE_SND_EFW_STATUS, status); + int i; + + printf("responded:\n"); + printf(" status: %s\n", label); + printf(" seqnum: %d\n", seqnum); + printf(" category; %d\n", category); + printf(" command: %d\n", command); + + if (frame_size > 0) { + printf(" frame:\n"); + for (i = 0; i < frame_size; ++i) + printf(" [%3x]: %08x\n", i, frame[i]); + } + + g_free(label); +} + +static int parse_args(int argc, char **argv, const char **path, const char **op_name, gboolean *debug) +{ + int i; + if (argc < 2) return -EINVAL; assert(strncmp(argv[1], "device", sizeof("device")) == 0); @@ -42,6 +65,15 @@ static int parse_args(int argc, char **argv, const char **path, const char **op_ return -EINVAL; *op_name = argv[3]; + *debug = FALSE; + for (i = 0; i < argc; ++i) { + if (strncmp(argv[i], "--debug", sizeof(--debug)) == 0 || + strncmp(argv[i], "-d", sizeof(--debug)) == 0) { + *debug = TRUE; + break; + } + } + return 0; } @@ -54,6 +86,7 @@ int subcmd_device(int argc, char **argv) } *entry, entries[] = { }; GError *error = NULL; + gboolean debug; const char *path; const char *op_name; HinawaFwNode *node; @@ -65,7 +98,7 @@ int subcmd_device(int argc, char **argv) int err; int i; - err = parse_args(argc, argv, &path, &op_name); + err = parse_args(argc, argv, &path, &op_name, &debug); if (err < 0) return print_help(0, NULL, NULL, NULL); @@ -103,6 +136,9 @@ int subcmd_device(int argc, char **argv) } proto = efw_proto_new(); + if (debug) + g_signal_connect(proto, "responded", (GCallback)handle_responded_signal, NULL); + efw_proto_bind(proto, node, &error); if (error != NULL) { if (g_error_matches(error, HINAWA_FW_NODE_ERROR, HINAWA_FW_NODE_ERROR_FAILED)) { From patchwork Fri Aug 21 07:31:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728559 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C56F739 for ; Fri, 21 Aug 2020 07:44:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B40EA2078D for ; Fri, 21 Aug 2020 07:44:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="eESuvuee"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="DVHrBwQe"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="SmlxBYD0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B40EA2078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4223F16B3; Fri, 21 Aug 2020 09:43:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4223F16B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995850; bh=lE7AyOUk95e6UffPn8xB2yiAY9ZfrT9O2QbO4Ak+iTw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=eESuvueeZXwN5bQBB+P98wl0An3kL9ICq2TdSMLMfjM4q0+6/LT03tipn0s2md08a oeHNlqAQZ/3rkrDwbVqiP6B/r6Ov3CsFeQwTPCu3Y5lgqoTatsjw4IzERJxtievp+L tzjo/lw8vPssll74IunC6wGijTGiaZmzTe8ut3/4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7C4A2F8037F; Fri, 21 Aug 2020 09:32:26 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id DDCA0F8033D; Fri, 21 Aug 2020 09:32:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 266FFF802DC for ; Fri, 21 Aug 2020 09:31:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 266FFF802DC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="DVHrBwQe"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="SmlxBYD0" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 57F19885; Fri, 21 Aug 2020 03:31:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=/ku8qMBURHYag jJHbBMdrFe0VzeXd9Y+T4h9H2xVdZI=; b=DVHrBwQe+K/O1Ela+x2jnnfOCZwka str73OtOXIVVSuTMT7YalAE/8cUASuPsZht/79gTT16Db/dGcs8XGOLOJ8vzQ/q4 1U6Sb1IwswCByaPhSfSNxfAbGja4hnJE8ZDnGKL1Z2w0M3YQZlFEw7kxOWxS2FEk s4h+Y2+A4ohuAAoXEdZ0dzDb/V+VBsxRrY6+9n1z/gcXbrXTEr+H+vgNpdOUo61W YaDpuNEKX1f+J/ixT7NAheTFCeW8WInplYKVEqJLg7GynKKs92LNZZaaRkanRS3C UwoSBVyaq+WwR+ltcxI7dzxY6LIDOqRhXFN+kGBaTBF9kfwOIEgDGe6og== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=/ku8qMBURHYagjJHbBMdrFe0VzeXd9Y+T4h9H2xVdZI=; b=SmlxBYD0 Ki1/Erd+1SPBqqFTFgEjkOgjXNrOXGrUivhLbyawbWcIh6wZhEz1q3tQtn4nGiCP 8zD5Vwt5wRc0qXDdJQHrSy62s2kCZIDgVbktWY238BxS3UamWGrwkJQQcZvK74Ev aforb/3oHp+nrJNlEqAdCJcCTvJwzytgVlGkn6XS7YLYFyXMs1SHmt25wc6TxvYu SfTLHPyZ1FNBszNkGH4m9QAvpCg6Uu531yXYfWqF8la19HZpa/saIBIOIm3bI9aW U8ka12xnngXXMGVrZLR5iigUx3eoaqxw/gS4rUlbtoNhkRb8w7fShqhFnH5bPSIR n/FXUfdBOvTzug== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepudeinecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 37B8330600B7; Fri, 21 Aug 2020 03:31:44 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 18/25] efw-downloader: efw-commands: add support for a part of hardware command Date: Fri, 21 Aug 2020 16:31:04 +0900 Message-Id: <20200821073111.134857-19-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Fireworks protocol includes command to retrieve information about hardware. This commit implements the command and local helper functions. Signed-off-by: Takashi Sakamoto --- 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 +#include +#include + +#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, ¶m_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', ] From patchwork Fri Aug 21 07:31:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728565 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67FA8739 for ; Fri, 21 Aug 2020 07:45:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE6232078D for ; Fri, 21 Aug 2020 07:45:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="q8qzp8u+"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="WpThy1DF"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fc/TWWok" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE6232078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 716DC16AF; Fri, 21 Aug 2020 09:44:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 716DC16AF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995915; bh=qj6DwRt2l7/77BGTLO1VgFLexfNWHoofqRlwGSONCF8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=q8qzp8u+2Z6ME+bGKYgZxEnbQEpFGnn8GTImPm3fX3JpkepgPyCg6P9TcQz3eNv5v Pql3pIdzEbIYf6/3+lkOaa6ceJMbetdl4NCYRUY9ojHWyGXQUt5pqDflqa4eQwzqkz Vj2hVPNdM2PeAfw0ztiNT4LrpZvVDD4XXLWiDUho= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 56385F80390; Fri, 21 Aug 2020 09:32:29 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id BC0D6F80347; Fri, 21 Aug 2020 09:32:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A0326F802FE for ; Fri, 21 Aug 2020 09:31:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A0326F802FE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="WpThy1DF"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fc/TWWok" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id CD7F38FA; Fri, 21 Aug 2020 03:31:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=hC3f/5eiwOoMy eaSZy0EsvqaQWeJ5FR6+CHhWs3o1zs=; b=WpThy1DFAkTKPqptOzjGzljwoUomR Q0FEyn/TMWPyggy5UNePLxoYqyFUQe4Q2nMJLIRrv/KLq3AaYN9nBQxC74D5GnlY UG+7UgaSt8AA4EGRhc2DPg36DgnlQsWxiFDTvEcAAGajAfg0pGrynpITKel1Fyxk zTmx71jurFIDJcPr8IklqATlisl6rrRu2rLBBtJ5NdzX1Okbetwb0ke7FL93DoLt X2TQiBUc5a0FKZS2ie/TK35fOIWi4vgNNirRSgx7sHxhIe1K+axuCH++3cjC9sKK HHHEonoVbYnQimzLxopyRdKae9KKb111Gzvu2XU4T1AKdBiPjjMTCvqeQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=hC3f/5eiwOoMyeaSZy0EsvqaQWeJ5FR6+CHhWs3o1zs=; b=fc/TWWok 5LSDaQ9B3XCJXj6jaBmLnyZn0H7MD4j3xESoOkgD+totmQQysq4JWnerIMigvavL W4M3Lp7rVn32ywxNdW9QC3U3sXXf41y5KI4IQyMgziXbf27k/k7kFZmrF21v/U5j qQKxLw4ycsQH+JNu5Idkwnpl/j4iC3Vxm+3OIzSQICWd5CP1J+96bPahim9MwZhV j7kMD4xWqea1wuHEo824ca60nqgSOeywb7x7N0ln/JdmSRm0DRF0SKkGGLrwGZJf R4945p8W9m3vA+LzL67gwvo1CyoFQiOYrD2pinvb2sjri70eA8oGUxQaPI3yt13Y M0bbXMyvO68mHg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepudeinecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 2120530600A9; Fri, 21 Aug 2020 03:31:46 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 19/25] efw-downloader: efw-commands: add support for commands in flash category Date: Fri, 21 Aug 2020 16:31:05 +0900 Message-Id: <20200821073111.134857-20-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Fireworks protocol includes command for software to operate on-board flash memory. This commit implements the command and adds local helper functions. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/efw-commands.c | 213 ++++++++++++++++++++++++++++++ efw-downloader/src/efw-commands.h | 12 ++ 2 files changed, 225 insertions(+) diff --git a/efw-downloader/src/efw-commands.c b/efw-downloader/src/efw-commands.c index 08b0114..b0a8320 100644 --- a/efw-downloader/src/efw-commands.c +++ b/efw-downloader/src/efw-commands.c @@ -8,10 +8,26 @@ // Categories in Echo Audio Fireworks protocol. #define CATEGORY_HW 0 +#define CATEGORY_FLASH 1 // Commands in hardware category. #define HW_CMD_INFO 0 +// Commands in flash category. +#define FLASH_CMD_ERASE 0 +#define FLASH_CMD_READ 1 +#define FLASH_CMD_WRITE 2 +#define FLASH_CMD_STATE 3 +#define FLASH_CMD_SESSION_BASE 4 +#define FLASH_CMD_LOCK 5 + +#define EFW_FLASH_FRAME_MAX_QUADS 64 + +// Between 0x00000000 - 0x00010000. +#define EFW_FLASH_BLOCK_SIZE_LOW 0x00002000 +// Between 0x00010000 - 0x00200000. +#define EFW_FLASH_BLOCK_SIZE_HIGH 0x00010000 + #define TIMEOUT 200 #define CAP_HAS_DSP 0x00000010 @@ -28,3 +44,200 @@ void efw_hw_info_has_fpga(struct hw_info *info, gboolean *has_fpga) { *has_fpga = !!(info->flags & CAP_HAS_FPGA); } + +int efw_flash_get_block_size(size_t offset, size_t *block_size) +{ + if (offset < 0x00010000) + *block_size = EFW_FLASH_BLOCK_SIZE_LOW; + else if (offset < 0x00200000) + *block_size = EFW_FLASH_BLOCK_SIZE_HIGH; + else + return -ENXIO; + + return 0; +} + +void efw_flash_erase(EfwProto *proto, size_t offset, GError **error) +{ + size_t block_size; + guint32 args[1] = {0}; + guint32 *params = (guint32 [1]){0}; + gsize param_count = 1; + int err; + + err = efw_flash_get_block_size(offset, &block_size); + if (err < 0) { + g_set_error(error, EFW_PROTO_ERROR, -err, + "%s %d: %s", __FILE__, __LINE__, strerror(-err)); + return; + } + + if (offset % block_size > 0) { + g_set_error(error, EFW_PROTO_ERROR, EINVAL, + "%s %d: %s", __FILE__, __LINE__, strerror(EINVAL)); + return; + } + + args[0] = offset; + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_ERASE, args, G_N_ELEMENTS(args), + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); +} + +void efw_flash_erase_and_wait(EfwProto *proto, size_t offset, GError **error) +{ + efw_flash_erase(proto, offset, error); + if (*error != NULL) + return; + + while (TRUE) { + gboolean state; + struct timespec req = { + .tv_sec = 0, + .tv_nsec = 500000000, + }; + + efw_flash_state(proto, &state, error); + if (state == TRUE) + break; + + if (*error != NULL) + g_clear_error(error); + + clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL); + } +} + +void efw_flash_read(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error) +{ + guint32 args[2] = {0}; + guint32 *params = (guint32 [2 + EFW_FLASH_FRAME_MAX_QUADS]){0}; + gsize param_count = 2 + EFW_FLASH_FRAME_MAX_QUADS; + + if (quads > EFW_FLASH_FRAME_MAX_QUADS) { + g_set_error(error, EFW_PROTO_ERROR, EINVAL, + "%s %d: %s", __FILE__, __LINE__, strerror(EINVAL)); + return; + } + + args[0] = offset; + args[1] = quads; + + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_READ, args, G_N_ELEMENTS(args), + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); + if (*error != NULL) + return; + + if (params[0] != offset || params[1] != quads) { + g_set_error(error, EFW_PROTO_ERROR, EIO, + "%s %d: %s", __FILE__, __LINE__, strerror(EIO)); + return; + } + + memcpy(buf, (const void *)¶ms[2], quads * sizeof(*buf)); +} + +void efw_flash_recursive_read(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error) +{ + while (quads > 0) { + size_t count = MIN(quads, EFW_FLASH_FRAME_MAX_QUADS); + + efw_flash_read(proto, offset, buf, count, error); + if (*error != NULL) + return; + + offset += count * 4; + quads -= count; + buf += count; + } +} + +void efw_flash_write(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error) +{ + guint32 args[2 + EFW_FLASH_FRAME_MAX_QUADS] = {0}; + guint32 *params = (guint32 [2]){0}; + gsize param_count = 2; + + if (quads > EFW_FLASH_FRAME_MAX_QUADS) { + g_set_error(error, EFW_PROTO_ERROR, EINVAL, + "%s %d: %s", __FILE__, __LINE__, strerror(EINVAL)); + return; + } + + args[0] = offset; + args[1] = quads; + memcpy((void *)&args[2], buf, quads * sizeof(*buf)); + + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_WRITE, args, G_N_ELEMENTS(args), + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); +} + +void efw_flash_recursive_write(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error) +{ + while (quads > 0) { + size_t count = MIN(quads, EFW_FLASH_FRAME_MAX_QUADS); + gboolean state; + + efw_flash_write(proto, offset, buf, count, error); + if (*error != NULL) + return; + + offset += count * 4; + quads -= count; + buf += count; + + while (TRUE) { + struct timespec req = { + .tv_sec = 0, + .tv_nsec = 500000000, + }; + + efw_flash_state(proto, &state, error); + if (state == TRUE) + break; + + if (*error != NULL) + g_clear_error(error); + + clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL); + } + } +} + +void efw_flash_state(EfwProto *proto, gboolean *state, GError **error) +{ + gsize param_count = 0; + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_STATE, NULL, 0, NULL, ¶m_count, + TIMEOUT, error); + if (*error == NULL) { + *state = TRUE; + } else if (g_error_matches(*error, EFW_PROTO_ERROR, HINAWA_SND_EFW_STATUS_FLASH_BUSY)) { + *state = FALSE; + g_clear_error(error); + } +} + +void efw_flash_get_session_base(EfwProto *proto, size_t *offset, GError **error) +{ + guint32 *params = (guint32 [1]){0}; + gsize param_count = 1; + + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_SESSION_BASE, NULL, 0, + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); + if (*error != NULL) + return; + + *offset = params[0]; +} + +// MEMO: Lock operation is additional to the combination of IceLynx Micro and FPGA. +void efw_flash_lock(EfwProto *proto, gboolean locked, GError **error) +{ + guint32 args[1] = {0}; + guint32 *params = (guint32 [1]){0}; + gsize param_count = 1; + + args[0] = locked; + + efw_proto_transaction(proto, CATEGORY_FLASH, FLASH_CMD_LOCK, args, G_N_ELEMENTS(args), + (guint32 *const *)¶ms, ¶m_count, TIMEOUT, error); +} diff --git a/efw-downloader/src/efw-commands.h b/efw-downloader/src/efw-commands.h index fd2dbe3..a25781b 100644 --- a/efw-downloader/src/efw-commands.h +++ b/efw-downloader/src/efw-commands.h @@ -42,4 +42,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); +void efw_flash_erase(EfwProto *proto, size_t offset, GError **error); +void efw_flash_read(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error); +void efw_flash_write(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error); +void efw_flash_state(EfwProto *proto, gboolean *state, GError **error); +void efw_flash_get_session_base(EfwProto *proto, size_t *offset, GError **error); +void efw_flash_lock(EfwProto *proto, gboolean locked, GError **error); + +int efw_flash_get_block_size(size_t offset, size_t *block_size); +void efw_flash_erase_and_wait(EfwProto *proto, size_t offset, GError **error); +void efw_flash_recursive_read(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error); +void efw_flash_recursive_write(EfwProto *proto, size_t offset, guint32 *buf, size_t quads, GError **error); + #endif From patchwork Fri Aug 21 07:31:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64DAC739 for ; Fri, 21 Aug 2020 07:43:40 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF3E32078D for ; Fri, 21 Aug 2020 07:43:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Oto9Y/MX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="iKLa+juy"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OFfFdeCf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF3E32078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 805B416B1; Fri, 21 Aug 2020 09:42:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 805B416B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995818; bh=UZPTzWLbxzFaYWGHqrpSCOVA+RqV9BHgddJXLt0YuLA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Oto9Y/MXJdjHcqFrxgJrSuvqtgdUmfuhO9QE6YF/XPS4LM597xoXydXerC/8MNL6K SDBRaCWftd+Rwd0tHQ8EalxM4HWPz7xiLXKYECENJ7j1KZybn0PMvogihe0SpMr+bl 1gxtqJzEEfjWDoKFV6hXJ5qMzwnLiND8Al8XRsUk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 02658F80377; Fri, 21 Aug 2020 09:32:25 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id AF74BF8033E; Fri, 21 Aug 2020 09:32:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 47515F80303 for ; Fri, 21 Aug 2020 09:31:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 47515F80303 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="iKLa+juy"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OFfFdeCf" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 7AFF48B9; Fri, 21 Aug 2020 03:31:50 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=KPYyZhrP1cWcK m0GXDuzOYq7JBYXxkQkitzqKvC+u38=; b=iKLa+juyy5TsCh0novAg2MenJkWZh yg/htRi1oGOUmc9u6FwYa0ir2J+heKp9hyy7LDXv09U5x1u5FOsyuVN1xnB6hFZK FdasippRwfS+/rj2MJwfjGSuFVKsJp4TEqUOZpdTdvpkzBaXYd+RCqKySpmaty/Z wMLO73DWnSzj2z8dukvUi/ZxlseIRDB9iIovvq6dYev4ZtkYIKPmZJqI+Kru1vID bcT5akrsN1pGN5AoCf171MvXqK+kI0o9s77jaoipibfjR58vxMoYqeo54UKNtgwR QSjLWcfBb6wZ/9h5KvkLGRE08KOlxZr1n2AgJTA3h+l54KcypF/pR3R8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=KPYyZhrP1cWcKm0GXDuzOYq7JBYXxkQkitzqKvC+u38=; b=OFfFdeCf Ln+2joZcIIK+Fx60rqLiXfDPan3DMhpIe52bG+EzKR8wPvCNf0pQHe4UbNelLzzQ INDm/wxFkU/3fjaXgy612R8Td7dz4d+zGllETiJrKuMuh+2YbJIQeyccMkEaYFu8 QH0zcjC94hw/plZ1ckAl96jHvM/0WvURs1X/oaYAYURqrXLFwzy/+rct/gmP6a1t x/UOREXecVp1GXnANG5VTA8dN7D3WD2/Cc1yY82TFHtJmGAP9KEHyjvS85TNN8pG mo9KUTXMAFPNrll5UO5haMo3Vx053bTuH7VEbV0w4IHjJooBfTcPDsDUIZ12b3tC netI6rIOl3ha/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepudeinecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id B338E30600B1; Fri, 21 Aug 2020 03:31:48 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 20/25] efw-downloader: subcmd-device: add read operation Date: Fri, 21 Aug 2020 16:31:06 +0900 Message-Id: <20200821073111.134857-21-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit add read operation in device sub command. The arbitrary range of address in on-board flash memory is read and the content is dump in stdout. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/meson.build | 1 + efw-downloader/src/op-device-read.c | 104 ++++++++++++++++++++++++++++ efw-downloader/src/subcmd-device.c | 4 ++ efw-downloader/src/subcmds.h | 4 ++ 4 files changed, 113 insertions(+) create mode 100644 efw-downloader/src/op-device-read.c diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 73a0f36..8738d76 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -18,6 +18,7 @@ sources = [ 'node-dispatcher.c', 'efw-commands.c', 'subcmd-device.c', + 'op-device-read.c', ] headers = [ diff --git a/efw-downloader/src/op-device-read.c b/efw-downloader/src/op-device-read.c new file mode 100644 index 0000000..a1fa0cf --- /dev/null +++ b/efw-downloader/src/op-device-read.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include +#include +#include +#include +#include + +#include "efw-commands.h" + +static void print_help() +{ + printf("Usage\n" + " efw-downloader device CDEV read OFFSET LENGTH [OPTIONS]\n" + "\n" + "where:\n" + " CDEV: The firewire character device corresponding to the node for proto\n" + " OFFSET: The hexadecimal offset address in on-board flash memory\n" + " LENGTH: The hexadecimal number to read. The value is finally aligned to quadlet.\n" + " OPTIONS:\n" + " --help, -h: Print this help message and exit.\n" + " --debug: Output debug message to stderr\n"); +} + +static int parse_args(int argc, char **argv, size_t *offset, size_t *quads, gboolean *help) +{ + unsigned long val; + char *end; + int i; + + if (argc < 4) + return -EINVAL; + assert(strncmp(argv[3], "read", sizeof("read")) == 0); + + if (argc < 5) + return -EINVAL; + val = strtol(argv[4], &end, 16); + if (*end != '\0') { + printf("Invalid argument for offset address.\n"); + return -EINVAL; + } + *offset = (size_t)val; + + if (argc < 6) + return -EINVAL; + val = strtol(argv[5], &end, 16); + if (*end != '\0') { + printf("Invalid argument for quadlet count.\n"); + return -EINVAL; + } + *quads = (size_t)(val + 3) / 4; + + *help = FALSE; + for (i = 0; i < argc; ++i) { + if (strncmp(argv[i], "--help", sizeof("--help")) == 0 || + strncmp(argv[i], "-h", sizeof("-h")) == 0) { + *help = TRUE; + } + } + + return 0; +} + +void op_device_read(int argc, char **argv, EfwProto *proto, GError **error) +{ + size_t offset; + size_t quads; + guint32 *buf; + gboolean help; + int err; + int i; + + err = parse_args(argc, argv, &offset, &quads, &help); + if (err < 0) { + print_help(); + g_set_error_literal(error, G_FILE_ERROR, G_FILE_ERROR_INVAL, "Invalid arguments"); + return; + } + + if (help) { + print_help(); + return; + } + + buf = g_try_malloc0_n(quads, sizeof(*buf)); + if (buf == NULL) { + fprintf(stderr, "Memory allocation fails.\n"); + g_set_error_literal(error, G_FILE_ERROR, G_FILE_ERROR_NOSPC, "Memory allocation error"); + return; + } + + efw_flash_recursive_read(proto, offset, buf, quads, error); + if (*error != NULL) { + fprintf(stderr, + "Fail to read contents of flash memory: %s %d %s\n", + g_quark_to_string((*error)->domain), (*error)->code, (*error)->message); + goto end; + } + + for (i = 0; i < quads; ++i) + printf(" %08lx: %08x\n", offset + 4 * i, buf[i]); +end: + g_free(buf); +} diff --git a/efw-downloader/src/subcmd-device.c b/efw-downloader/src/subcmd-device.c index 329eef0..a11450c 100644 --- a/efw-downloader/src/subcmd-device.c +++ b/efw-downloader/src/subcmd-device.c @@ -9,6 +9,8 @@ #include "config-rom.h" #include "node-dispatcher.h" +#include "subcmds.h" + #define report_error(error, msg) \ fprintf(stderr, "Fail to %s: %s %d %s\n", \ msg, g_quark_to_string(error->domain), error->code, error->message) @@ -21,6 +23,7 @@ static int print_help() "where:\n" " CDEV: The firewire character device corresponding to the node for transaction\n" " OPERATION:\n" + " read: read from on-board flash memory\n" " help: print this help message\n" " ARGUMENTS:\n" " depending on OPERATION\n" @@ -84,6 +87,7 @@ int subcmd_device(int argc, char **argv) size_t size; void (*op)(int argc, char **argv, EfwProto *proto, GError **error); } *entry, entries[] = { + { "read", sizeof("read"), op_device_read }, }; GError *error = NULL; gboolean debug; diff --git a/efw-downloader/src/subcmds.h b/efw-downloader/src/subcmds.h index f10c420..70cbb5a 100644 --- a/efw-downloader/src/subcmds.h +++ b/efw-downloader/src/subcmds.h @@ -3,6 +3,10 @@ #ifndef __SUBCMDS_H__ #define __SUBCMDS_H__ +#include "efw-proto.h" + int subcmd_device(int argc, char **argv); +void op_device_read(int argc, char **argv, EfwProto *proto, GError **error); + #endif From patchwork Fri Aug 21 07:31:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728555 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 036CB739 for ; Fri, 21 Aug 2020 07:43:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86DE5207DF for ; Fri, 21 Aug 2020 07:43:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="gbFq2rRj"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="BaBGAXdV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nl7qShPG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86DE5207DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 530A416A4; Fri, 21 Aug 2020 09:42:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 530A416A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995789; bh=NsDj5mhAOHE3U5SLAhjBIClS4OgP64OspdNDURlL1tQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gbFq2rRj4kGzZv9n7oczcBb6Ki4g/VvbumQu5NvJnHwpYZm6TVAMKEGIRMQWQ/W7s osHaepujhfTfDSTs1G7qB7cHcDvmUEaPsbDIL3pg/JuO4qZiCTbR0KPIEO31Hj57FV 97LiKpIZZmXNmWhPJvjraIbBSCqP/tb6FtkSDahw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F2BC9F8036D; Fri, 21 Aug 2020 09:32:23 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 24751F8033F; Fri, 21 Aug 2020 09:32:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C50E2F80307 for ; Fri, 21 Aug 2020 09:31:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C50E2F80307 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="BaBGAXdV"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nl7qShPG" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id F2D0A88D; Fri, 21 Aug 2020 03:31:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=K/QPuC3ZdcnZY 7jTjKWi3t1nnUTZaUy5ObXDqQ9utho=; b=BaBGAXdVo3qb0KJVuaxuPP1QtE4D3 2gXzFKaP50OnKQhl5k5niklWZ6Or3u+Sa4XjwY2ZmkeeLIwXtg6LdyRtWWnb6GEz XOdUywJtqMzzmitizUqY6nyFVxyzQf4OCHL8WwA7zHldHu9Alf9kI23Uw1mrELpI helpEpLfyWZmbxOu0wmzliuiP85ZE3imUyiJgcjVPHv076wKBAvWwhCzcrhd9FQN pmGtdsMuJTQ2S+OYapKVwNMfmBn6G5nIUHAcsUjNmqwUfXEXpxFCXyqZSMsI9Is5 7EJ/suC6BPBYAGASfoBnlYt1mHFI6Yv1VcWjmzBRQnjTBVZiNm2uCHU0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=K/QPuC3ZdcnZY7jTjKWi3t1nnUTZaUy5ObXDqQ9utho=; b=nl7qShPG bhh7TJJxPS5zP77aWxnBo0XvCkvv78C0+e1AUzORfqaWZXFypmaasoj+tcGvmOLP 4j4SjT3H/qQ9XiwTHxuLKb6Q0ZEbah6LG24nMBCcoxWSCX3EyAPGxP2lZcArapoX 4As+JQnujXmS91dBtG07E16JV4i1nc/7VVNmjMkGD9dbQVjyP3hW0+8h428Vovrh 0g5fCUS6Hd30qcxZ/Qf/LIw61CeFbAsBxZljZAyrEBOznJpxrznGYphHAq4E5Vwb wMANtJj2wNiOMxwJB6xexZl750mUR+uMdl8kX8VL9imrsHVwODh+xVE8Kxx6XXn/ a705Z1RL1+mmHA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepudelnecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 5AD4A30600A6; Fri, 21 Aug 2020 03:31:50 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 21/25] efw-downloader: file-cntr: add parser for data binary shipped by Echo Digital Audio corporation Date: Fri, 21 Aug 2020 16:31:07 +0900 Message-Id: <20200821073111.134857-22-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Echo Digital Audio corporation designed data format of firmware. The format seems to be suitable for their SDK for customers and closed. FFADO project implements the format parser in libffado2. Although the implementation is not enough in several points, it's good point to guess the format. I captured asynchronous packet by bus analyzer during updating firmware by Windows driver, aggregated the content of packet by script, then compared it to content of firmware. Some points are cleared (but not all). This commit adds parser for data binary shipped by Echo Digital Audio corporation. I note that driver package shipped by vendors for Fireworks based devices includes no EULA. I think this kind of reimplementation is not limited in the case. The content of file consists of two parts; header after magic bytes, and payload. The header includes metadata about the data of payload. There are four kind of data; for DSP, for IceLynx Micro, for arbitrary data, and for FPGA. The content except for magic bytes is hexadecimal string, therefore it's possible to print out by simple dump tool; cat(1) and less(1). The header includes CRC32 value of the decoded data and checksum of every bytes of the decoded data. When the header includes a flag, the CRC32 value is written to the end of area for firmware. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/file-cntr.c | 183 +++++++++++++++++++++++++++++++++ efw-downloader/src/file-cntr.h | 39 +++++++ efw-downloader/src/meson.build | 5 + 3 files changed, 227 insertions(+) create mode 100644 efw-downloader/src/file-cntr.c create mode 100644 efw-downloader/src/file-cntr.h diff --git a/efw-downloader/src/file-cntr.c b/efw-downloader/src/file-cntr.c new file mode 100644 index 0000000..1e159f7 --- /dev/null +++ b/efw-downloader/src/file-cntr.c @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include +#include +#include +#include + +#include + +#include "file-cntr.h" + +#define MAGIC_BYTES "1651 1 0 0 0\r\n" +#define PAYLOAD_OFFSET_QUADS 0x3f + +static int parse_entry(FILE *handle, uint32_t *val) +{ + char buf[16]; + char *end; + size_t len; + int err = 0; + + if (fgets(buf, sizeof(buf), handle) != buf) { + if (ferror(handle)) + err = -errno; + else + err = INT_MAX; // Use the value for EOF. + return err; + } + + len = strlen(buf); + if (buf[0] != '0' || buf[1] != 'x' || buf[len - 2] != '\r' || buf[len - 1] != '\n') + return -EPROTO; + buf[len - 2] = '\0'; + + *val = strtoul(buf, &end, 16); + if (*end != '\0') + return -EPROTO; + + return err; +} + +static int parse_header(FILE *handle, struct file_cntr_header *header) +{ + uint32_t *buf = (uint32_t *)header; + int err = 0; + int i; + + for (i = 0; i < 8; ++i) { + uint32_t val; + + err = parse_entry(handle, &val); + if (err != 0) + break; + + buf[i] = val; + } + + if (err == INT_MAX) + err = -ENODATA; + + return err; +} + +static int parse_payload(FILE *handle, unsigned int quads, uint32_t *blob) +{ + int err = 0; + int i; + + for (i = 0; i < quads; ++i) { + uint32_t val; + + err = parse_entry(handle, &val); + if (err != 0) + break; + + blob[i] = val; + } + + if (i != quads || err == INT_MAX) + err = -ENODATA; + + return err; +} + +static int check_crc32(struct file_cntr *cntr) +{ + uint32_t blob_crc32; + + blob_crc32 = crc32(0ul, (const uint8_t *)cntr->payload.blob, + cntr->payload.count * sizeof(*cntr->payload.blob)); + if (blob_crc32 != cntr->header.blob_crc32) + return -EINVAL; + + return 0; +} + +static int check_checksum(struct file_cntr *cntr) +{ + uint32_t checksum = 0; + int i, j; + + for (i = 0; i < cntr->payload.count; ++i) { + for (j = 3; j >= 0; --j) + checksum += (cntr->payload.blob[i] >> (j * 8)) & 0xff; + } + + if (checksum != cntr->header.blob_checksum) + return -EINVAL; + + return 0; +} + +int file_cntr_parse(struct file_cntr *cntr, const char *filepath) +{ + FILE *handle; + char buf[16]; + size_t till_data; + int err = 0; + + handle = fopen(filepath, "r"); + if (handle == NULL) + return -errno; + + // Check magic bytes. + if (fgets(buf, sizeof(buf), handle) != buf) { + if (ferror(handle)) + err = -errno; + else + err = -ENODATA; + goto end; + } + + if (memcmp(buf, MAGIC_BYTES, sizeof(MAGIC_BYTES))) { + err = -EPROTO; + goto end; + } + + // Parse header. + err = parse_header(handle, &cntr->header); + if (err < 0) + goto end; + + // Skip to area for data. + till_data = (PAYLOAD_OFFSET_QUADS - 7) * 12; + if (fseek(handle, till_data, SEEK_CUR) < 0) { + err = -errno; + goto end; + } + + cntr->payload.blob = calloc(cntr->header.blob_quads, sizeof(*cntr->payload.blob)); + if (cntr->payload.blob == NULL) { + err = -ENOMEM; + goto end; + } + cntr->payload.count = cntr->header.blob_quads; + + err = parse_payload(handle, cntr->header.blob_quads, cntr->payload.blob); + if (err < 0) { + free(cntr->payload.blob); + goto end; + } + + err = check_crc32(cntr); + if (err < 0) { + free(cntr->payload.blob); + goto end; + } + + err = check_checksum(cntr); + if (err < 0) + free(cntr->payload.blob); +end: + fclose(handle); + + return err; +} + +void file_cntr_release(struct file_cntr *cntr) +{ + if (cntr->payload.blob != NULL) + free(cntr->payload.blob); + cntr->payload.blob = NULL; +} diff --git a/efw-downloader/src/file-cntr.h b/efw-downloader/src/file-cntr.h new file mode 100644 index 0000000..c4657f1 --- /dev/null +++ b/efw-downloader/src/file-cntr.h @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#ifndef __FILE_CNTR__ +#define __FILE_CNTR__ + +#include + +enum blob_type { + BLOB_TYPE_DSP = 0, + BLOB_TYPE_ICELYNX = 1, + BLOB_TYPE_DATA = 2, + BLOB_TYPE_FPGA = 3, +}; + +struct file_cntr_header { + enum blob_type type; + uint32_t offset_addr; + uint32_t blob_quads; + uint32_t blob_crc32; + uint32_t blob_checksum; + uint32_t version; + uint32_t crc_in_region_end; + uint32_t cntr_quads; +}; + +struct file_cntr_payload { + uint32_t *blob; + size_t count; +}; + +struct file_cntr { + struct file_cntr_header header; + struct file_cntr_payload payload; +}; + +int file_cntr_parse(struct file_cntr *cntr, const char *filepath); +void file_cntr_release(struct file_cntr *cntr); + +#endif diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 8738d76..05d491d 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -11,12 +11,15 @@ hinawa = dependency('hinawa', version: '>=2.1', ) +zlib = dependency('zlib') + sources = [ 'main.c', 'efw-proto.c', 'config-rom.c', 'node-dispatcher.c', 'efw-commands.c', + 'file-cntr.c', 'subcmd-device.c', 'op-device-read.c', ] @@ -26,6 +29,7 @@ headers = [ 'config-rom.h', 'node-dispatcher.h', 'efw-commands.h', + 'file-cntr.h', 'subcmds.h', ] @@ -42,6 +46,7 @@ executable('efw-downloader', dependencies: [ gobject, hinawa, + zlib, ], install: true, ) From patchwork Fri Aug 21 07:31:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728561 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEB931392 for ; Fri, 21 Aug 2020 07:44:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 526462078D for ; Fri, 21 Aug 2020 07:44:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="FRJPs68L"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="XB9qIwos"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dV7jXK9/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 526462078D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CDA0C16A3; Fri, 21 Aug 2020 09:44:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CDA0C16A3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995887; bh=w42RtQqrjsrW1k7evi5ZzzKLwzbO+Wr2+b8FX2fyrhw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=FRJPs68L6kB5bINs90ukd1G2O/hch7C0tneOARinUWPlS8exehRyS0LE/ILWjs471 ZjkWf4sp0YK4UCtweIkvJubQTWyS4ao7x2yUNWlNyA/xXiOytF8fc2z+9Y2yx2C/Nt JmUNhotGYhkAkPXgxWHk0wOW+QQPmVTKfZtElo14= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1B5CEF80384; Fri, 21 Aug 2020 09:32:28 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id A4398F80343; Fri, 21 Aug 2020 09:32:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5E536F80322 for ; Fri, 21 Aug 2020 09:31:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5E536F80322 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="XB9qIwos"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dV7jXK9/" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 898F68D6; Fri, 21 Aug 2020 03:31:53 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=h4YioK3sQj4FJ w+dGh9BBRLRZzKMT9AN+fJGXzo4fGw=; b=XB9qIwosgscxokqfEvIXFAmQNan9U nLpQPT5yIU3E40Uv1g27MlF1DL9gPejg6ui0RJsb5o1dwITJLK2rMUTeGyIhRcr4 62dS1AX8CK//fH2hbux0icnZkDjFWzEhqwZuTIWkoIea78NgnEFxuh3OU2hV7uO0 pVVZsjMwwdH/DR03T3ys4XlIxk944gV6Uy+nDD7/l6sUwHw1yODXZLWak5yKfXHw pXAkuXtnvIV0w0TRWQTIhDilED0492IQ4+UxhZ7NC9xOoGGRVIKyg02iuCFs0Cvm Nre7RVrZKoYrvRI96G8p0ldDDvXFLQr1bEphstqnGL6XDlNHH/PMHOwJg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=h4YioK3sQj4FJw+dGh9BBRLRZzKMT9AN+fJGXzo4fGw=; b=dV7jXK9/ JIGiYHuY/Fc+dRdvaSQ4OX6uywMzz4xYuduwjFPHsBa5URQmjpeM70X8OXlIHPRH /m5nqjaeDuGEjuRPWr8LEPdRH5qNPBdvkdWuf93LFWdhJEw5+QrACzirrQLO/CIT Z37hua2sESf3FLd3Dz2lySAUC2lXel72JrvEscjGjULosbD3IPZzZZsvDm+Rrcqn jD2KzUFXEPC2F2y44k2IViz1fsiH34/qT7CueYXiKHeYm8auzyaArMO6JmvjUpQ+ bO3Gi+g7wSrtvHQJRxzmeosvvczIWtqAfczbi/3QYJLfV+ScjesgfL36BgdZ+Dba szb3LW769gGUkw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepudelnecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id D14C230600B1; Fri, 21 Aug 2020 03:31:51 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 22/25] efw-downloader: subcmd-file: add 'file' sub command Date: Fri, 21 Aug 2020 16:31:08 +0900 Message-Id: <20200821073111.134857-23-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit adds 'file' subcommand to handle firmware files. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/meson.build | 1 + efw-downloader/src/subcmd-file.c | 85 ++++++++++++++++++++++++++++++++ efw-downloader/src/subcmds.h | 2 + 3 files changed, 88 insertions(+) create mode 100644 efw-downloader/src/subcmd-file.c diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 05d491d..7d11332 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -22,6 +22,7 @@ sources = [ 'file-cntr.c', 'subcmd-device.c', 'op-device-read.c', + 'subcmd-file.c', ] headers = [ diff --git a/efw-downloader/src/subcmd-file.c b/efw-downloader/src/subcmd-file.c new file mode 100644 index 0000000..0ee7653 --- /dev/null +++ b/efw-downloader/src/subcmd-file.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include +#include +#include +#include +#include + +#include "subcmds.h" + +static void print_help() +{ + printf("Usage\n" + " efw-downloader file FILEPATH OPERATION ARGUMENTS\n" + "\n" + "where:\n" + " FILEPATH: The path to file.\n" + " OPERATION:\n" + " help: print this help message\n" + " ARGUMENTS:\n" + " depending on the OPERATION\n"); +} + +static int parse_args(int argc, char **argv, const char **filepath, const char **op_name) +{ + if (argc < 2) + return -EINVAL; + assert(strncmp(argv[1], "file", sizeof("file")) == 0); + + if (argc < 3) + return -EINVAL; + *filepath = argv[2]; + + if (argc < 4) + return -EINVAL; + *op_name = argv[3]; + + return 0; +} + +int subcmd_file(int argc, char **argv) +{ + struct { + const char *name; + size_t size; + int (*op)(int argc, char **argv, struct file_cntr *cntr); + } *entry, entries[] = { + }; + const char *op_name; + const char *filepath; + struct file_cntr cntr = {0}; + int err; + int i; + + err = parse_args(argc, argv, &filepath, &op_name); + if (err < 0) { + print_help(); + return EXIT_FAILURE; + } + + for (i = 0; i < sizeof(entries) / sizeof(entries[0]); ++i) { + entry = entries + i; + if (strncmp(op_name, entry->name, entry->size) == 0) + break; + } + if (i == sizeof(entries) / sizeof(entries[0])) { + print_help(); + return EXIT_FAILURE; + } + + err = file_cntr_parse(&cntr, filepath); + if (err < 0) { + printf("Fail to parse: %s\n", strerror(-err)); + return EXIT_FAILURE; + } + + err = entry->op(argc, argv, &cntr); + + file_cntr_release(&cntr); + + if (err < 0) + return EXIT_FAILURE; + + return EXIT_SUCCESS; +} diff --git a/efw-downloader/src/subcmds.h b/efw-downloader/src/subcmds.h index 70cbb5a..b1810b3 100644 --- a/efw-downloader/src/subcmds.h +++ b/efw-downloader/src/subcmds.h @@ -4,8 +4,10 @@ #define __SUBCMDS_H__ #include "efw-proto.h" +#include "file-cntr.h" int subcmd_device(int argc, char **argv); +int subcmd_file(int argc, char **argv); void op_device_read(int argc, char **argv, EfwProto *proto, GError **error); From patchwork Fri Aug 21 07:31:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728569 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5ACE813B1 for ; Fri, 21 Aug 2020 07:45:50 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E383620738 for ; Fri, 21 Aug 2020 07:45:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="iCDM3lMk"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="ZKTRxkVV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="d2iz8TXs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E383620738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6FE7A16B4; Fri, 21 Aug 2020 09:45:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6FE7A16B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995948; bh=OBSwhEBcqI35q6xG/aAUxKl6NhPWCiXlxOhWpXMVifA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iCDM3lMkIH8Ix48xHAPUffvuJuzXzGcsm0EjremAUj8by1drApDI1rkSA0q4alxVO IAeXEX2smyKqKhS5VBYBdDWdABPVUwojlyFUAxnSBy9D8Zrl7kCkjKFfv/0jzWAkEL Il2edwa8nvbB+8jr9thlqCw5EXVZhSDXeupiHvmM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9E65AF80393; Fri, 21 Aug 2020 09:32:30 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id ECEF3F80349; Fri, 21 Aug 2020 09:32:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E2001F80253 for ; Fri, 21 Aug 2020 09:31:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E2001F80253 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="ZKTRxkVV"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="d2iz8TXs" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 211F393B; Fri, 21 Aug 2020 03:31:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=BMe74KewABkkh TJIZlnshVWfepeONnyeatFA/AXINs8=; b=ZKTRxkVVIIcKG0rmkyls/+d7EB0Z5 Nf4Pfy8G1mwn9GofYjzx69szbPRywkRCf+Y8MhuIo/zlUFP8U+9jGxhnGJhGN0q4 T7NGimaJ8dNUL3WaevMQCQV5fMHTP0MSB8/3Uy0lQ6p4J3aTlvHjexLOK0a3ej+c OL91lNJlBoNv2AOddEFdPZnb2OKpcYYVem+ccfXSHGLvctozaV4bKPcfTL+lX6GW GWJHsrv6L3WZSGVaQspnGlN0b4JU6ljUr1yKthMsQx5k/IZWvJB1X7GWktp8xaKC +cPFX12qCouDkwadcibY3XBwRdnjt5nOIHmHEwe4GqnEQa15fniUTA1bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=BMe74KewABkkhTJIZlnshVWfepeONnyeatFA/AXINs8=; b=d2iz8TXs 4L4CTi48Sj2Ki6YUvzg2Nhnss7WLFFTJTkYwkU+PUk/Cvrsyr646BoatwYHllESr rWh3qOi02zeIe9XqmTmKaFpuKeKgKWlHGy/gAWcXLoMRu0guBywCF4dBIkld0Inh kKvjZxGxCzCRWnvHUvB1iU3mlppiUynQ9vQpfEKbtr7UHhRf91BTTivjQ2F9W5A0 z4dImNoJ/9771ZrEfZI+2VnZPBd9a2DLHIXYvudwX2LTKMOGzMVqDYFh9BVYV2TL gxNnKXne3zJt1hgnzrVRndn6EU3HJfkEdpV3Km+YtZE1G+n+s+XXVu+2NWyn/dz/ cdW8SuR9LW/OcQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpeevfefffe ektefgveegfeelheffhfeujedtjeevtefhkeevkedtjeejvddtjefhjeenucfkphepudek tddrvdefhedrfedrheegnecuvehluhhsthgvrhfuihiivgepudelnecurfgrrhgrmhepmh grihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 6308A30600A9; Fri, 21 Aug 2020 03:31:53 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 23/25] efw-downloader: subcmd-file: add parse operation Date: Fri, 21 Aug 2020 16:31:09 +0900 Message-Id: <20200821073111.134857-24-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit adds parse operation in file sub command to dump contents of firmware files. Signed-off-by: Takashi Sakamoto --- efw-downloader/src/main.c | 2 + efw-downloader/src/meson.build | 1 + efw-downloader/src/op-file-parse.c | 106 +++++++++++++++++++++++++++++ efw-downloader/src/subcmd-file.c | 2 + efw-downloader/src/subcmds.h | 2 + 5 files changed, 113 insertions(+) create mode 100644 efw-downloader/src/op-file-parse.c diff --git a/efw-downloader/src/main.c b/efw-downloader/src/main.c index e150cc8..a9b52eb 100644 --- a/efw-downloader/src/main.c +++ b/efw-downloader/src/main.c @@ -14,6 +14,7 @@ static void print_help() "where:\n" " SUBCOMMAND:\n" " device: operate for device for unit on IEEE 1394 bus\n" + " file: operate for firmware file" " help: print help\n" " OPTIONS: optional arguments dependent on the subcommand\n"); } @@ -26,6 +27,7 @@ int main(int argc, char **argv) int (*op)(int argc, char **argv); } *entry, entries[] = { { "device", sizeof("device"), subcmd_device }, + { "file", sizeof("file"), subcmd_file }, }; const char *subcmd; int i; diff --git a/efw-downloader/src/meson.build b/efw-downloader/src/meson.build index 7d11332..8f7e363 100644 --- a/efw-downloader/src/meson.build +++ b/efw-downloader/src/meson.build @@ -23,6 +23,7 @@ sources = [ 'subcmd-device.c', 'op-device-read.c', 'subcmd-file.c', + 'op-file-parse.c', ] headers = [ diff --git a/efw-downloader/src/op-file-parse.c b/efw-downloader/src/op-file-parse.c new file mode 100644 index 0000000..c9c81d2 --- /dev/null +++ b/efw-downloader/src/op-file-parse.c @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Copyright (c) 2020 Takashi Sakamoto +#include +#include +#include +#include +#include +#include + +#include "file-cntr.h" + +static void print_help() +{ + printf("Usage\n" + " efw-downloader file PATH parse [--help | -h]\n" + "\n" + "where:\n" + " --help, -h: print this help message\n"); +} + +static const char *get_blob_type_name(enum blob_type type) +{ + const char *name; + + switch (type) { + case BLOB_TYPE_DSP: + name = "DSP"; + break; + case BLOB_TYPE_ICELYNX: + name = "IceLynx"; + break; + case BLOB_TYPE_DATA: + name = "data"; + break; + case BLOB_TYPE_FPGA: + name = "FPGA"; + break; + default: + name = "invalid"; + break; + } + + return name; +} + +static void file_cntr_dump_header(const struct file_cntr *cntr) +{ + printf("Container header:\n"); + printf(" type: %d (%s)\n", cntr->header.type, get_blob_type_name(cntr->header.type)); + printf(" offset_addr: 0x%08x\n", cntr->header.offset_addr); + printf(" blob_quads: %u\n", cntr->header.blob_quads); + printf(" blob_crc32: 0x%08x\n", cntr->header.blob_crc32); + printf(" blob_checksum: 0x%08x\n", cntr->header.blob_checksum); + printf(" version: 0x%08x\n", cntr->header.version); + printf(" crc_in_region_end: %d\n", cntr->header.crc_in_region_end); + printf(" total_quads: %d\n", cntr->header.cntr_quads); +} + +static void file_cntr_dump_payload(const struct file_cntr *cntr) +{ + int i; + + printf("Container payload:\n"); + for (i = 0; i < cntr->payload.count; ++i) + printf(" %08x: %08x\n", cntr->header.offset_addr + i * 4, cntr->payload.blob[i]); +} + +static int parse_args(int argc, char **argv, bool *help) +{ + int i; + + if (argc < 4) + return -EINVAL; + assert(!strncmp(argv[3], "parse", sizeof("parse"))); + + *help = false; + for (i = 0; i < argc; ++i) { + if (strncmp(argv[i], "--help", sizeof("--help")) == 0 || + strncmp(argv[i], "-h", sizeof("-h")) == 0) { + *help = true; + break; + } + } + + return 0; +} + +int op_file_parse(int argc, char **argv, struct file_cntr *cntr) +{ + bool help = false; + int err; + + err = parse_args(argc, argv, &help); + if (err < 0) + return err; + + if (help) { + print_help(); + return 0; + } + + file_cntr_dump_header(cntr); + file_cntr_dump_payload(cntr); + + return 0; +} diff --git a/efw-downloader/src/subcmd-file.c b/efw-downloader/src/subcmd-file.c index 0ee7653..a61378c 100644 --- a/efw-downloader/src/subcmd-file.c +++ b/efw-downloader/src/subcmd-file.c @@ -16,6 +16,7 @@ static void print_help() "where:\n" " FILEPATH: The path to file.\n" " OPERATION:\n" + " parse: parse and dump binary blob released by Echo Audio\n" " help: print this help message\n" " ARGUMENTS:\n" " depending on the OPERATION\n"); @@ -45,6 +46,7 @@ int subcmd_file(int argc, char **argv) size_t size; int (*op)(int argc, char **argv, struct file_cntr *cntr); } *entry, entries[] = { + { "parse", sizeof("parse"), op_file_parse }, }; const char *op_name; const char *filepath; diff --git a/efw-downloader/src/subcmds.h b/efw-downloader/src/subcmds.h index b1810b3..99d3bef 100644 --- a/efw-downloader/src/subcmds.h +++ b/efw-downloader/src/subcmds.h @@ -11,4 +11,6 @@ int subcmd_file(int argc, char **argv); void op_device_read(int argc, char **argv, EfwProto *proto, GError **error); +int op_file_parse(int argc, char **argv, struct file_cntr *cntr); + #endif From patchwork Fri Aug 21 07:31:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728571 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6BB213B1 for ; Fri, 21 Aug 2020 07:46:26 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A4FE20738 for ; Fri, 21 Aug 2020 07:46:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="caHEFXGJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="GP1Jq+53"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dqP1L8T4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A4FE20738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ECE0D16B6; Fri, 21 Aug 2020 09:45:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ECE0D16B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597995985; bh=1M0xMF6jh/kQkej4AfnVrwJUI4xFNs4rjRFSQTbinrw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=caHEFXGJZ/sl49BXOe7UeXU9NLo+KvuPeBLDgETa9O0KJe/OAlLQhkqGenenxVCGr 7SX+s4BRhX+P8h5qRrJHwjrcXk/76CpDHn+4XWQox/y7s8X/iSH22Cmtm1dNM6ShwI vOXU8QLYdP5m/wdG3/+frPsOEy/sPV2oU6031itU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C07C8F803AE; Fri, 21 Aug 2020 09:32:31 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id F1ADBF8034F; Fri, 21 Aug 2020 09:32:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8C961F80260 for ; Fri, 21 Aug 2020 09:31:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8C961F80260 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="GP1Jq+53"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="dqP1L8T4" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id A955E882; Fri, 21 Aug 2020 03:31:56 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=3BFWBP5PBZ6Hi BLP9nUpES7DxhrMVS/Dhly6Y5qWPG4=; b=GP1Jq+53E5eJiemZeR1uPI72DWOIz JV9CutAngV5J75RAgzIStmgf1iIBFKm0U+1DJ/wr7FY7XqKX2mQNLLpq74HBuyMu SdIIxX1pwn3OqQgZtTbz3jxswTDHaBcGi2wgtQ9jXV8XRHyLG+ccbAsHNCLHObsh wOsvJzUdK445vtwSLkgz2VAepkGjU0i87x+LTE734P14QNR611ihdR5B437cbCgU HZJF4Yniej8wxDYVEksdDW4iKcbQrnh2YQ9od3JtfBaXTbLhd5hHMTgZWqUJWm5y SfmKAL8q5uTnX9iu2C+VuPh7/3xsLEbxpCcGtgQFomGJYJg4+kNkLY/Mw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=3BFWBP5PBZ6HiBLP9nUpES7DxhrMVS/Dhly6Y5qWPG4=; b=dqP1L8T4 xT+0uCQL9/5mhpk0YYyeMgWYjuQvhc8hwOQvN7cgN1Pyz3FDTo3Pi/ulymF7IFSN LMH6vqiYfWwjWrXtqZyiEbPwroMf3GW8Rzi05LpUkALgriVG3tmW7da29tuYdqoa 3naiQsnJF1TpqnLl7ZdOL2N/y6nx4w/NPZiiwBhciOkGUZyrIaPxqj0PsWAl0n21 wDuaZIfneWFhgTeIRcZeLolHl3n0yHtZPoL7nO8PHSsF14EIAGdG4NtfYJyj4s5U 5rCZHOu1VdyO3V2/N3CHIdSDdWRgPZ9qQQZUhNBZRBuzHlhYzy2e4uqbliJ/rcGB 4oA/tXAEWciExQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpefgieevte efveeludehfefhveeukefffeffjeeuvdeggeegfedvteegjefffedugeenucffohhmrghi nhepghhithhhuhgsrdgtohhmnecukfhppedukedtrddvfeehrdefrdehgeenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhi sehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id E563530600B1; Fri, 21 Aug 2020 03:31:54 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 24/25] efw-downloader: man: add online manual Date: Fri, 21 Aug 2020 16:31:10 +0900 Message-Id: <20200821073111.134857-25-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit adds online manual. Additionally, this commit adds 'man' meson option to decide whether installing the manual or not. Signed-off-by: Takashi Sakamoto --- efw-downloader/man/efw-downloader.1 | 162 ++++++++++++++++++++++++++++ efw-downloader/meson.build | 4 + efw-downloader/meson_options.txt | 5 + 3 files changed, 171 insertions(+) create mode 100644 efw-downloader/man/efw-downloader.1 create mode 100644 efw-downloader/meson_options.txt diff --git a/efw-downloader/man/efw-downloader.1 b/efw-downloader/man/efw-downloader.1 new file mode 100644 index 0000000..5b38c28 --- /dev/null +++ b/efw-downloader/man/efw-downloader.1 @@ -0,0 +1,162 @@ +.TH EFW\-DOWNLOADER 1 "20 Aug 2020" "alsa\-tools" + +.SH NAME +efw\-downloader \- operate on-board flash memory for Fireworks board module + +.SH SYNOPSIS + +.B efw-downloader +.I subcommand +.I options ... + +subcommand = +.B device +| +.B file + +options = ( depends on +.I subcommand +) + +.SH DESCRIPTION + +The +.B efw-downloader +is a command\-line tool to operate on-board flash memory for Fireworks board +module by Fireworks protocol. + +.SH SUBCOMMAND + +.SS device +Operate on-board flash memory by Fireworks protocol. + +.SS file +Operate firmware files. + +.SH OPTIONS + +.SS For device subcommand + +.B efw-downloader device +.I path +.I operation +.I arguments + +.TP +.B path +The path to special file for firewire character device corresponding to +node of Fireworks board module. + +.TP +.B operation +One of +.I read +, and +.I help +operations. + +.TP +.B arguments for read operation + +.B efw-downloader device +.I path +read +.I offset +.I size +[ +.I --debug +| +.I --help +| +.I -h +] + +The +.I offset +argument is the hexadecimal number of offset on flash memory. + +The +.I size +argument is +the hexadecimal number of size to read, aligned to quadlet automatically. + +The optional +.I --debug +argument is to enable debug output for Fireworks protocol. + +The optional +.I --help +and +.I -h +arguments are for help message. + +.TP +.B arguments for help operation + +.B efw-downloader device +.I path +help + +The help operation have no arguments. + +.SS For file subcommand + +.B efw-downloader file +.I filepath +.I operation +.I arguments + +.TP +.B filepath +The path to file of firmware blob included in driver package shipped by vendors. + +.TP +.B operation +One of +.I parse +, and +.I help +operations. + +.TP +.B arguments for parse operation + +.B efw-downloader file +.I filepath +.I parse +[ +.I --help +| +.I -h +] + +The +.I --help +and +.I -h +argument is for help message. + +.TP +.B arguments for help operation + +.B efw-downloder file +.I filepath +.I help + +The help operation have no arguments. + +.SH EXIT_STATUS + +.I EXIT_SUCCESS +(0) if run time successfully finished, else +.I EXIT_FAILURE +(1). + +.SH REPORTING BUGS +Report any bugs to mailing list in ALSA community + where the development and maintenance is +primarily discussed. Bug tracking service of alsa\-tools repository on +github.com is also available. + +.SH AUTHOR +Takashi Sakamoto diff --git a/efw-downloader/meson.build b/efw-downloader/meson.build index 9664100..bd7ce21 100644 --- a/efw-downloader/meson.build +++ b/efw-downloader/meson.build @@ -8,3 +8,7 @@ project('efw-downloader', 'c', ) subdir('src') + +if get_option('man') + install_man('man/efw-downloader.1') +endif diff --git a/efw-downloader/meson_options.txt b/efw-downloader/meson_options.txt new file mode 100644 index 0000000..83ac978 --- /dev/null +++ b/efw-downloader/meson_options.txt @@ -0,0 +1,5 @@ +option('man', + type: 'boolean', + value: true, + description: 'install online manual', +) From patchwork Fri Aug 21 07:31:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11728573 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F4AA739 for ; Fri, 21 Aug 2020 07:46:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2FE1D20738 for ; Fri, 21 Aug 2020 07:46:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="tEoHyvEb"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="VjwyHU4+"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qb/tpPF9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2FE1D20738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AD59416BB; Fri, 21 Aug 2020 09:46:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AD59416BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597996013; bh=xSL7vLFiufMvyeL2EA9DIeDW6xH8c3sayA5tkk7KDho=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tEoHyvEbpQvTDRM1df3DWsywrDP2xIiQlJ7vllGR30L+67ARMG115/cBRW+LViE30 O6fmSai+x4bnsDvYb/Lv05bB/EPFUDoMcWNDsTlyq+Y2fb0vJOvTDuA075o7tPzWm/ K9kMHOMI9qiGJc5uVVv7jsW1vRbTEL48AXaxVsko= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 19B33F803B2; Fri, 21 Aug 2020 09:32:33 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id B286DF8034F; Fri, 21 Aug 2020 09:32:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 15CDFF80321 for ; Fri, 21 Aug 2020 09:32:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 15CDFF80321 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="VjwyHU4+"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qb/tpPF9" Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 3FBB1972; Fri, 21 Aug 2020 03:31:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 21 Aug 2020 03:31:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=5VOfFKimvpk+B rmzzYZxBeFsugpeMuRuC5PysM43MGU=; b=VjwyHU4+ZOTTGZBjUkDOil5oZ1Sd0 pHyhAET6NkODdEE4iOUQ6fCDehj/hXmMRABhjQDhVmmICMEUbDHbdikgipDV9Gan RtE2Sth4U7H849+tdtEDEYjDdkjMTZpu6GuwEvEdiO/ol45RD8U8Q/wHMt3tuCNl XC8t1TmOZ2qYQIRHaYz+E9Y8COLc5JoywzX4PQ6r3ZxUYFWI9qJx3XPpdtzfytWd dkrVPK7xaK6+mUez3qsON4Rx4EHzftERv5RrAH/FqohSxiN1W1JLcCEdlKUMCwl8 z0HWmDQO8G5wQqKLpI+39DlXCgmGbzr19TzqvtG4qusljcPFqtiYkZOOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=5VOfFKimvpk+BrmzzYZxBeFsugpeMuRuC5PysM43MGU=; b=qb/tpPF9 W6BNlIx4uQnE/e9PBbTeDMOmJrqUQPcqu2/Aq14SdxZInpY7DQDDlItBrnblYn/S qLQTXB0vC+apUAD/ZNvpJ+vWcIypz+Yar3KHFcMtB0IFR7kaG2K2nDoMTi4gZVFJ R//zgUkpzxrUssE6uwrxexM9QV0DUssmpUmPlL/vHvmJ95mGyui9zMz9Ua+uiw9I Z5BczaUREyoFQt88e5xbLZY6CnQy5A0PujmNJ7npXKSkSTZ0VGSKKr9XYvKtCohd DLQuVDQUGyUVupO/BXoReMZ9vwZ465F5FaV6xI15Q8ZBHnblsLWrAdG+iH3xZxut PF66lzmQ6ZGcfA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudduuddgudduudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefvrghkrghshhhiucfurghkrghmohhtohcuoehoqdhtrghk rghshhhisehsrghkrghmohgttghhihdrjhhpqeenucggtffrrghtthgvrhhnpefftdffje ejgfefleeiffetgfeiieegtdfghedvtdevteffteehvdeuiefhheejgeenucffohhmrghi nhepghhnohhmvgdrohhrghdpghhithhhuhgsrdgtohhmpdiilhhisgdrnhgvthdpmhgvsh honhgsuhhilhgurdgtohhmnecukfhppedukedtrddvfeehrdefrdehgeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhise hsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Received: from workstation.flets-east.jp (ad003054.dynamic.ppp.asahi-net.or.jp [180.235.3.54]) by mail.messagingengine.com (Postfix) with ESMTPA id 7812B30600A9; Fri, 21 Aug 2020 03:31:56 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [PATCH 25/25] efw-downloader: add README formatted by reStructuredText Date: Fri, 21 Aug 2020 16:31:11 +0900 Message-Id: <20200821073111.134857-26-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821073111.134857-1-o-takashi@sakamocchi.jp> References: <20200821073111.134857-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: ffado-devel@lists.sourceforge.net, alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit adds README so that developers and users can get description about this tool easily. Signed-off-by: Takashi Sakamoto --- efw-downloader/README.rst | 167 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 efw-downloader/README.rst diff --git a/efw-downloader/README.rst b/efw-downloader/README.rst new file mode 100644 index 0000000..8d35ee3 --- /dev/null +++ b/efw-downloader/README.rst @@ -0,0 +1,167 @@ +============== +efw-downloader +============== + +2020/08/21 +Takashi Sakamoto + +Introduction +============ + +This tool is designed to operate on-board flash memory for devices with Fireworks board module. The +goal is to download firmware for the module. + +At present, the tool can perform read operation from flash memory, and parse operation for firmware +file, therefore it's unlikely to make your device bricked. + +Target devices +============== + +* LOUD Audio, LLC (Mackie) + + * Onyx 400F + * Onyx 1200F + +* Echo Digital Audio corporation + + * Audiofire 12 (with DSP) + * Audiofire 12 (with FPGA) + * Audiofire 8 (with DSP) + * Audiofire 8 (with FPGA) + * Audiofire 2 + * Audiofire 4 + * Audiofire Pre8 + +* Gibson guitar corporation + + * Robot Interface Pack (RIP) + +Background +========== + +Echo Digital Audio corporation shipped Fireworks board module. This module is designed for audio and +music units on IEEE 1394 bus with rich features for direct monitoring, on-board routing, and so on. + +The module consists of two combinations of two ICs: + +* A combination: + + * Texus Instruments TSB43Cx43A (IceLynx Micro) + * Texus Instruments TMS320C6713B (DSP) + +* Another combination: + + * Texus Instruments TSB43Cx43A (IceLynx Micro) + * Xilinx Spartan XC35250E (FPGA) + +The module has on-board flash memory to store firmware for the above ICs and allows software to +read, erase, and write to the memory by Fireworks protocol. + +For your information, Echo Digital Audio corporation have US patent. The patent describes that two +processors are used for data processing in IEEE 1394 bus, and for sample processing from/to DAC/ADC. +These two processors independently run via memory bank. I guess that IceLynx Micro is used for the +former role, and DSP/FPGA is used for the latter role. + +Echo Digital Audio corporation provided a series of firmware blob to their customers and bundled the +firmware to driver package for Windows and macOS. The firmware blob has specific structure designed +by Echo Digital Audio corporation. + +Prerequities +============ + +Dependencies for build and runtime +------------------------------------- + +* libglib-2.0 and libgobject v2.34 or later. (https://gitlab.gnome.org/GNOME/glib) +* libhinawa v2.1 or later (https://github.com/alsa-project/libhinawa) +* zlib (https://zlib.net/) + +For build +--------- + +* Meson Build system (https://mesonbuild.com/) is used. + +For runtime +----------- + +* ALSA fireworks driver uses the same address space on 1394 OHCI controller for Fireworks protocol, + therefore it's better to unload the driver in advance of using the tool. +* FFADO applications should be stopped to avoid misfortune. + +Build and Install +================= + +:: + + $ meson (--prefix=xxx, -Dman=false). build + $ cd build + $ ninja + $ meson install + +* The ``man`` meson option is to install online manual for the tool. Default is ``true``. + +Instruction +=========== + +The tool consists of two sub commands; ``device`` and ``file``. The former is to operate on-board +flash memory, and the latter is to handle file of firmware blob. +:: + + efw-downloader SUBCOMMAND OPTIONS ... + + SUBCOMMAND = device | file + + OPTIONS = ( depends on subcommand ) + +The ``device`` sub command consists of several operations. At present, ``read`` operation is just +supported but the other operations are planned to add for future release. +:: + + efw-downloader device PATH OPERATION ARGUMENTS + + PATH The path to special file for firewire character device corresponding to node of Fireworks board module. + + OPERATION + One of read , and help operations. + + ARGUMENTS for read operation + + efw-downloader device PATH read OFFSET SIZE [ --debug | --help | -h ] + + The offset argument is the hexadecimal number of offset on flash memory. + + The size argument is the hexadecimal number of size to read, aligned to quadlet automatically. + + The optional --debug argument is to enable debug output for Fireworks protocol. + + The optional --help and -h arguments are for help message. + + ARGUMENTS for help operation + + efw-downloader device PATH help + + The help operation have no arguments. + +The ``file`` sub command consists of several operations as well. At present, ``parse`` operation is +just supported but the other operations are planned to add for future release. +:: + + efw-downloader file FILEPATH OPERATION ARGUMENTS + + FILEPATH + The path to file of firmware blob included in driver package shipped by vendors. + + OPERATION + One of parse , and help operations. + + ARGUMENTS for parse operation + + efw-downloader file FILEPATH parse [ --help | -h ] + + The --help and -h argument is for help message. + + ARGUMENTS for help operation + + efw-downloder file FILEPATH help + + The help operation have no arguments.