From: Takashi Iwai Subject: Re: [PATCH 1/1] ALSA: CA0132 - Ensure SCP packet is little-endian format Date: Mon, 08 Oct 2012 10:15:02 +0200 Message-ID: References: <1348709039-4210-1-git-send-email-ian_minett@creativelabs.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 710A62616C8 for ; Mon, 8 Oct 2012 10:15:02 +0200 (CEST) In-Reply-To: <1348709039-4210-1-git-send-email-ian_minett@creativelabs.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Ian Minett Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Wed, 26 Sep 2012 18:23:59 -0700, Ian Minett wrote: > > From: Ian Minett > > Hi Takashi, > Great - good to hear the previous DSP loader patches are now living in the > hda-ca0132-dsp branch. This patch is based on that branch, and addresses > the SCP packet endianness. > > >> The firmware does need to be reloaded when the chip loses power, so it > >> doesn't survive S3. > >OK, we need suspend/resume hooks, too. > > Do we need to do anything specific to handle this? The firmware is already > restored upon S3 by the current caching code. Then it's OK. I didn't check that the firmware loader gets called in the resume path in patch_ca0132.c. Looking at the patch now...: > Thanks, > - Ian > > --- > > The DSP firmware expects the SCP data to be in little-endian > format regardless of the host architecture. > > Signed-off-by: Ian Minett > > --- > diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c > index 2fd3121..4d7cda4 100644 > --- a/sound/pci/hda/patch_ca0132.c > +++ b/sound/pci/hda/patch_ca0132.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #include > #include "hda_codec.h" > #include "hda_local.h" > @@ -701,9 +702,13 @@ static int dspio_send(struct hda_codec *codec, unsigned int reg, > unsigned int res; > int retry = 50; > > + /* Handling for Big Endian machine */ > + unsigned int val; > + put_unaligned_le32(data, &val); > + > /* send bits of data specified by reg to dsp */ > do { > - res = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, reg, data); > + res = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, reg, val); > if ((res >= 0) && (res != VENDOR_STATUS_DSPIO_BUSY)) > return res; > } while (--retry); I don't think this is the right place to fix the endianness. The value passed to this function should be already in a right order. The wrong endian value should be corrected at the place where you read the value. thanks, Takashi