/[qemu]/qemu/hw/es1370.c
ViewVC logotype

Diff of /qemu/hw/es1370.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by bellard, Sun Oct 30 18:58:22 2005 UTC revision 1.2 by bellard, Sat Nov 5 18:55:28 2005 UTC
# Line 265  struct chan { Line 265  struct chan {
265  typedef struct ES1370State {  typedef struct ES1370State {
266      PCIDevice *pci_dev;      PCIDevice *pci_dev;
267    
268        QEMUSoundCard card;
269      struct chan chan[NB_CHANNELS];      struct chan chan[NB_CHANNELS];
270      SWVoiceOut *dac_voice[2];      SWVoiceOut *dac_voice[2];
271      SWVoiceIn *adc_voice;      SWVoiceIn *adc_voice;
# Line 341  static void es1370_reset (ES1370State *s Line 342  static void es1370_reset (ES1370State *s
342          d->scount = 0;          d->scount = 0;
343          d->leftover = 0;          d->leftover = 0;
344          if (i == ADC_CHANNEL) {          if (i == ADC_CHANNEL) {
345              AUD_close_in (s->adc_voice);              AUD_close_in (&s->card, s->adc_voice);
346              s->adc_voice = NULL;              s->adc_voice = NULL;
347          }          }
348          else {          else {
349              AUD_close_out (s->dac_voice[i]);              AUD_close_out (&s->card, s->dac_voice[i]);
350              s->dac_voice[i] = NULL;              s->dac_voice[i] = NULL;
351          }          }
352      }      }
# Line 417  static void es1370_update_voices (ES1370 Line 418  static void es1370_update_voices (ES1370
418                      (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8,                      (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8,
419                      d->shift);                      d->shift);
420              if (new_freq) {              if (new_freq) {
421                    audsettings_t as;
422    
423                    as.freq = new_freq;
424                    as.nchannels = 1 << (new_fmt & 1);
425                    as.fmt = (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8;
426    
427                  if (i == ADC_CHANNEL) {                  if (i == ADC_CHANNEL) {
428                      s->adc_voice =                      s->adc_voice =
429                          AUD_open_in (                          AUD_open_in (
430                                &s->card,
431                              s->adc_voice,                              s->adc_voice,
432                              "es1370.adc",                              "es1370.adc",
433                              s,                              s,
434                              es1370_adc_callback,                              es1370_adc_callback,
435                              new_freq,                              &as
                             1 << (new_fmt & 1),  
                             (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8  
436                              );                              );
437                  }                  }
438                  else {                  else {
439                      s->dac_voice[i] =                      s->dac_voice[i] =
440                          AUD_open_out (                          AUD_open_out (
441                                &s->card,
442                              s->dac_voice[i],                              s->dac_voice[i],
443                              i ? "es1370.dac2" : "es1370.dac1",                              i ? "es1370.dac2" : "es1370.dac1",
444                              s,                              s,
445                              i ? es1370_dac2_callback : es1370_dac1_callback,                              i ? es1370_dac2_callback : es1370_dac1_callback,
446                              new_freq,                              &as
                             1 << (new_fmt & 1),  
                             (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8  
447                              );                              );
448                  }                  }
449              }              }
# Line 761  static void es1370_transfer_audio (ES137 Line 766  static void es1370_transfer_audio (ES137
766          while (temp) {          while (temp) {
767              int acquired, to_copy;              int acquired, to_copy;
768    
769              to_copy = audio_MIN (temp, sizeof (tmpbuf));              to_copy = audio_MIN ((size_t) temp, sizeof (tmpbuf));
770              acquired = AUD_read (s->adc_voice, tmpbuf, to_copy);              acquired = AUD_read (s->adc_voice, tmpbuf, to_copy);
771              if (!acquired)              if (!acquired)
772                  break;                  break;
# Line 779  static void es1370_transfer_audio (ES137 Line 784  static void es1370_transfer_audio (ES137
784          while (temp) {          while (temp) {
785              int copied, to_copy;              int copied, to_copy;
786    
787              to_copy = audio_MIN (temp, sizeof (tmpbuf));              to_copy = audio_MIN ((size_t) temp, sizeof (tmpbuf));
788              cpu_physical_memory_read (addr, tmpbuf, to_copy);              cpu_physical_memory_read (addr, tmpbuf, to_copy);
789              copied = AUD_write (voice, tmpbuf, to_copy);              copied = AUD_write (voice, tmpbuf, to_copy);
790              if (!copied)              if (!copied)
# Line 812  static void es1370_transfer_audio (ES137 Line 817  static void es1370_transfer_audio (ES137
817      else {      else {
818          d->frame_cnt = size;          d->frame_cnt = size;
819    
820          if (cnt <= d->frame_cnt)          if ((uint32_t) cnt <= d->frame_cnt)
821              d->frame_cnt |= cnt << 16;              d->frame_cnt |= cnt << 16;
822      }      }
823    
# Line 876  static void es1370_map (PCIDevice *pci_d Line 881  static void es1370_map (PCIDevice *pci_d
881      PCIES1370State *d = (PCIES1370State *) pci_dev;      PCIES1370State *d = (PCIES1370State *) pci_dev;
882      ES1370State *s = &d->es1370;      ES1370State *s = &d->es1370;
883    
884        (void) region_num;
885        (void) size;
886        (void) type;
887    
888      register_ioport_write (addr, 0x40 * 4, 1, es1370_writeb, s);      register_ioport_write (addr, 0x40 * 4, 1, es1370_writeb, s);
889      register_ioport_write (addr, 0x40 * 2, 2, es1370_writew, s);      register_ioport_write (addr, 0x40 * 2, 2, es1370_writew, s);
890      register_ioport_write (addr, 0x40, 4, es1370_writel, s);      register_ioport_write (addr, 0x40, 4, es1370_writel, s);
# Line 923  static int es1370_load (QEMUFile *f, voi Line 932  static int es1370_load (QEMUFile *f, voi
932          qemu_get_be32s (f, &d->frame_cnt);          qemu_get_be32s (f, &d->frame_cnt);
933          if (i == ADC_CHANNEL) {          if (i == ADC_CHANNEL) {
934              if (s->adc_voice) {              if (s->adc_voice) {
935                  AUD_close_in (s->adc_voice);                  AUD_close_in (&s->card, s->adc_voice);
936                  s->adc_voice = NULL;                  s->adc_voice = NULL;
937              }              }
938          }          }
939          else {          else {
940              if (s->dac_voice[i]) {              if (s->dac_voice[i]) {
941                  AUD_close_out (s->dac_voice[i]);                  AUD_close_out (&s->card, s->dac_voice[i]);
942                  s->dac_voice[i] = NULL;                  s->dac_voice[i] = NULL;
943              }              }
944          }          }
# Line 953  static void es1370_on_reset (void *opaqu Line 962  static void es1370_on_reset (void *opaqu
962      es1370_reset (s);      es1370_reset (s);
963  }  }
964    
965  int es1370_init (PCIBus *bus)  int es1370_init (PCIBus *bus, AudioState *audio)
966  {  {
967      PCIES1370State *d;      PCIES1370State *d;
968      ES1370State *s;      ES1370State *s;
969      uint8_t *c;      uint8_t *c;
970    
971        if (!bus) {
972            dolog ("No PCI bus\n");
973            return -1;
974        }
975    
976        if (!audio) {
977            dolog ("No audio state\n");
978            return -1;
979        }
980    
981      d = (PCIES1370State *) pci_register_device (bus, "ES1370",      d = (PCIES1370State *) pci_register_device (bus, "ES1370",
982                                                  sizeof (PCIES1370State),                                                  sizeof (PCIES1370State),
983                                                  -1, NULL, NULL);                                                  -1, NULL, NULL);
# Line 1002  int es1370_init (PCIBus *bus) Line 1021  int es1370_init (PCIBus *bus)
1021      pci_register_io_region (&d->dev, 0, 256, PCI_ADDRESS_SPACE_IO, es1370_map);      pci_register_io_region (&d->dev, 0, 256, PCI_ADDRESS_SPACE_IO, es1370_map);
1022      register_savevm ("es1370", 0, 1, es1370_save, es1370_load, s);      register_savevm ("es1370", 0, 1, es1370_save, es1370_load, s);
1023      qemu_register_reset (es1370_on_reset, s);      qemu_register_reset (es1370_on_reset, s);
1024    
1025        AUD_register_card (audio, "es1370", &s->card);
1026      es1370_reset (s);      es1370_reset (s);
1027      return 0;      return 0;
1028  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26