Hello Joseph,

From: Joseph Scott <[EMAIL PROTECTED]>
Date: Thu, 10 Aug 2000 17:36:52 -0700
::> I have created a patch that trys to enable internal speakers.
::
::      The first part of the patch (for maestro.c) didn't apply cleanly for
::me, so I ended up doing it by hand.

Thats funny. Did you aply my patch to the original 20000725 version?

::> It worked for me (NEC VersaProNX VA26D), but I'm not sure if it works
::> for everybody. Patch is based on Linux driver, but simplified.
::> 
::> If it does not work, 1) try setting GPIO values to what your PC is at
::> when rebooting from Windows, 2) try original way the Linux driver do.
::> Let me know, if you want to know what Linux driver does.
::
::      Unfortunately this didn't work for mine (Dell Inspiron 7500).  How to
::I find out the GPIO values that make windows work?  I'm open to trying
::what the Linux driver does.  Mind you my C programing skills are
::pretty much useless, but I'm willing to try things out :-)

Aha, Dell Inspiron 7500!
There was some extra stuff in the Linux driver for it.
I have recreated my patch (mstr2_spk.patch2) to include them.
Please aply the new patch to the original 20000725 version source code!

And also, I added a small patch (mstr2_gpio.patch) that should print
GPIO values. Aply GPIO patch after the mstr2_spk.patch2!

Let me know how that works out.

BTW, I'll be out of town for few days. So my reply may get delayed. sorry.

Thank you,
  Haro
=------------------------------------------------------------------------------
           _ _    Munehiro (haro) Matsuda
 -|- /_\  |_|_|   Business Incubation Dept., Kubota Corp.
 /|\ |_|  |_|_|   1-3 Nihonbashi-Muromachi 3-Chome
                  Chuo-ku Tokyo 103-8310, Japan
                  Tel: +81-3-3245-3318  Fax: +81-3-3245-3315
                  Email: [EMAIL PROTECTED]
--- maestro.c.org       Tue Jul 25 03:20:26 2000
+++ maestro.c   Fri Aug 11 14:11:33 2000
@@ -50,6 +50,9 @@
 #define MAESTRO_2_PCI_ID       0x1968125d
 #define MAESTRO_2E_PCI_ID      0x1978125d
 
+#define NEC_SUBID1     0x80581033      /* Taken from Linux driver */
+#define NEC_SUBID2     0x803c1033      /* NEC VersaProNX VA26D    */
+
 #define AGG_MAXPLAYCH  4
 #define AGG_BUFSIZ     (8 << 10)
 
@@ -87,6 +90,8 @@
        unsigned                playchns, active;
        struct agg_chinfo       pch[AGG_MAXPLAYCH];
        struct agg_chinfo       rch;
+
+       u_int32_t               subid;
 };
 
 
@@ -95,8 +100,8 @@
 
 static void     set_timer(struct agg_info*);
 
-static u_int32_t agg_rdcodec(struct agg_info*, int);
-static void     agg_wrcodec(struct agg_info*, int, u_int32_t);
+static u_int32_t agg_rdcodec(void *, int);
+static void     agg_wrcodec(void *, int, u_int32_t);
 
 static inline void      ringbus_setdest(struct agg_info*, int, int);
 
@@ -117,9 +122,9 @@
 
 static void     agg_init(struct agg_info*);
 static void     agg_deinit(struct agg_info*);
-static u_int32_t agg_ac97_init(struct agg_info*);
+static u_int32_t agg_ac97_init(void *);
 
-static void                    agg_intr(struct agg_info*);
+static void                    agg_intr(void *);
 static pcmchan_init_t          aggch_init;
 static pcmchan_setdir_t                aggch_setdir;
 static pcmchan_setformat_t     aggch_setplayformat;
@@ -143,8 +148,9 @@
 /* Codec/Ringbus */
 
 static u_int32_t
-agg_rdcodec(struct agg_info *ess, int regno)
+agg_rdcodec(void *s, int regno)
 {
+       struct agg_info *ess = (struct agg_info *)s;
        unsigned t;
 
        /* We have to wait for a SAFE time to write addr/data */
@@ -178,8 +184,9 @@
 }
 
 static void
-agg_wrcodec(struct agg_info *ess, int regno, u_int32_t data)
+agg_wrcodec(void *s, int regno, u_int32_t data)
 {
+       struct agg_info *ess = (struct agg_info *)s;
        unsigned t;
 
        /* We have to wait for a SAFE time to write addr/data */
@@ -351,6 +358,37 @@
            | WAVCACHE_WAVETABLE_SIZE_2MB);
        wp_wrreg(ess, WPREG_BASE, 0x8500);
        wp_wrreg(ess, WPREG_TIMER_ENABLE, 1);
+
+       /* Setup ASSP. Needed for Dell Inspiron 7500? */
+       bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CNTL_B, 0x00);
+       bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CNTL_A, 0x03);
+       bus_space_write_1(ess->st, ess->sh, PORT_ASSP_CNTL_C, 0x00);
+
+        /*
+         * Setup GPIO.
+         * There seems to be speciality with NEC systems.
+         */
+       switch (ess->subid) {
+        case NEC_SUBID1:
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_MASK, 0x09ff);
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR,
+                   bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DIR)| 0x600);
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x0209);
+               break;
+       case NEC_SUBID2:
+               /* For VersaProNX VA26D */
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_MASK, 0x09e4);
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR, 0x061b);
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA, 0x03ef);
+               break;
+       default:
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_MASK,
+                  bus_space_read_2(ess->st, ess->sh, PORT_GPIO_MASK) & 0xfffe);
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DIR,
+                  bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DIR) | 0x11);
+               bus_space_write_2(ess->st, ess->sh, PORT_GPIO_DATA,
+                  bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DATA) | 0x01);
+       }
 }
 
 static void
@@ -371,8 +409,9 @@
 }
 
 static u_int32_t
-agg_ac97_init(struct agg_info *ess)
+agg_ac97_init(void *s)
 {
+       struct agg_info *ess = (struct agg_info *)s;
        u_int32_t       data;
 
        data = bus_space_read_4(ess->st, ess->sh, PORT_RINGBUS_CTRL);
@@ -391,8 +430,9 @@
 }
 
 static void
-agg_intr(struct agg_info* ess)
+agg_intr(void *s)
 {
+       struct agg_info *ess = (struct agg_info *)s;
        u_int16_t status;
        int i;
 
@@ -745,7 +785,7 @@
        struct agg_info *ess = NULL;
        u_int32_t       data;
        int     mapped = 0;
-       int     regid = PCI_MAP_REG_START;
+       int     regid = PCIR_MAPS;
        struct resource *reg = NULL;
        struct ac97_info        *codec = NULL;
        int     irqid = 0;
@@ -793,6 +833,12 @@
                device_printf(dev, "unable to map register space\n");
                goto bad;
        }
+
+        ess->subid = pci_read_config(dev, PCIR_SUBVEND_0, 4);
+
+       /* Needed for Dell Inspiron 7500? */
+       data = pci_read_config(dev, CONFIGURATION_B, 2);
+       pci_write_config(dev, CONFIGURATION_B, data|ENABLE_DSP_IF, 2);
 
        agg_init(ess);
        codec = ac97_create(dev, ess, agg_ac97_init, agg_rdcodec, agg_wrcodec);
--- maestro_reg.h.org   Tue Jul 25 03:11:52 2000
+++ maestro_reg.h       Fri Aug 11 14:12:44 2000
@@ -43,6 +43,10 @@
 #define        PPMI_D2         2       /* Low power */
 #define        PPMI_D3         3       /* Turned off */
 
+/* Maestro2E Configuration B */
+#define CONFIGURATION_B        0x52    /* WORD RW */
+#define ENABLE_DSP_IF  0x0010
+
 
 /* -----------------------------
  * I/O ports
@@ -143,6 +147,17 @@
 #define RINGBUS_DEST_RESERVED3 3
 #define RINGBUS_DEST_DSOUND_IN 4
 #define RINGBUS_DEST_ASSP_IN   5
+
+/* GPIO control */
+#define PORT_GPIO_DATA         0x60    /* WORD RW */
+#define PORT_GPIO_MASK         0x64    /* WORD RW */
+#define PORT_GPIO_DIR          0x68    /* WORD RW */
+
+/* ASSP control */
+#define PORT_ASSP_CNTL_A       0xa2    /* BYTE RW */
+#define PORT_ASSP_CNTL_B       0xa4    /* BYTE RW */
+#define PORT_ASSP_CNTL_C       0xa6    /* BYTE RW */
+
 
 
 /* -----------------------------
--- maestro.c.org1      Fri Aug 11 14:13:28 2000
+++ maestro.c   Fri Aug 11 14:18:42 2000
@@ -834,6 +834,16 @@
                goto bad;
        }
 
+#define DEBUG_GPIO
+#ifdef DEBUG_GPIO
+       printf("GIPO_MASK: %04x\n",
+              bus_space_read_2(ess->st, ess->sh, PORT_GPIO_MASK));
+       printf("GIPO_DIR : %04x\n",
+              bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DIR));
+       printf("GIPO_DATA: %04x\n",
+              bus_space_read_2(ess->st, ess->sh, PORT_GPIO_DATA));
+#endif
+
         ess->subid = pci_read_config(dev, PCIR_SUBVEND_0, 4);
 
        /* Needed for Dell Inspiron 7500? */

Reply via email to