audio: two small fixes.

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJadBgAAAoJEEy22O7T6HE4RHgQANxYU8qUNmDiNqyel4OdyVBs
 nGprFzNVWk1aJd5zHAPJRuEt7PMwnPQhQSYdhFlrUFNwQNSRk9DOhu1QIYVTQd65
 98Stvnxb8g+IS33Nkv3UNglLcROW+K+WEmaqK/XvQ8poAv9CZ0HSqGsshwfjHp9i
 iqFf+xPDg0yT9z/a3KrhrSl4GhOFcxlbQ8dZytcEKTvsLGm8vvn//QPe4H9J1RQj
 I/eAXIC5rKrr5WZ/N4vBTsEtRY0aZu/49W7nS9omRGDDrWn0jkdJigELhjlrX5ru
 zeek89HDY1yvxEM6vonFdNvrriFTa+tLT4izfB5fpoBeuzkcHCKlve1yemyVCMMn
 tdPvQPGhApWXC9opDvHc2EV2UWdE81FRKew7H+DytxN3PzmmwPBXPTYn35Ubkavv
 n/sNT1evt98AmLUGQlXnMUMkBqmtHZJY4Y0hPYR1K1f3ZDGHVXKLJQ1hBH8L/jvB
 UUaP/khZc71J9y3zip9/wu+taXXv/4fZ4NQEVykWzYemroj3Bop1fLu04m0X1wx4
 N6yUJHGUGbZ12speCXNwrbPFWlFgGyzBz4yddSmq3WbAiSR+ijZFsB7C0TGRoeoV
 Mtu4FXzBwF1VWeDq9r+Hy1b7tiJ6FcuJypGlrRoFZ8lPmTj4beSdnDBjYB4olYxW
 vJMAaLuRk9kE97YRwW5T
 =MwSl
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/audio-20180202-pull-request' into staging

audio: two small fixes.

# gpg: Signature made Fri 02 Feb 2018 07:49:20 GMT
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/audio-20180202-pull-request:
  hw/audio/sb16.c: change dolog() to qemu_log_mask()
  hw/audio/wm8750: move WM8750 declarations from i2c/i2c.h to audio/wm8750.h

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2018-02-02 15:33:57 +00:00
commit fabbd691fd
8 changed files with 82 additions and 52 deletions

View File

@ -25,6 +25,7 @@
#include "hw/block/flash.h"
#include "ui/console.h"
#include "hw/i2c/i2c.h"
#include "hw/audio/wm8750.h"
#include "sysemu/block-backend.h"
#include "exec/address-spaces.h"
#include "ui/pixel_ops.h"
@ -1691,7 +1692,7 @@ static void musicpal_init(MachineState *machine)
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
}
wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
wm8750_dev = i2c_create_slave(i2c, TYPE_WM8750, MP_WM_ADDR);
dev = qdev_create(NULL, "mv88w8618_audio");
s = SYS_BUS_DEVICE(dev);
qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);

View File

@ -24,6 +24,7 @@
#include "hw/devices.h"
#include "hw/arm/sharpsl.h"
#include "ui/console.h"
#include "hw/audio/wm8750.h"
#include "audio/audio.h"
#include "hw/boards.h"
#include "sysemu/block-backend.h"
@ -745,7 +746,7 @@ static void spitz_i2c_setup(PXA2xxState *cpu)
DeviceState *wm;
/* Attach a WM8750 to the bus */
wm = i2c_create_slave(bus, "wm8750", 0);
wm = i2c_create_slave(bus, TYPE_WM8750, 0);
spitz_wm8750_addr(wm, 0, 0);
qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM,

View File

@ -23,6 +23,7 @@
#include "hw/block/flash.h"
#include "sysemu/block-backend.h"
#include "ui/console.h"
#include "hw/audio/wm8750.h"
#include "audio/audio.h"
#include "exec/address-spaces.h"
#include "sysemu/qtest.h"
@ -346,7 +347,7 @@ static void z2_init(MachineState *machine)
z2_lcd = ssi_create_slave(mpu->ssp[1], "zipit-lcd");
bus = pxa2xx_i2c_bus(mpu->i2c[0]);
i2c_create_slave(bus, TYPE_AER915, 0x55);
wm = i2c_create_slave(bus, "wm8750", 0x1b);
wm = i2c_create_slave(bus, TYPE_WM8750, 0x1b);
mpu->i2s->opaque = wm;
mpu->i2s->codec_out = wm8750_dac_dat;
mpu->i2s->codec_in = wm8750_adc_dat;

View File

@ -13,6 +13,7 @@
#include "hw/sysbus.h"
#include "hw/hw.h"
#include "hw/i2c/i2c.h"
#include "hw/audio/wm8750.h"
#include "audio/audio.h"
#define MP_AUDIO_SIZE 0x00001000

View File

@ -29,6 +29,8 @@
#include "hw/qdev.h"
#include "qemu/timer.h"
#include "qemu/host-utils.h"
#include "qemu/log.h"
#include "qapi/error.h"
#define dolog(...) AUD_log ("sb16", __VA_ARGS__)
@ -123,7 +125,7 @@ static int magic_of_irq (int irq)
case 10:
return 8;
default:
dolog ("bad irq %d\n", irq);
qemu_log_mask(LOG_GUEST_ERROR, "bad irq %d\n", irq);
return 2;
}
}
@ -140,7 +142,7 @@ static int irq_of_magic (int magic)
case 8:
return 10;
default:
dolog ("bad irq magic %d\n", magic);
qemu_log_mask(LOG_GUEST_ERROR, "bad irq magic %d\n", magic);
return -1;
}
}
@ -258,8 +260,8 @@ static void dma_cmd8 (SB16State *s, int mask, int dma_len)
s->align = (1 << s->fmt_stereo) - 1;
if (s->block_size & s->align) {
dolog ("warning: misaligned block size %d, alignment %d\n",
s->block_size, s->align + 1);
qemu_log_mask(LOG_GUEST_ERROR, "warning: misaligned block size %d,"
" alignment %d\n", s->block_size, s->align + 1);
}
ldebug ("freq %d, stereo %d, sign %d, bits %d, "
@ -338,8 +340,8 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, int dma_len)
s->highspeed = 0;
s->align = (1 << (s->fmt_stereo + (s->fmt_bits == 16))) - 1;
if (s->block_size & s->align) {
dolog ("warning: misaligned block size %d, alignment %d\n",
s->block_size, s->align + 1);
qemu_log_mask(LOG_GUEST_ERROR, "warning: misaligned block size %d,"
" alignment %d\n", s->block_size, s->align + 1);
}
if (s->freq) {
@ -391,7 +393,8 @@ static void command (SB16State *s, uint8_t cmd)
if (cmd > 0xaf && cmd < 0xd0) {
if (cmd & 8) {
dolog ("ADC not yet supported (command %#x)\n", cmd);
qemu_log_mask(LOG_UNIMP, "ADC not yet supported (command %#x)\n",
cmd);
}
switch (cmd >> 4) {
@ -399,7 +402,7 @@ static void command (SB16State *s, uint8_t cmd)
case 12:
break;
default:
dolog ("%#x wrong bits\n", cmd);
qemu_log_mask(LOG_GUEST_ERROR, "%#x wrong bits\n", cmd);
}
s->needed_bytes = 3;
}
@ -453,7 +456,7 @@ static void command (SB16State *s, uint8_t cmd)
goto warn;
case 0x35:
dolog ("0x35 - MIDI command not implemented\n");
qemu_log_mask(LOG_UNIMP, "0x35 - MIDI command not implemented\n");
break;
case 0x40:
@ -487,34 +490,38 @@ static void command (SB16State *s, uint8_t cmd)
case 0x74:
s->needed_bytes = 2; /* DMA DAC, 4-bit ADPCM */
dolog ("0x75 - DMA DAC, 4-bit ADPCM not implemented\n");
qemu_log_mask(LOG_UNIMP, "0x75 - DMA DAC, 4-bit ADPCM not"
" implemented\n");
break;
case 0x75: /* DMA DAC, 4-bit ADPCM Reference */
s->needed_bytes = 2;
dolog ("0x74 - DMA DAC, 4-bit ADPCM Reference not implemented\n");
qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 4-bit ADPCM Reference not"
" implemented\n");
break;
case 0x76: /* DMA DAC, 2.6-bit ADPCM */
s->needed_bytes = 2;
dolog ("0x74 - DMA DAC, 2.6-bit ADPCM not implemented\n");
qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 2.6-bit ADPCM not"
" implemented\n");
break;
case 0x77: /* DMA DAC, 2.6-bit ADPCM Reference */
s->needed_bytes = 2;
dolog ("0x74 - DMA DAC, 2.6-bit ADPCM Reference not implemented\n");
qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 2.6-bit ADPCM Reference"
" not implemented\n");
break;
case 0x7d:
dolog ("0x7d - Autio-Initialize DMA DAC, 4-bit ADPCM Reference\n");
dolog ("not implemented\n");
qemu_log_mask(LOG_UNIMP, "0x7d - Autio-Initialize DMA DAC, 4-bit"
" ADPCM Reference\n");
qemu_log_mask(LOG_UNIMP, "not implemented\n");
break;
case 0x7f:
dolog (
"0x7d - Autio-Initialize DMA DAC, 2.6-bit ADPCM Reference\n"
);
dolog ("not implemented\n");
qemu_log_mask(LOG_UNIMP, "0x7d - Autio-Initialize DMA DAC, 2.6-bit"
" ADPCM Reference\n");
qemu_log_mask(LOG_UNIMP, "not implemented\n");
break;
case 0x80:
@ -586,7 +593,7 @@ static void command (SB16State *s, uint8_t cmd)
break;
case 0xe7:
dolog ("Attempt to probe for ESS (0xe7)?\n");
qemu_log_mask(LOG_UNIMP, "Attempt to probe for ESS (0xe7)?\n");
break;
case 0xe8: /* read test reg */
@ -613,7 +620,7 @@ static void command (SB16State *s, uint8_t cmd)
goto warn;
default:
dolog ("Unrecognized command %#x\n", cmd);
qemu_log_mask(LOG_UNIMP, "Unrecognized command %#x\n", cmd);
break;
}
}
@ -632,8 +639,8 @@ static void command (SB16State *s, uint8_t cmd)
return;
warn:
dolog ("warning: command %#x,%d is not truly understood yet\n",
cmd, s->needed_bytes);
qemu_log_mask(LOG_UNIMP, "warning: command %#x,%d is not truly understood"
" yet\n", cmd, s->needed_bytes);
goto exit;
}
@ -735,9 +742,8 @@ static void complete (SB16State *s)
break;
case 0x42: /* FT2 sets output freq with this, go figure */
#if 0
dolog ("cmd 0x42 might not do what it think it should\n");
#endif
qemu_log_mask(LOG_UNIMP, "cmd 0x42 might not do what it think it"
" should\n");
case 0x41:
s->freq = dsp_get_hilo (s);
ldebug ("set freq %d\n", s->freq);
@ -820,7 +826,8 @@ static void complete (SB16State *s)
break;
default:
dolog ("complete: unrecognized command %#x\n", s->cmd);
qemu_log_mask(LOG_UNIMP, "complete: unrecognized command %#x\n",
s->cmd);
return;
}
}
@ -1095,10 +1102,9 @@ static void mixer_write_datab(void *opaque, uint32_t nport, uint32_t val)
dma = ctz32 (val & 0xf);
hdma = ctz32 (val & 0xf0);
if (dma != s->dma || hdma != s->hdma) {
dolog (
"attempt to change DMA "
"8bit %d(%d), 16bit %d(%d) (val=%#x)\n",
dma, s->dma, hdma, s->hdma, val);
qemu_log_mask(LOG_GUEST_ERROR, "attempt to change DMA 8bit"
" %d(%d), 16bit %d(%d) (val=%#x)\n", dma, s->dma,
hdma, s->hdma, val);
}
#if 0
s->dma = dma;
@ -1108,8 +1114,8 @@ static void mixer_write_datab(void *opaque, uint32_t nport, uint32_t val)
break;
case 0x82:
dolog ("attempt to write into IRQ status register (val=%#x)\n",
val);
qemu_log_mask(LOG_GUEST_ERROR, "attempt to write into IRQ status"
" register (val=%#x)\n", val);
return;
default:
@ -1181,8 +1187,9 @@ static int SB_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len)
int till, copy, written, free;
if (s->block_size <= 0) {
dolog ("invalid block size=%d nchan=%d dma_pos=%d dma_len=%d\n",
s->block_size, nchan, dma_pos, dma_len);
qemu_log_mask(LOG_GUEST_ERROR, "invalid block size=%d nchan=%d"
" dma_pos=%d dma_len=%d\n", s->block_size, nchan,
dma_pos, dma_len);
return dma_pos;
}
@ -1376,7 +1383,7 @@ static void sb16_realizefn (DeviceState *dev, Error **errp)
reset_mixer (s);
s->aux_ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, aux_timer, s);
if (!s->aux_ts) {
dolog ("warning: Could not create auxiliary timer\n");
error_setg(errp, "warning: Could not create auxiliary timer");
}
isa_register_portio_list(isadev, &s->portio_list, s->port,

View File

@ -8,8 +8,8 @@
*/
#include "qemu/osdep.h"
#include "hw/hw.h"
#include "hw/i2c/i2c.h"
#include "hw/audio/wm8750.h"
#include "audio/audio.h"
#define IN_PORT_N 3
@ -24,7 +24,6 @@ typedef struct {
int dac_hz;
} WMRate;
#define TYPE_WM8750 "wm8750"
#define WM8750(obj) OBJECT_CHECK(WM8750State, (obj), TYPE_WM8750)
typedef struct WM8750State {
@ -639,8 +638,7 @@ static void wm8750_fini(I2CSlave *i2c)
}
#endif
void wm8750_data_req_set(DeviceState *dev,
void (*data_req)(void *, int, int), void *opaque)
void wm8750_data_req_set(DeviceState *dev, data_req_cb *data_req, void *opaque)
{
WM8750State *s = WM8750(dev);

30
include/hw/audio/wm8750.h Normal file
View File

@ -0,0 +1,30 @@
/*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2 or later, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HW_DAC_WM8750_H
#define HW_DAC_WM8750_H
#include "hw/hw.h"
#define TYPE_WM8750 "wm8750"
typedef void data_req_cb(void *opaque, int free_out, int free_in);
void wm8750_data_req_set(DeviceState *dev, data_req_cb *data_req, void *opaque);
void wm8750_dac_dat(void *opaque, uint32_t sample);
uint32_t wm8750_adc_dat(void *opaque);
void *wm8750_dac_buffer(void *opaque, int samples);
void wm8750_dac_commit(void *opaque);
void wm8750_set_bclk_in(void *opaque, int new_hz);
#endif

View File

@ -70,15 +70,6 @@ int i2c_recv(I2CBus *bus);
DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
/* wm8750.c */
void wm8750_data_req_set(DeviceState *dev,
void (*data_req)(void *, int, int), void *opaque);
void wm8750_dac_dat(void *opaque, uint32_t sample);
uint32_t wm8750_adc_dat(void *opaque);
void *wm8750_dac_buffer(void *opaque, int samples);
void wm8750_dac_commit(void *opaque);
void wm8750_set_bclk_in(void *opaque, int new_hz);
/* lm832x.c */
void lm832x_key_event(DeviceState *dev, int key, int state);