From cc1daf578efe21780fd321e00704feee42ed1a6c Mon Sep 17 00:00:00 2001 From: crazii Date: Sat, 27 Apr 2024 22:04:15 +0800 Subject: [PATCH] bugfix on compiler optimization for MMIO, using volatile. --- mpxplay/au_cards/au_base.h | 44 ++++++++++++++++++------------------- mpxplay/au_cards/sc_inthd.c | 2 ++ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/mpxplay/au_cards/au_base.h b/mpxplay/au_cards/au_base.h index da9f8b05..70b6d6cf 100644 --- a/mpxplay/au_cards/au_base.h +++ b/mpxplay/au_cards/au_base.h @@ -285,33 +285,33 @@ typedef int mpxp_ptrsize_t; #define funcbit_copy(var1,var2,bit) ((var1)=((var1)&(~(bit)))|((var2)&(bit))) // note LE: lowest byte first, highest byte last -#define PDS_GETB_8S(p) *((mpxp_int8_t *)(p)) // signed 8 bit (1 byte) -#define PDS_GETB_8U(p) *((mpxp_uint8_t *)(p)) // unsigned 8 bit (1 byte) -#define PDS_GETB_LE16(p) *((mpxp_int16_t *)(p)) // 2bytes LE to short -#define PDS_GETB_LEU16(p)*((mpxp_uint16_t *)(p)) // 2bytes LE to unsigned short -#define PDS_GETB_BE16(p) pds_bswap16(*((mpxp_uint16_t *)(p)))// 2bytes BE to unsigned short -#define PDS_GETB_LE32(p) *((mpxp_int32_t *)(p)) // 4bytes LE to long -#define PDS_GETB_LEU32(p) *((mpxp_uint32_t *)(p)) // 4bytes LE to unsigned long -#define PDS_GETB_BE32(p) pds_bswap32(*((mpxp_uint32_t *)(p)))// 4bytes BE to unsigned long +#define PDS_GETB_8S(p) *((volatile mpxp_int8_t *)(p)) // signed 8 bit (1 byte) +#define PDS_GETB_8U(p) *((volatile mpxp_uint8_t *)(p)) // unsigned 8 bit (1 byte) +#define PDS_GETB_LE16(p) *((volatile mpxp_int16_t *)(p)) // 2bytes LE to short +#define PDS_GETB_LEU16(p)*((volatile mpxp_uint16_t *)(p)) // 2bytes LE to unsigned short +#define PDS_GETB_BE16(p) pds_bswap16(*((volatile mpxp_uint16_t *)(p)))// 2bytes BE to unsigned short +#define PDS_GETB_LE32(p) *((volatile mpxp_int32_t *)(p)) // 4bytes LE to long +#define PDS_GETB_LEU32(p) *((volatile mpxp_uint32_t *)(p)) // 4bytes LE to unsigned long +#define PDS_GETB_BE32(p) pds_bswap32(*((volatile mpxp_uint32_t *)(p)))// 4bytes BE to unsigned long #define PDS_GETB_LE24(p) ((PDS_GETB_LEU32(p))&0x00ffffff) #define PDS_GETB_BE24(p) ((PDS_GETB_BE32(p))>>8) -#define PDS_GETB_LE64(p) *((mpxp_int64_t *)(p)) // 8bytes LE to int64 -#define PDS_GETB_LEU64(p) *((mpxp_uint64_t *)(p)) // 8bytes LE to uint64 -#define PDS_GETB_BEU64(p) ((((mpxp_uint64_t)PDS_GETB_BE32(p))<<32)|((mpxp_uint64_t)PDS_GETB_BE32(((mpxp_uint8_t *)(p)+4)))) -#define PDS_GETBD_BEU64(d,p) *(((mpxp_uint32_t *)(d))+1)=PDS_GETB_BE32(p); *((mpxp_uint32_t *)(d))=PDS_GETB_BE32(((mpxp_uint32_t *)(p))+1) +#define PDS_GETB_LE64(p) *((volatile mpxp_int64_t *)(p)) // 8bytes LE to int64 +#define PDS_GETB_LEU64(p) *((volatile mpxp_uint64_t *)(p)) // 8bytes LE to uint64 +#define PDS_GETB_BEU64(p) ((((volatile mpxp_uint64_t)PDS_GETB_BE32(p))<<32)|((mpxp_uint64_t)PDS_GETB_BE32(((volatile mpxp_uint8_t *)(p)+4)))) +#define PDS_GETBD_BEU64(d,p) *(((volatile mpxp_uint32_t *)(d))+1)=PDS_GETB_BE32(p); *((volatile mpxp_uint32_t *)(d))=PDS_GETB_BE32(((volatile mpxp_uint32_t *)(p))+1) #define PDS_GET4C_LE32(a,b,c,d) ((mpxp_uint32_t)(a) | ((mpxp_uint32_t)(b) << 8) | ((mpxp_uint32_t)(c) << 16) | ((mpxp_uint32_t)(d) << 24)) #define PDS_GETS_LE32(p) ((char *)&(p)) // unsigned long to 4 bytes string -#define PDS_PUTB_8S(p,v) *((mpxp_int8_t *)(p))=(v) // -#define PDS_PUTB_8U(p,v) *((mpxp_uint8_t *)(p))=(v) // -#define PDS_PUTB_LE16(p,v) *((mpxp_int16_t *)(p))=(v) // -#define PDS_PUTB_LEU16(p,v) *((mpxp_uint16_t *)(p))=(v) // -#define PDS_PUTB_BEU16(p,v) *((mpxp_uint16_t *)(p))=pds_bswap16((v))// -#define PDS_PUTB_LE24(p,v) *((mpxp_uint8_t *)(p))=((v)&0xff); PDS_PUTB_LE16(((mpxp_uint8_t*)p+1),((v)>>8)) -#define PDS_PUTB_LE32(p,v) *((mpxp_int32_t *)(p))=(v) // long to 4bytes LE -#define PDS_PUTB_BEU32(p,v) *((mpxp_uint32_t *)(p))=pds_bswap32((v)) // long to 4bytes BE -#define PDS_PUTB_LE64(p,v) *((mpxp_int64_t *)(p))=(v) // int64 to 8bytes LE -#define PDS_PUTB_BEU64(p,v) *((mpxp_uint32_t *)(p)+1)=pds_bswap32((v)&0xffffffff); *((mpxp_uint32_t *)(p))=pds_bswap32((mpxp_uint64_t)(v)>>32) +#define PDS_PUTB_8S(p,v) *((volatile mpxp_int8_t *)(p))=(v) // +#define PDS_PUTB_8U(p,v) *((volatile mpxp_uint8_t *)(p))=(v) // +#define PDS_PUTB_LE16(p,v) *((volatile mpxp_int16_t *)(p))=(v) // +#define PDS_PUTB_LEU16(p,v) *((volatile mpxp_uint16_t *)(p))=(v) // +#define PDS_PUTB_BEU16(p,v) *((volatile mpxp_uint16_t *)(p))=pds_bswap16((v))// +#define PDS_PUTB_LE24(p,v) *((volatile mpxp_uint8_t *)(p))=((v)&0xff); PDS_PUTB_LE16(((mpxp_uint8_t*)p+1),((v)>>8)) +#define PDS_PUTB_LE32(p,v) *((volatile mpxp_int32_t *)(p))=(v) // long to 4bytes LE +#define PDS_PUTB_BEU32(p,v) *((volatile mpxp_uint32_t *)(p))=pds_bswap32((v)) // long to 4bytes BE +#define PDS_PUTB_LE64(p,v) *((volatile mpxp_int64_t *)(p))=(v) // int64 to 8bytes LE +#define PDS_PUTB_BEU64(p,v) *((volatile mpxp_uint32_t *)(p)+1)=pds_bswap32((v)&0xffffffff); *((mpxp_uint32_t *)(p))=pds_bswap32((mpxp_uint64_t)(v)>>32) #define PDS_DIRECTORY_SEPARATOR_CHAR_DOSWIN '\\' #define PDS_DIRECTORY_SEPARATOR_CHAR_UNXFTP '/' diff --git a/mpxplay/au_cards/sc_inthd.c b/mpxplay/au_cards/sc_inthd.c index fe6676f1..f7f64f1e 100644 --- a/mpxplay/au_cards/sc_inthd.c +++ b/mpxplay/au_cards/sc_inthd.c @@ -805,8 +805,10 @@ static struct hda_gnode *parse_output_jack(struct intelhd_card_s *card,int jack_ if(node->wid_caps&AC_WCAP_DIGITAL) continue; }else{ +#ifndef SBEMU //it's logical conflict with the following code that set AC_PINCTL_OUT_EN if(!(node->pin_ctl&AC_PINCTL_OUT_EN)) continue; +#endif } clear_check_flags(card); err = parse_output_path(card, node, 0);