From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolin Chen Subject: Re: SGTL500 and its external MCLK Date: Mon, 11 Aug 2014 13:50:17 +0800 Message-ID: <20140811055015.GA12969@MrMyself> References: <20140808052901.GA6028@MrMyself> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2lp0244.outbound.protection.outlook.com [207.46.163.244]) by alsa0.perex.cz (Postfix) with ESMTP id 390FA26506E for ; Mon, 11 Aug 2014 08:01:14 +0200 (CEST) Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: "jonsmirl@gmail.com" Cc: alsa-devel mailing list , Mark Brown , Lars-Peter Clausen , zengzm.kernel@gmail.com, Liam Girdwood List-Id: alsa-devel@alsa-project.org On Sat, Aug 09, 2014 at 12:42:43PM -0400, jonsmirl@gmail.com wrote: > On Fri, Aug 8, 2014 at 1:07 PM, jonsmirl@gmail.com wrote: > > On Fri, Aug 8, 2014 at 1:29 AM, Nicolin Chen wrote: > >> On Thu, Aug 07, 2014 at 03:37:47PM -0400, jonsmirl@gmail.com wrote: > >>> Since the sgtl5000 driver has the handle to the clock, can't it just > >>> ask the clock for its rate? If it directly asked the clock for its > >>> rate it looks like this codec could be bound with simple-audio-card > >>> and not need a machine driver. > >> > >> I think Simple Card should already have the capability to support > >> this without changing sgtl5000's code. It has two properties that > >> can make it call set_sysclk() for you during the init(). They are > >> 'clocks' and 'system-clock-frequency'. Please refer to its binding > >> doc for details. > > Simple has a hard coded clock ID of zero. Which just happens to match > codecs/sgtl5000.h:#define SGTL5000_SYSCLK 0x00 > > Lucky coincidence? It's also pretty fair to think that Simple Card only supports CODEC using the main sysclk -- id is 0x00. And I believe this also works out for other CODECs whose sysclk configurations aren't complicated since the name is Simple Card :) > >> And the topic why not let sgtl5000 fully control the clock has been > >> discussed in this thread: > >> http://comments.gmane.org/gmane.linux.alsa.devel/109093 > >> > >> So I think the change can be done as well? > > > > I tried hacking on it some. One problem is with clocks that aren't > > 100% accurate. For example my clock is off a little - 22.571428. So > > when the code divides that by 44100 it gets 511.8 which truncates to > > 511 and the test for equal to 512 fails. This is a clock dividing accuracy issue. We can try DIV_ROUND_UP() instead of the truncating division. Best regards, Nicolin