1d028d02dSMathieu Sonet /* 2d028d02dSMathieu Sonet * LM4549 Audio Codec Interface 3d028d02dSMathieu Sonet * 4d028d02dSMathieu Sonet * Copyright (c) 2011 5d028d02dSMathieu Sonet * Written by Mathieu Sonet - www.elasticsheep.com 6d028d02dSMathieu Sonet * 74d8db4e4SStefan Weil * This code is licensed under the GPL. 8d028d02dSMathieu Sonet * 9d028d02dSMathieu Sonet * ***************************************************************** 10d028d02dSMathieu Sonet */ 11d028d02dSMathieu Sonet 12d028d02dSMathieu Sonet #ifndef HW_LM4549_H 13d028d02dSMathieu Sonet #define HW_LM4549_H 14d028d02dSMathieu Sonet 15d028d02dSMathieu Sonet #include "audio/audio.h" 16d4842052SMarkus Armbruster #include "exec/hwaddr.h" 17d028d02dSMathieu Sonet 18d028d02dSMathieu Sonet typedef void (*lm4549_callback)(void *opaque); 19d028d02dSMathieu Sonet 20d028d02dSMathieu Sonet #define LM4549_BUFFER_SIZE (512 * 2) /* 512 16-bit stereo samples */ 21d028d02dSMathieu Sonet 22d028d02dSMathieu Sonet 23d028d02dSMathieu Sonet typedef struct { 24d028d02dSMathieu Sonet QEMUSoundCard card; 25d028d02dSMathieu Sonet SWVoiceOut *voice; 26d028d02dSMathieu Sonet uint32_t voice_is_active; 27d028d02dSMathieu Sonet 28d028d02dSMathieu Sonet uint16_t regfile[128]; 29d028d02dSMathieu Sonet lm4549_callback data_req_cb; 30d028d02dSMathieu Sonet void *opaque; 31d028d02dSMathieu Sonet 32d028d02dSMathieu Sonet uint16_t buffer[LM4549_BUFFER_SIZE]; 33d028d02dSMathieu Sonet uint32_t buffer_level; 34d028d02dSMathieu Sonet } lm4549_state; 35d028d02dSMathieu Sonet 36d028d02dSMathieu Sonet extern const VMStateDescription vmstate_lm4549_state; 37d028d02dSMathieu Sonet 38d028d02dSMathieu Sonet 39*79d3e56cSMartin Kletzander void lm4549_init(lm4549_state *s, lm4549_callback data_req, void *opaque, 40*79d3e56cSMartin Kletzander Error **errp); 41a8170e5eSAvi Kivity uint32_t lm4549_read(lm4549_state *s, hwaddr offset); 42a8170e5eSAvi Kivity void lm4549_write(lm4549_state *s, hwaddr offset, uint32_t value); 43d028d02dSMathieu Sonet uint32_t lm4549_write_samples(lm4549_state *s, uint32_t left, uint32_t right); 44d028d02dSMathieu Sonet 45175de524SMarkus Armbruster #endif /* HW_LM4549_H */ 46