From owner-freebsd-hackers Thu Aug 10 16:52:28 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from kbtfw.kubota.co.jp (kbtfw.kubota.co.jp [133.253.102.202]) by hub.freebsd.org (Postfix) with ESMTP id BA05F37BB36 for ; Thu, 10 Aug 2000 16:52:16 -0700 (PDT) (envelope-from haro@tk.kubota.co.jp) Received: by kbtfw.kubota.co.jp; id IAA11817; Fri, 11 Aug 2000 08:51:45 +0900 (JST) Received: from unknown(133.253.122.1) by kbtfw.kubota.co.jp via smap (V4.2) id xma011608; Fri, 11 Aug 00 08:51:32 +0900 Received: from jkpc15.tk.kubota.co.jp ([192.168.7.250]) by kbtmx.eto.kubota.co.jp (8.9.3+3.2W/3.7W) with ESMTP id IAA08491; Fri, 11 Aug 2000 08:51:30 +0900 (JST) Received: from localhost (localhost.ttr.kubota.co.jp [127.0.0.1]) by jkpc15.tk.kubota.co.jp (8.9.3/3.7W-02/21/99) with ESMTP id IAA00818; Fri, 11 Aug 2000 08:48:27 +0900 (JST) To: joseph.scott@owp.csus.edu, taku@cent.saitama-u.ac.jp Cc: julian@elischer.org, abc@bsdi.com, abial@webgiro.com, gandalf@vilnya.demon.co.uk, freebsd-hackers@FreeBSD.ORG Subject: Maestro2E patch (Was: US$100 prize for adding ESS Audiodrive support to pcm) In-Reply-To: <39902AC7.CB39BCD8@owp.csus.edu> References: <20000805155806.A94702@diskfarm.firehouse.net> <398F3081.167EB0E7@elischer.org> <39902AC7.CB39BCD8@owp.csus.edu> X-Mailer: Mew version 1.94.1 on Emacs 20.6 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Aug_11_08:47:09_2000_809)--" Content-Transfer-Encoding: 7bit Message-Id: <20000811084827Y.haro@tk.kubota.co.jp> Date: Fri, 11 Aug 2000 08:48:27 +0900 From: haro@tk.kubota.co.jp (Munehiro Matsuda) X-Dispatcher: imput version 990905(IM130) Lines: 209 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG ----Next_Part(Fri_Aug_11_08:47:09_2000_809)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi all, From: Joseph Scott Date: Tue, 08 Aug 2000 08:44:08 -0700 ::> > > On a simmilar note: what about a driver for ESS Maestro 2E? I'm certainly ::> [...] ::> > Add $100 from me. There is one that works for some folks out there ::> > by , but it does not work for me. ::> ::> where do you find this? :: :: I'm not sure about Alan, but I got it from an email from Taku ::YAMAMOTO . I've included the email below. ::One thing to note, myself and a few others have only been able to get ::sound to work out of the audio out jack. For some reason the internal ::speakers just don't work. I've played with the settings on the ::notebook quite a bit, and they do still work when I boot into ::Windows. However, sound, even without the internal speakers, is ::better than no sound at all :-) I have created a patch that trys to enable internal speakers. 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. The patch is based on Taku YAMAMOTO's maestro driver found at: http://access.cent.saitama-u.ac.jp/~taku/freebsd/maestro/releng4-20000725.tar.gz FYI, I also was writing Maestro2E driver myself, but I stopped. Because YAMAMOTO-san's driver works better than mine. :-) 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: haro@kubota.co.jp ----Next_Part(Fri_Aug_11_08:47:09_2000_809)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="mstr2_spr.patch" --- maestro.c.org Fri Aug 11 08:23:46 2000 +++ maestro.c Fri Aug 11 08:27:06 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,32 @@ | WAVCACHE_WAVETABLE_SIZE_2MB); wp_wrreg(ess, WPREG_BASE, 0x8500); wp_wrreg(ess, WPREG_TIMER_ENABLE, 1); + + /* + * 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 +404,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 +425,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 +780,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 +828,8 @@ device_printf(dev, "unable to map register space\n"); goto bad; } + + ess->subid = pci_read_config(dev, PCIR_SUBVEND_0, 4); agg_init(ess); codec = ac97_create(dev, ess, agg_ac97_init, agg_rdcodec, agg_wrcodec); --- maestro_reg.h.org Fri Aug 11 08:23:58 2000 +++ maestro_reg.h Fri Aug 11 08:23:15 2000 @@ -144,6 +144,11 @@ #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 */ + /* ----------------------------- * Wave Processor Indexed Data Registers. ----Next_Part(Fri_Aug_11_08:47:09_2000_809)---- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message