From patchwork Fri Oct 16 15:22:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Ignacio Zurita X-Patchwork-Id: 54271 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9GFPS9f003877 for ; Fri, 16 Oct 2009 15:25:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760111AbZJPPXV (ORCPT ); Fri, 16 Oct 2009 11:23:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760282AbZJPPXV (ORCPT ); Fri, 16 Oct 2009 11:23:21 -0400 Received: from smtp101.prem.mail.ac4.yahoo.com ([76.13.13.40]:36780 "HELO smtp101.prem.mail.ac4.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1760111AbZJPPXU (ORCPT ); Fri, 16 Oct 2009 11:23:20 -0400 Received: (qmail 62577 invoked from network); 16 Oct 2009 15:22:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:Sender:User-Agent; b=zqLFM1J30/1q0KcnL7DW+JQeg/j05AdtzqTYtBGd+l4Zfl4x48QDDWxtmjyrHA7Xakm2/0fMwRgpUU+DspBC2rHFjW395v2HDuRLjjgagYsldRN2SdCMkPhrUElrQT0eAFlcaRK2uXA2O2KRNXUvsl5ARipDDdWCm3Gi//EKki4= ; Received: from customer-static-123-158-181.iplannetworks.net (rizurita@200.123.158.181 with login) by smtp101.prem.mail.ac4.yahoo.com with SMTP; 16 Oct 2009 08:22:38 -0700 PDT X-Yahoo-SMTP: MLUTDXCswBBmC6xvZOGw0G_cPpRR X-YMail-OSG: qJyrT08VM1l1qFJNOqx8F4NzVlqgA6.RM2R6VtAyQ8Zh0ab6rmR0dKscGCIRr.C8CpgGcHGgrXF3va1sstkby0F._6Myn5yJWiRnU88fedbC_gXsUj6htpB8KnTsQEtRlbAC7QXkGvQ.taY97J6YEo7RjfEtyvmCiePkpCaSJtWjZvwRz983nLXSQO5w7OAn1xBsO1vZRGsfOroWF0oXv96NXqorkUAlMX.HFUIZ4kRMKtVp3HQ9sSYmr.xj9Xqg3OT8Fa8Kuq3gJly6qV7h6lbulgfGHJtTeX4LpCUvviWupnoEpumQhibpjFHCMzY60H5LmkaVfuyUzpP7tQgDihuiQ1Kknywz0LGnd0X0i1WJAG7W1bdUQP6sGRS8 X-Yahoo-Newman-Property: ymail-3 Date: Fri, 16 Oct 2009 12:22:36 -0300 From: Rafael Ignacio Zurita To: Paul Mundt Cc: linux-sh@vger.kernel.org Subject: Re: [PATCH] sh: add SuperH DAC audio driver for ALSA Message-ID: <20091016152236.GA6810@rafazurita.homelinux.net> Reply-To: Rafael Ignacio Zurita References: <20091008013423.GA26059@rafazurita.homelinux.net> <20091009012224.GB31816@linux-sh.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091009012224.GB31816@linux-sh.org> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org diff --git a/arch/sh/boards/mach-hp6xx/setup.c b/arch/sh/boards/mach-hp6xx/setup.c index 8f305b3..826a499 100644 --- a/arch/sh/boards/mach-hp6xx/setup.c +++ b/arch/sh/boards/mach-hp6xx/setup.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -51,9 +52,66 @@ static struct platform_device jornadakbd_device = { .id = -1, }; +static void dac_audio_start(struct dac_audio_pdata *pdata); +static void dac_audio_stop(struct dac_audio_pdata *pdata); + +static struct dac_audio_pdata dac_audio_platform_data = { + .buffer_size = 64000, + .channel = 1, + .start = dac_audio_start, + .stop = dac_audio_stop, +}; + +static void dac_audio_start(struct dac_audio_pdata *pdata) +{ + u16 v; + u8 v8; + + /* HP Jornada 680/690 speaker on */ + v = inw(HD64461_GPADR); + v &= ~HD64461_GPADR_SPEAKER; + outw(v, HD64461_GPADR); + + /* HP Palmtop 620lx/660lx speaker on */ + v8 = inb(PKDR); + v8 &= ~PKDR_SPEAKER; + outb(v8, PKDR); + + sh_dac_enable(pdata->channel); +} + +static void dac_audio_stop(struct dac_audio_pdata *pdata) +{ + u16 v; + u8 v8; + + /* HP Jornada 680/690 speaker off */ + v = inw(HD64461_GPADR); + v |= HD64461_GPADR_SPEAKER; + outw(v, HD64461_GPADR); + + /* HP Palmtop 620lx/660lx speaker off */ + v8 = inb(PKDR); + v8 |= PKDR_SPEAKER; + outb(v8, PKDR); + + sh_dac_output(0, pdata->channel); + sh_dac_disable(pdata->channel); +} + +static struct platform_device dac_audio_device = { + .name = "dac_audio", + .id = -1, + .dev = { + .platform_data = &dac_audio_platform_data, + } + +}; + static struct platform_device *hp6xx_devices[] __initdata = { &cf_ide_device, &jornadakbd_device, + &dac_audio_device, }; static void __init hp6xx_init_irq(void) diff --git a/include/sound/dac_audio.h b/include/sound/dac_audio.h new file mode 100644 index 0000000..98324e9 --- /dev/null +++ b/include/sound/dac_audio.h @@ -0,0 +1,21 @@ +/* + * SH_DAC specific configuration, for the dac_audio platform_device + * + * Copyright (C) 2009 Rafael Ignacio Zurita + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#ifndef __INCLUDE_DAC_AUDIO_H +#define __INCLUDE_DAC_AUDIO_H + +struct dac_audio_pdata { + int buffer_size; + int channel; + void (*start)(struct dac_audio_pdata *pd); + void (*stop)(struct dac_audio_pdata *pd); +}; + +#endif /* __INCLUDE_DAC_AUDIO_H */ diff --git a/sound/sh/snd_sh_dac_audio.c b/sound/sh/snd_sh_dac_audio.c new file mode 100644 index 0000000..63eda29 --- /dev/null +++ b/sound/sh/snd_sh_dac_audio.c @@ -0,0 +1,471 @@ +/* + * snd_sh_dac_audio.c - SuperH DAC audio driver for ALSA + * [snip] + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + [snip] + +/* + * "driver" definition + */ +static struct platform_driver driver = { + .probe = snd_sh_dac_probe, + .remove = snd_sh_dac_remove, + .driver = { + .name = SND_SH_DAC_DRIVER, + }, +}; + +static int __init sh_dac_init(void) +{ + return platform_driver_register(&driver); +} + +/* clean up the module */ +static void __exit sh_dac_exit(void) +{ + platform_driver_unregister(&driver); +} + +module_init(sh_dac_init); +module_exit(sh_dac_exit); Is that idea better for the platform device? The new include/sound/dac_audio.h file has the struct for the platform data. Perhaps another platform would like to use the same struct, if it needs to use the driver (it should set the values for the members in its board code). I am also fixing the other problems that you pointed in your mail. If you are okey with the idea I am going to resend a new version of the patch. Thanks a lot for the review. Rafael -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html