From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haojian Zhuang Subject: Re: [PATCH 4/4] ASoC: enable wm8753 in aspenite Date: Fri, 2 Apr 2010 12:40:30 +0800 Message-ID: References: <20100401182124.GB26650@opensource.wolfsonmicro.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-pz0-f187.google.com (mail-pz0-f187.google.com [209.85.222.187]) by alsa0.perex.cz (Postfix) with ESMTP id 6A1321038C5 for ; Fri, 2 Apr 2010 06:40:31 +0200 (CEST) Received: by pzk17 with SMTP id 17so1707330pzk.5 for ; Thu, 01 Apr 2010 21:40:30 -0700 (PDT) In-Reply-To: <20100401182124.GB26650@opensource.wolfsonmicro.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: alsa-devel@alsa-project.org, Eric Miao , linux-arm-kernel , Liam Girdwood List-Id: alsa-devel@alsa-project.org On Fri, Apr 2, 2010 at 2:21 AM, Mark Brown wrote: > On Wed, Mar 31, 2010 at 08:48:58AM -0400, Haojian Zhuang wrote: > >> +/* Seek the index of MCLK configuration table */ >> +static int pxa168_seek_mclk_conf(int rate, int format, int channel) >> +{ >> + =A0 =A0 int i; >> + >> + =A0 =A0 for (i =3D 0; i < ARRAY_SIZE(mclk_conf); i++) { >> + =A0 =A0 =A0 =A0 =A0 =A0 if ((mclk_conf[i].rate =3D=3D rate) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 && (mclk_conf[i].format =3D=3D= format) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 && (mclk_conf[i].channel =3D= =3D channel)) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return i; >> + =A0 =A0 } >> + =A0 =A0 return -EINVAL; >> +} > >> +/* Get the MCLK frequency */ >> +static int pxa168_get_mclk(int i) >> +{ >> + =A0 =A0 if ((i < 0) || (i >=3D ARRAY_SIZE(mclk_conf))) >> + =A0 =A0 =A0 =A0 =A0 =A0 return -EINVAL; >> + =A0 =A0 return mclk_conf[i].mclk; >> +} > > This stuff probably shouldn't be in the machine driver since pretty much > all machine drivers are going to want exactly the same code - it should > be in the library code. =A0Probably best to have them take hw_params > rather than require the machine driver to decode the format, rate and > channel since that'll save a bit of per driver boiler plate if they > don't otherwise need that information. > > As I said last time ideally machine drivers shouldn't have to see this > at all, of course. > This functions is used to get the sysclk. It's the parameter that is used in hw_params() of machine driver since we need set codec and cpu sysclock. But hw_params() of machine driver is invoked before hw_params() of cpu_dai. That's the main reason. If hw_params() of cpu_dai is invoked before machine driver. This issue won't exist.