All of lore.kernel.org
 help / color / mirror / Atom feed
From: linux@audioscience.com
To: patch@alsa-project.org
Cc: tiwai@suse.de,
	Eliot Blennerhassett <eblennerhassett@audioscience.com>,
	alsa-devel@alsa-project.org
Subject: [PATCH 02/15] Increase request and response buffer sizes
Date: Fri, 22 Jul 2011 15:52:39 +1200	[thread overview]
Message-ID: <1311306785-23116-5-git-send-email-linux@audioscience.com> (raw)
In-Reply-To: <1311306785-23116-1-git-send-email-linux@audioscience.com>

From: Eliot Blennerhassett <eblennerhassett@audioscience.com>

Allow for up to 256 bytes of extra data on top of standard hpi
request and response sizes.

Signed-off-by: Eliot Blennerhassett <eblennerhassett@audioscience.com>
---
 sound/pci/asihpi/hpi6205.c |   15 ++++++++-------
 sound/pci/asihpi/hpi6205.h |   25 +++++++++++++++++++------
 sound/pci/asihpi/hpicmn.c  |   13 +++++++------
 3 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index faff9e3..8831a6f 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -2085,13 +2085,13 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
 	u16 err = 0;
 
 	message_count++;
-	if (phm->size > sizeof(interface->u)) {
+	if (phm->size > sizeof(interface->u.message_buffer)) {
 		phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL;
-		phr->specific_error = sizeof(interface->u);
+		phr->specific_error = sizeof(interface->u.message_buffer);
 		phr->size = sizeof(struct hpi_response_header);
 		HPI_DEBUG_LOG(ERROR,
 			"message len %d too big for buffer %zd \n", phm->size,
-			sizeof(interface->u));
+			sizeof(interface->u.message_buffer));
 		return 0;
 	}
 
@@ -2123,18 +2123,19 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
 
 	/* read the result */
 	if (time_out) {
-		if (interface->u.response_buffer.size <= phr->size)
+		if (interface->u.response_buffer.response.size <= phr->size)
 			memcpy(phr, &interface->u.response_buffer,
-				interface->u.response_buffer.size);
+				interface->u.response_buffer.response.size);
 		else {
 			HPI_DEBUG_LOG(ERROR,
 				"response len %d too big for buffer %d\n",
-				interface->u.response_buffer.size, phr->size);
+				interface->u.response_buffer.response.size,
+				phr->size);
 			memcpy(phr, &interface->u.response_buffer,
 				sizeof(struct hpi_response_header));
 			phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
 			phr->specific_error =
-				interface->u.response_buffer.size;
+				interface->u.response_buffer.response.size;
 			phr->size = sizeof(struct hpi_response_header);
 		}
 	}
diff --git a/sound/pci/asihpi/hpi6205.h b/sound/pci/asihpi/hpi6205.h
index df2f02c..ec0827b 100644
--- a/sound/pci/asihpi/hpi6205.h
+++ b/sound/pci/asihpi/hpi6205.h
@@ -1,7 +1,7 @@
 /*****************************************************************************
 
     AudioScience HPI driver
-    Copyright (C) 1997-2010  AudioScience Inc. <support@audioscience.com>
+    Copyright (C) 1997-2011  AudioScience Inc. <support@audioscience.com>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of version 2 of the GNU General Public License as
@@ -70,15 +70,28 @@ The Host located memory buffer that the 6205 will bus master
 in and out of.
 ************************************************************/
 #define HPI6205_SIZEOF_DATA (16*1024)
+
+struct message_buffer_6205 {
+	struct hpi_message message;
+	char data[256];
+};
+
+struct response_buffer_6205 {
+	struct hpi_response response;
+	char data[256];
+};
+
+union buffer_6205 {
+	struct message_buffer_6205 message_buffer;
+	struct response_buffer_6205 response_buffer;
+	u8 b_data[HPI6205_SIZEOF_DATA];
+};
+
 struct bus_master_interface {
 	u32 host_cmd;
 	u32 dsp_ack;
 	u32 transfer_size_in_bytes;
-	union {
-		struct hpi_message_header message_buffer;
-		struct hpi_response_header response_buffer;
-		u8 b_data[HPI6205_SIZEOF_DATA];
-	} u;
+	union buffer_6205 u;
 	struct controlcache_6205 control_cache;
 	struct async_event_buffer_6205 async_buffer;
 	struct hpi_hostbuffer_status
diff --git a/sound/pci/asihpi/hpicmn.c b/sound/pci/asihpi/hpicmn.c
index 801dcd8..fe2e1ae 100644
--- a/sound/pci/asihpi/hpicmn.c
+++ b/sound/pci/asihpi/hpicmn.c
@@ -315,8 +315,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
 	short found = 1;
 	struct hpi_control_cache_info *pI;
 	struct hpi_control_cache_single *pC;
-	struct hpi_control_cache_pad *p_pad;
-
+	u16 response_size;
 	if (!find_control(phm->obj_index, p_cache, &pI)) {
 		HPI_DEBUG_LOG(VERBOSE,
 			"HPICMN find_control() failed for adap %d\n",
@@ -326,11 +325,15 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
 
 	phr->error = 0;
 
+	/* set the default response size */
+	response_size =
+		sizeof(struct hpi_response_header) +
+		sizeof(struct hpi_control_res);
+
 	/* pC is the default cached control strucure. May be cast to
 	   something else in the following switch statement.
 	 */
 	pC = (struct hpi_control_cache_single *)pI;
-	p_pad = (struct hpi_control_cache_pad *)pI;
 
 	switch (pI->control_type) {
 
@@ -529,9 +532,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache,
 		pI->control_index, pI->control_type, phm->u.c.attribute);
 
 	if (found)
-		phr->size =
-			sizeof(struct hpi_response_header) +
-			sizeof(struct hpi_control_res);
+		phr->size = response_size;
 
 	return found;
 }
-- 
1.7.0.4

  parent reply	other threads:[~2011-07-22  3:52 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-22  3:52 [PATCH 00/15] ALSA: asihpi - update from HPI 4.06 to 4.08 linux
2011-07-22  3:52 ` [PATCH 01/15] ALSA: asihpi - Give more meaningful name to hpi request message type linux
2011-07-22  3:52 ` [PATCH 01/15] " linux
2011-07-22  3:52 ` [PATCH 02/15] ALSA: asihpi - Increase request and response buffer sizes linux
2011-07-22  3:52 ` linux [this message]
2011-07-22  3:52 ` [PATCH 03/15] ALSA: asihpi - Remove controlex structs and associated special data transfer code linux
2011-07-22  3:52 ` [PATCH 03/15] " linux
2011-07-22  3:52 ` [PATCH 04/15] ALSA: asihpi - DSP code loader API now independent of OS linux
2011-07-22  5:56   ` Takashi Iwai
2011-07-22  3:52 ` [PATCH 04/15] " linux
2011-07-22  3:52 ` [PATCH 05/15] ALSA: asihpi - Revise snd_pcm_debug_name, get rid of DEBUG_NAME macro linux
2011-07-22  3:52 ` [PATCH 05/15] " linux
2011-07-22  3:52 ` [PATCH 06/15] ALSA: asihpi - Remove spurious adapter index check linux
2011-07-22  3:52 ` [PATCH 06/15] " linux
2011-07-22  3:52 ` [PATCH 07/15] ALSA: asihpi - Remove unused structures, macros and functions linux
2011-07-22  3:52 ` [PATCH 07/15] " linux
2011-07-22  3:52 ` [PATCH 08/15] ALSA: asihpi - Fix minor typos and spelling linux
2011-07-22  3:52 ` [PATCH 08/15] " linux
2011-07-22  3:52 ` [PATCH 09/15] ALSA: asihpi - Make local function static linux
2011-07-22  3:52 ` [PATCH 09/15] " linux
2011-07-22  3:52 ` [PATCH 10/15] Add new node and message defines linux
2011-07-22  3:52 ` [PATCH 10/15] ALSA: asihpi - " linux
2011-07-22  3:52 ` [PATCH 11/15] ALSA: asihpi - Explicitly include mutex.h linux
2011-07-22  3:52 ` [PATCH 11/15] " linux
2011-07-22  3:52 ` [PATCH 12/15] ALSA: asihpi - Use size_t for sizeof result linux
2011-07-22  3:52 ` [PATCH 12/15] " linux
2011-07-22  3:53 ` [PATCH 13/15] ALSA: asihpi - Control name updates linux
2011-07-22  3:53 ` [PATCH 13/15] " linux
2011-07-22  3:53 ` [PATCH 14/15] Add volume mute controls linux
2011-07-22  3:53 ` [PATCH 14/15] ALSA: asihpi - " linux
2011-07-22  6:01   ` Takashi Iwai
2011-07-22  3:53 ` [PATCH 15/15] ALSA: asihpi - HPI version 4.08 linux
2011-07-22  3:53 ` [PATCH 15/15] " linux
2011-07-22  4:04 ` Please ignore duplicates Eliot Blennerhassett
2011-07-22  6:03 ` [PATCH 00/15] ALSA: asihpi - update from HPI 4.06 to 4.08 Takashi Iwai
     [not found] ` <4E28F717.90204@audioscience.com>
2011-07-22  6:06   ` asihpi - update from HPI 4.06 to 4.08 - Firmware Takashi Iwai

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=1311306785-23116-5-git-send-email-linux@audioscience.com \
    --to=linux@audioscience.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=eblennerhassett@audioscience.com \
    --cc=patch@alsa-project.org \
    --cc=tiwai@suse.de \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.