Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Split out common code to cs428x.c and cosmetic c...



details:   https://anonhg.NetBSD.org/src/rev/75aa6f069c8f
branches:  trunk
changeset: 503507:75aa6f069c8f
user:      tacha <tacha%NetBSD.org@localhost>
date:      Wed Feb 07 14:41:10 2001 +0000

description:
Split out common code to cs428x.c and cosmetic change to introduce
higher symmetry between cs4280.c and cs4281.c.

Also fix the problem rebooting from Windows. Relevant patch is contributed
from Shingo WATANABE <nabe%nabechan.org@localhost>.

diffstat:

 sys/dev/pci/cs4280.c    |  2103 ++++++++++++++++++----------------------------
 sys/dev/pci/cs4280reg.h |    48 +-
 sys/dev/pci/cs4281.c    |   752 ++++------------
 sys/dev/pci/cs4281reg.h |     3 +-
 sys/dev/pci/cs428x.c    |   384 ++++++++
 sys/dev/pci/cs428x.h    |    17 +-
 sys/dev/pci/files.pci   |     5 +-
 7 files changed, 1455 insertions(+), 1857 deletions(-)

diffs (truncated from 3848 to 300 lines):

diff -r 79dd5e6f80c8 -r 75aa6f069c8f sys/dev/pci/cs4280.c
--- a/sys/dev/pci/cs4280.c      Wed Feb 07 14:28:50 2001 +0000
+++ b/sys/dev/pci/cs4280.c      Wed Feb 07 14:41:10 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cs4280.c,v 1.13 2001/01/27 18:37:01 augustss Exp $     */
+/*     $NetBSD: cs4280.c,v 1.14 2001/02/07 14:41:10 tacha Exp $        */
 
 /*
  * Copyright (c) 1999, 2000 Tatoku Ogaito.  All rights reserved.
@@ -38,9 +38,12 @@
  * ftp://ftp.alsa-project.org/pub/manuals/cirrus/embedded_audio_spec.pdf
  * ftp://ftp.alsa-project.org/pub/manuals/cirrus/embedded_audio_spec.doc
  *
- * Note:  CS4610 + CS423x ISA codec should be worked with
+ * Note:  CS4610/CS4611 + CS423x ISA codec should be worked with
  *      wss* at pnpbios?
- *
+ * or
+ *       sb* at pnpbios?
+ * Since I could not find any documents on handling ISA codec,
+ * clcs does not support those chips.
  */
 
 /*
@@ -48,15 +51,6 @@
  * Joystick support
  */
 
-#if defined(CS4280_DEBUG)
-#define DPRINTF(x)         if (cs4280debug) printf x
-#define DPRINTFN(n,x)      if (cs4280debug>(n)) printf x
-int cs4280debug = 0;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
-
 #include "midi.h"
 
 #include <sys/param.h>
@@ -73,6 +67,7 @@
 #include <dev/pci/pcivar.h>
 #include <dev/pci/cs4280reg.h>
 #include <dev/pci/cs4280_image.h>
+#include <dev/pci/cs428xreg.h>
 
 #include <sys/audioio.h>
 #include <dev/audio_if.h>
@@ -83,166 +78,56 @@
 #include <dev/ic/ac97reg.h>
 #include <dev/ic/ac97var.h>
 
+#include <dev/pci/cs428x.h>
+
 #include <machine/bus.h>
 #include <machine/bswap.h>
 
-#define CSCC_PCI_BA0 0x10
-#define CSCC_PCI_BA1 0x14
-
-struct cs4280_dma {
-       bus_dmamap_t map;
-       caddr_t addr;           /* real dma buffer */
-       caddr_t dum;            /* dummy buffer for audio driver */
-       bus_dma_segment_t segs[1];
-       int nsegs;
-       size_t size;
-       struct cs4280_dma *next;
-};
-#define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr)
-#define BUFADDR(p)  ((void *)((p)->dum))
-#define KERNADDR(p) ((void *)((p)->addr))
-
-/*
- * Software state
- */
-struct cs4280_softc {
-       struct device         sc_dev;
-
-       pci_intr_handle_t *   sc_ih;
-
-       /* I/O (BA0) */
-       bus_space_tag_t       ba0t;
-       bus_space_handle_t    ba0h;
-       
-       /* BA1 */
-       bus_space_tag_t       ba1t;
-       bus_space_handle_t    ba1h;
-       
-       /* DMA */
-       bus_dma_tag_t    sc_dmatag;
-       struct cs4280_dma *sc_dmas;
-
-       void    (*sc_pintr)(void *);    /* dma completion intr handler */
-       void    *sc_parg;               /* arg for sc_intr() */
-       char    *sc_ps, *sc_pe, *sc_pn;
-       int     sc_pcount;
-       int     sc_pi;
-       struct  cs4280_dma *sc_pdma;
-       char    *sc_pbuf;
-#ifdef DIAGNOSTIC
-       char    sc_prun;
-#endif
-
-       void    (*sc_rintr)(void *);    /* dma completion intr handler */
-       void    *sc_rarg;               /* arg for sc_intr() */
-       char    *sc_rs, *sc_re, *sc_rn;
-       int     sc_rcount;
-       int     sc_ri;
-       struct  cs4280_dma *sc_rdma;
-       char    *sc_rbuf;
-       int     sc_rparam;              /* record format */
-#ifdef DIAGNOSTIC
-       char    sc_rrun;
-#endif
-
-#if NMIDI > 0
-       void    (*sc_iintr)(void *, int); /* midi input ready handler */
-       void    (*sc_ointr)(void *);      /* midi output ready handler */
-       void    *sc_arg;
-#endif
-
-       u_int32_t pctl;
-       u_int32_t cctl;
-
-       struct ac97_codec_if *codec_if;
-       struct ac97_host_if host_if;    
-
-       char    sc_suspend;
-       void   *sc_powerhook;           /* Power Hook */
-};
-
-#define BA0READ4(sc, r) bus_space_read_4((sc)->ba0t, (sc)->ba0h, (r))
-#define BA0WRITE4(sc, r, x) bus_space_write_4((sc)->ba0t, (sc)->ba0h, (r), (x))
 #define BA1READ4(sc, r) bus_space_read_4((sc)->ba1t, (sc)->ba1h, (r))
 #define BA1WRITE4(sc, r, x) bus_space_write_4((sc)->ba1t, (sc)->ba1h, (r), (x))
 
-int    cs4280_match  __P((struct device *, struct cfdata *, void *));
-void   cs4280_attach __P((struct device *, struct device *, void *));
-int    cs4280_intr __P((void *));
-void   cs4280_reset __P((void *));
-int    cs4280_download_image __P((struct cs4280_softc *));
-
-int cs4280_download(struct cs4280_softc *, const u_int32_t *, u_int32_t, u_int32_t);
-int cs4280_allocmem __P((struct cs4280_softc *, size_t, size_t,
-                        struct cs4280_dma *));
-int cs4280_freemem __P((struct cs4280_softc *, struct cs4280_dma *));
-
-#ifdef CS4280_DEBUG
-int    cs4280_check_images   __P((struct cs4280_softc *));
-int    cs4280_checkimage(struct cs4280_softc *, u_int32_t *, u_int32_t,
-                         u_int32_t);
-#endif
+/* IF functions for audio driver */
+int  cs4280_match(struct device *, struct cfdata *, void *);
+void cs4280_attach(struct device *, struct device *, void *);
+int  cs4280_intr(void *);
+int  cs4280_query_encoding(void *, struct audio_encoding *);
+int  cs4280_set_params(void *, int, int, struct audio_params *, struct audio_params *);
+int  cs4280_halt_output(void *);
+int  cs4280_halt_input(void *);
+int  cs4280_getdev(void *, struct audio_device *);
+int  cs4280_trigger_output(void *, void *, void *, int, void (*)(void *),
+                           void *, struct audio_params *);
+int  cs4280_trigger_input(void *, void *, void *, int, void (*)(void *),
+                          void *, struct audio_params *);
 
-struct cfattach clcs_ca = {
-       sizeof(struct cs4280_softc), cs4280_match, cs4280_attach
-};
-
-int    cs4280_init __P((struct cs4280_softc *, int));
-int    cs4280_open __P((void *, int));
-void   cs4280_close __P((void *));
-
-int    cs4280_query_encoding __P((void *, struct audio_encoding *));
-int    cs4280_set_params __P((void *, int, int, struct audio_params *, struct audio_params *));
-int    cs4280_round_blocksize __P((void *, int));
-
-int    cs4280_halt_output __P((void *));
-int    cs4280_halt_input __P((void *));
-
-int    cs4280_getdev __P((void *, struct audio_device *));
+void cs4280_reset_codec(void *);
 
-int    cs4280_mixer_set_port __P((void *, mixer_ctrl_t *));
-int    cs4280_mixer_get_port __P((void *, mixer_ctrl_t *));
-int    cs4280_query_devinfo __P((void *addr, mixer_devinfo_t *dip));
-void   *cs4280_malloc __P((void *, int, size_t, int, int));
-void   cs4280_free __P((void *, void *, int));
-size_t cs4280_round_buffersize __P((void *, int, size_t));
-paddr_t        cs4280_mappage __P((void *, void *, off_t, int));
-int    cs4280_get_props __P((void *));
-int    cs4280_trigger_output __P((void *, void *, void *, int, void (*)(void *),
-           void *, struct audio_params *));
-int    cs4280_trigger_input __P((void *, void *, void *, int, void (*)(void *),
-           void *, struct audio_params *));
-
+/* For PowerHook */
+void cs4280_power(int, void *);
 
-void   cs4280_set_dac_rate  __P((struct cs4280_softc *, int ));
-void   cs4280_set_adc_rate  __P((struct cs4280_softc *, int ));
-int    cs4280_get_portnum_by_name __P((struct cs4280_softc *, char *, char *,
-                                        char *));
-int    cs4280_src_wait  __P((struct cs4280_softc *));
-int    cs4280_attach_codec __P((void *sc, struct ac97_codec_if *));
-int    cs4280_read_codec __P((void *sc, u_int8_t a, u_int16_t *d));
-int    cs4280_write_codec __P((void *sc, u_int8_t a, u_int16_t d));
-void   cs4280_reset_codec __P((void *sc));
+/* Internal functions */
+void cs4280_set_adc_rate(struct cs428x_softc *, int );
+void cs4280_set_dac_rate(struct cs428x_softc *, int );
+int  cs4280_download(struct cs428x_softc *, const u_int32_t *, u_int32_t, u_int32_t);
+int  cs4280_download_image(struct cs428x_softc *);
+void cs4280_reset(void *);
+int  cs4280_get_portnum_by_name(struct cs428x_softc *, char *, char *, char *);
+int  cs4280_init(struct cs428x_softc *, int);
+void cs4280_clear_fifos(struct cs428x_softc *);
 
-void   cs4280_power __P((int, void *));
-
-void   cs4280_clear_fifos __P((struct cs4280_softc *));
-
-#if NMIDI > 0
-void   cs4280_midi_close __P((void*));
-void   cs4280_midi_getinfo __P((void *, struct midi_info *));
-int    cs4280_midi_open __P((void *, int, void (*)(void *, int),
-                             void (*)(void *), void *));
-int    cs4280_midi_output __P((void *, int));
+#if CS4280_DEBUG > 10
+/* Thease two function is only for checking image loading is succeeded or not. */
+int  cs4280_check_images(struct cs428x_softc *);
+int  cs4280_checkimage(struct cs428x_softc *, u_int32_t *, u_int32_t, u_int32_t);
 #endif
 
 struct audio_hw_if cs4280_hw_if = {
-       cs4280_open,
-       cs4280_close,
+       cs428x_open,
+       cs428x_close,
        NULL,
        cs4280_query_encoding,
        cs4280_set_params,
-       cs4280_round_blocksize,
+       cs428x_round_blocksize,
        NULL,
        NULL,
        NULL,
@@ -253,19 +138,26 @@
        NULL,
        cs4280_getdev,
        NULL,
-       cs4280_mixer_set_port,
-       cs4280_mixer_get_port,
-       cs4280_query_devinfo,
-       cs4280_malloc,
-       cs4280_free,
-       cs4280_round_buffersize,
-       cs4280_mappage,
-       cs4280_get_props,
+       cs428x_mixer_set_port,
+       cs428x_mixer_get_port,
+       cs428x_query_devinfo,
+       cs428x_malloc,
+       cs428x_free,
+       cs428x_round_buffersize,
+       cs428x_mappage,
+       cs428x_get_props,
        cs4280_trigger_output,
        cs4280_trigger_input,
 };
 
 #if NMIDI > 0
+/* Midi Interface */
+int  cs4280_midi_open(void *, int, void (*)(void *, int),
+                      void (*)(void *), void *);
+void cs4280_midi_close(void*);
+int  cs4280_midi_output(void *, int);
+void cs4280_midi_getinfo(void *, struct midi_info *);
+
 struct midi_hw_if cs4280_midi_hw_if = {
        cs4280_midi_open,
        cs4280_midi_close,
@@ -275,7 +167,9 @@
 };
 #endif
 
-       
+struct cfattach clcs_ca = {
+       sizeof(struct cs428x_softc), cs4280_match, cs4280_attach
+};
 
 struct audio_device cs4280_device = {
        "CS4280",
@@ -293,99 +187,739 @@
        struct pci_attach_args *pa = (struct pci_attach_args *)aux;
        
        if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_CIRRUS)
-               return (0);



Home | Main Index | Thread Index | Old Index