Alsa-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: alsa-devel@alsa-project.org, clemens@ladisch.de,
	ffado-devel@lists.sf.net
Subject: Re: [PATCH 26/39] fireworks: Add command/response functionality into hwdep interface
Date: Fri, 28 Feb 2014 07:58:32 +0100
Message-ID: <s5h4n3jn2p3.wl%tiwai@suse.de> (raw)
In-Reply-To: <1393558072-25926-27-git-send-email-o-takashi@sakamocchi.jp>

At Fri, 28 Feb 2014 12:27:39 +0900,
Takashi Sakamoto wrote:
> 
> This commit adds two functionality for hwdep interface, adds two parameters for
> this driver, add a node for proc interface.
> 
> To receive responses from devices, this driver already allocate own callback
> into private address area in host controller. This means no one can allocate
> its own callback to the address. So this driver must give a way for user
> applications to receive responses.
> 
> This commit adds a functionality to receive responses via hwdep interface. The
> application can receive responses to read from this interface. To achieve this,
> this commit adds a buffer to queue responses. The default size of this buffer is
> 1024 bytes. This size can be changed to give preferrable size to
> 'resp_buf_size' parameter for this driver. The application should notice rest
> of space in this buffer because this driver don't push responses when this
> buffer has no space.
> 
> Additionaly, this commit adds a functionality to transmit commands via hwdep
> interface. The application can transmit commands to write into this interface.
> I note that the application can transmit one command at once, but can receive
> as many responses as possible untill the user-buffer is full.
> 
> When using these interfaces, the application must keep maximum number of
> sequence number in command within the number in firewire.h because this driver
> uses this number to distinguish the response is against the command by the
> application or this driver.
> 
> Usually responses against commands which the application transmits are pushed
> into this buffer. But to enable 'resp_buf_debug' parameter for this driver, all
> responses are pushed into the buffer. When using this mode, I reccomend to
> expand the size of buffer.
> 
> Finally this commit adds a new node into proc interface to output status of the
> buffer.
> 
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---
>  include/uapi/sound/firewire.h                    |  18 +++
>  sound/firewire/fireworks/fireworks.c             |  17 +++
>  sound/firewire/fireworks/fireworks.h             |  22 +--
>  sound/firewire/fireworks/fireworks_command.c     |   6 +-
>  sound/firewire/fireworks/fireworks_hwdep.c       | 129 ++++++++++++++---
>  sound/firewire/fireworks/fireworks_proc.c        |  19 +++
>  sound/firewire/fireworks/fireworks_transaction.c | 176 ++++++++++++++++++++---
>  7 files changed, 340 insertions(+), 47 deletions(-)
> 
> diff --git a/include/uapi/sound/firewire.h b/include/uapi/sound/firewire.h
> index fc9afb2..7f4c419 100644
> --- a/include/uapi/sound/firewire.h
> +++ b/include/uapi/sound/firewire.h
> @@ -7,6 +7,7 @@
>  
>  #define SNDRV_FIREWIRE_EVENT_LOCK_STATUS	0x000010cc
>  #define SNDRV_FIREWIRE_EVENT_DICE_NOTIFICATION	0xd1ce004e
> +#define SNDRV_FIREWIRE_EVENT_EFW_RESPONSE	0x4e617475
>  
>  struct snd_firewire_event_common {
>  	unsigned int type; /* SNDRV_FIREWIRE_EVENT_xxx */
> @@ -22,10 +23,27 @@ struct snd_firewire_event_dice_notification {
>  	unsigned int notification; /* DICE-specific bits */
>  };
>  
> +#define SND_EFW_TRANSACTION_SEQNUM_MAX	((uint32_t)(BIT(28) - 1))
> +/* each field should be in big endian */
> +struct snd_efw_transaction {
> +	uint32_t length;
> +	uint32_t version;
> +	uint32_t seqnum;
> +	uint32_t category;
> +	uint32_t command;
> +	uint32_t status;
> +	uint32_t params[0];
> +};
> +struct snd_firewire_event_efw_response {
> +	unsigned int type;
> +	uint32_t response[0];	/* some responses */
> +};
> +
>  union snd_firewire_event {
>  	struct snd_firewire_event_common            common;
>  	struct snd_firewire_event_lock_status       lock_status;
>  	struct snd_firewire_event_dice_notification dice_notification;
> +	struct snd_firewire_event_efw_response      efw_response;
>  };
>  
>  
> diff --git a/sound/firewire/fireworks/fireworks.c b/sound/firewire/fireworks/fireworks.c
> index 38986c0..7846285 100644
> --- a/sound/firewire/fireworks/fireworks.c
> +++ b/sound/firewire/fireworks/fireworks.c
> @@ -24,6 +24,8 @@ MODULE_LICENSE("GPL v2");
>  static int index[SNDRV_CARDS]	= SNDRV_DEFAULT_IDX;
>  static char *id[SNDRV_CARDS]	= SNDRV_DEFAULT_STR;
>  static bool enable[SNDRV_CARDS]	= SNDRV_DEFAULT_ENABLE_PNP;
> +unsigned int resp_buf_size	= 1024;
> +bool resp_buf_debug		= false;
>  
>  module_param_array(index, int, NULL, 0444);
>  MODULE_PARM_DESC(index, "card index");
> @@ -31,6 +33,10 @@ module_param_array(id, charp, NULL, 0444);
>  MODULE_PARM_DESC(id, "ID string");
>  module_param_array(enable, bool, NULL, 0444);
>  MODULE_PARM_DESC(enable, "enable Fireworks sound card");
> +module_param(resp_buf_size, uint, 0444);
> +MODULE_PARM_DESC(resp_buf_size, "response buffer size (default 1024)");
> +module_param(resp_buf_debug, bool, 0444);
> +MODULE_PARM_DESC(resp_buf_debug, "store all responses to buffer");
>  
>  static DEFINE_MUTEX(devices_mutex);
>  static unsigned int devices_used;
> @@ -165,6 +171,7 @@ efw_probe(struct fw_unit *unit,
>  {
>  	struct snd_card *card;
>  	struct snd_efw *efw;
> +	void *resp_buf;
>  	int card_index, err;
>  
>  	mutex_lock(&devices_mutex);
> @@ -178,6 +185,13 @@ efw_probe(struct fw_unit *unit,
>  		goto end;
>  	}
>  
> +	/* prepare response buffer */
> +	resp_buf = kzalloc(resp_buf_size, GFP_KERNEL);

Better to have a sanity check of resp_buf_size value.  You can't trust
a value given by a user.


Takashi

  reply index

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28  3:27 [GIT PULL][PATCH 00/39] Enhancement of support for Firewire devices Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 01/39] firewire-lib: Rename functions, structure, member for AMDTP Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 02/39] firewire-lib: Add macros instead of fixed value " Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 03/39] firewire-lib: Add 'direction' member to 'amdtp_stream' structure Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 04/39] firewire-lib: Split some codes into functions to reuse for both streams Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 05/39] firewire-lib: Add support for AMDTP in-stream and PCM capture Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 06/39] firewire-lib: Add support for MIDI capture/playback Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 07/39] firewire-lib: Give syt value as parameter to handle_out_packet() Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 08/39] firewire-lib: Add support for duplex streams synchronization in blocking mode Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 09/39] firewire-lib: Add sort function for transmitted packet Takashi Sakamoto
2014-02-28  6:40   ` Takashi Iwai
2014-02-28 14:31     ` Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 10/39] firewire-lib: Add transfer delay to synchronized duplex streams Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 11/39] firewire-lib: Add support for channel mapping Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 12/39] firewire-lib: Rename macros, variables and functions for CMP Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 13/39] firewire-lib: Add 'direction' member to 'cmp_connection' structure Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 14/39] firewire-lib: Add handling output connection by CMP Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 15/39] firewire-lib: Add a new function to check others' connection Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 16/39] firewire-lib: Add some AV/C general commands Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 17/39] firewire-lib: Add quirks for Fireworks Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 18/39] firewire-lib: Add a fallback at RCODE_CANCELLED Takashi Sakamoto
2014-02-28 20:25   ` Stefan Richter
2014-02-28 20:39     ` Stefan Richter
2014-03-01  3:18     ` Takashi Sakamoto
2014-03-01 10:10       ` Stefan Richter
2014-03-01 12:22         ` Takashi Sakamoto
2014-03-01 14:20           ` Stefan Richter
2014-03-04  1:35             ` [FFADO-devel] " Jonathan Woithe
2014-03-04  8:33               ` Stefan Richter
2014-03-04  9:28                 ` Stefan Richter
2014-03-01 10:34   ` Stefan Richter
2014-03-01 12:23     ` Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 19/39] fireworks: Add skelton for Fireworks based devices Takashi Sakamoto
2014-02-28  6:51   ` Takashi Iwai
2014-02-28 15:05     ` Takashi Sakamoto
2014-02-28 15:10       ` Takashi Iwai
2014-02-28 15:36         ` Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 20/39] fireworks: Add transaction and some commands Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 21/39] fireworks: Add connection and stream management Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 22/39] fireworks: Add proc interface for debugging purpose Takashi Sakamoto
2014-02-28  6:54   ` Takashi Iwai
2014-03-01 13:17     ` Takashi Sakamoto
2014-03-03  9:01       ` Takashi Iwai
2014-03-04 14:10         ` Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 23/39] fireworks: Add MIDI interface Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 24/39] fireworks: Add PCM interface Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 25/39] fireworks: Add hwdep interface Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 26/39] fireworks: Add command/response functionality into " Takashi Sakamoto
2014-02-28  6:58   ` Takashi Iwai [this message]
2014-03-01 13:18     ` Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 27/39] bebob: Add skelton for BeBoB based devices Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 28/39] bebob: Add commands and connections/streams management Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 29/39] bebob: Add proc interface for debugging purpose Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 30/39] bebob: Add MIDI interface Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 31/39] bebob: Add PCM interface Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 32/39] bebob: Add hwdep interface Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 33/39] bebob: Prepare for device specific operations Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 34/39] bebob: Add support for Terratec PHASE, EWS series and Aureon Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 35/39] bebob: Add support for Yamaha GO series Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 36/39] bebob: Add support for Focusrite Saffire/SaffirePro series Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 37/39] bebob: Add support for M-Audio usual Firewire series Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 38/39] bebob: Send a cue to load firmware for M-Audio " Takashi Sakamoto
2014-02-28  3:27 ` [PATCH 39/39] bebob: Add support for M-Audio special " Takashi Sakamoto
2014-03-01 10:53   ` Stefan Richter
2014-03-01 13:06     ` Takashi Sakamoto
2014-03-01 14:32       ` Stefan Richter
2014-02-28  6:36 ` [GIT PULL][PATCH 00/39] Enhancement of support for Firewire devices Takashi Iwai
2014-03-01 13:14   ` Takashi Sakamoto
     [not found] <5316963F.1000206@sakamocchi.jp>
2014-03-05 10:47 ` [GIT PULL][PATCH 00/39 v2] " Takashi Sakamoto
2014-03-05 10:48   ` [PATCH 26/39] fireworks: Add command/response functionality into hwdep interface Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5h4n3jn2p3.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sf.net \
    --cc=o-takashi@sakamocchi.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Alsa-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/alsa-devel/0 alsa-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 alsa-devel alsa-devel/ https://lore.kernel.org/alsa-devel \
		alsa-devel@alsa-project.org
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.alsa-project.alsa-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git