Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/dev/pci Pull up revisions 1.7-1.8, 1.10-1.14, 1.16 ...



details:   https://anonhg.NetBSD.org/src/rev/1bb6d6845f25
branches:  netbsd-1-5
changeset: 491653:1bb6d6845f25
user:      he <he%NetBSD.org@localhost>
date:      Sun May 06 15:10:26 2001 +0000

description:
Pull up revisions 1.7-1.8, 1.10-1.14, 1.16 (via patch, requested by he):
  Add driver for Cirrus Logic CrystalClear PCI Audio CS4281.

diffstat:

 sys/dev/pci/cs4280.c |  2200 ++++++++++++++++++++-----------------------------
 1 files changed, 909 insertions(+), 1291 deletions(-)

diffs (truncated from 2500 to 300 lines):

diff -r a1bbc232f085 -r 1bb6d6845f25 sys/dev/pci/cs4280.c
--- a/sys/dev/pci/cs4280.c      Sun May 06 15:09:57 2001 +0000
+++ b/sys/dev/pci/cs4280.c      Sun May 06 15:10:26 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cs4280.c,v 1.4.4.7 2001/03/13 21:01:14 he Exp $        */
+/*     $NetBSD: cs4280.c,v 1.4.4.8 2001/05/06 15:10:26 he 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>
@@ -65,6 +59,7 @@
 #include <sys/fcntl.h>
 #include <sys/malloc.h>
 #include <sys/device.h>
+#include <sys/proc.h>
 #include <sys/types.h>
 #include <sys/systm.h>
 
@@ -72,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>
@@ -82,167 +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 */
-       u_int16_t  ac97_reg[CS4280_SAVE_REG_MAX + 1];   /* Save ac97 registers */
-};
-
-#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 *, 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



Home | Main Index | Thread Index | Old Index