ALSA: CA0132 - Ensure SCP packet is little-endian format
PATCH 1/1 ALSA: CA0132 - Ensure SCP packet is little-endian format
From: Ian Minett <[email protected]>
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.
Quoted 3 lines
Quoted 2 lines
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.
Thanks,
- Ian
---
The DSP firmware expects the SCP data to be in little-endian format regardless of the host architecture.
---
sound/pci/hda/patch_ca0132.c +6 -1
@@ -28,6 +28,7 @@#include <linux/mutex.h> #include <linux/module.h> #include <linux/firmware.h> +#include <asm/unaligned.h> #include <sound/core.h> #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);
Signature · 1 line
1.7.4.1
At Wed, 26 Sep 2012 18:23:59 -0700,
Quoted 8 lines · Ian Minett
From: Ian Minett <[email protected]>
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.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
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...:
Quoted 28 lines
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 <[email protected]>---
sound/pci/hda/patch_ca0132.c +2
-0@@ -28,6 +28,7 @@#include <linux/mutex.h> #include <linux/module.h> #include <linux/firmware.h> +#include <asm/unaligned.h> #include <sound/core.h> #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 */
sound/pci/hda/patch_ca0132.c static int dspio_send(struct hda_codec *codec, unsigned int reg, · line 714
Quoted 10 lines
sound/pci/hda/patch_ca0132.c +4
-1+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