Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4244276ybh; Tue, 6 Aug 2019 08:30:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJMJr/s6TkOKNqjslZM32WiVJ6rsTtHNeEV3xP/gW8lb4CLekHHnv6JIUqDU0i3XErwOck X-Received: by 2002:a17:90a:372a:: with SMTP id u39mr3848708pjb.2.1565105424908; Tue, 06 Aug 2019 08:30:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565105424; cv=none; d=google.com; s=arc-20160816; b=UFubqdcHIw7EVtDppYbrcy0tJ+CEq9IbUtlCkz7civINGbmMwKZVUC1Kdgc0MdpOJn M7OU1R523NL1vOFou28XTYXFjLiJ6gs9vNOQzCdaDV+5AZL60ihygRVLCygswpQzpb6d AlKMSnkM4brLvuYmypwENdQWjXITom6FMwkE8fuwfMT4Qv/77vkvysogTXCqccHGSyxJ wupORJZkdIQIcSpccSOOIYjnxJ6R+NAY7XNvZN7LIcSGoqmexNZC4FCP14gufETLtmqc bJLWivugFUN9rx0ZdZHtlvBWYz8Ob9kRQAk7dZsvOujxKP9mvKvavClpzWWAv75erAm2 EQAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=twRCx/dQ+gvHlyqtzOAvbehM5Ndq1HQIwQhs2TL65Nc=; b=wn1LTBUUC1zo7h1R2fKBa54FGvJV5LR5/1JMN8t/v/2fgWIyo4PST5qsmxAQrwhKaw ddU8kPMuC9yk2I0rtKjrWBeO8xVg0zat1XhHNwEgINnmepQIKEhJO7SLfuoMks3Gv6bu +xGC2AbJdNm2PinyCAQC8kppBZ03w3gkarydN3KpyHBZ9uLVBlpFeVs8ozdZNRTVUABH g9Wp4R1pnrRwdc6s+zEa41fUMCk99/ze/ll3Z+l1Br44BuDD1NRlO76OeKgq7GNWOEN9 hL/g/r3Yd+cXBjFdubhOeLztkTvPk9O8kap/VwLwlo7f6w2V/TPOfnLxzeNTg9MXpYZB gVtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l63si46001794pge.264.2019.08.06.08.30.08; Tue, 06 Aug 2019 08:30:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732976AbfHFP1i (ORCPT + 99 others); Tue, 6 Aug 2019 11:27:38 -0400 Received: from mga18.intel.com ([134.134.136.126]:27010 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730188AbfHFP1i (ORCPT ); Tue, 6 Aug 2019 11:27:38 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Aug 2019 08:27:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,353,1559545200"; d="scan'208";a="174208993" Received: from crojewsk-mobl1.ger.corp.intel.com (HELO [10.252.15.113]) ([10.252.15.113]) by fmsmga008.fm.intel.com with ESMTP; 06 Aug 2019 08:27:30 -0700 Subject: Re: [PATCH 06/17] soundwire: cadence_master: use firmware defaults for frame shape To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, Blauciak@vger.kernel.org, Slawomir , Sanyog Kale References: <20190806005522.22642-1-pierre-louis.bossart@linux.intel.com> <20190806005522.22642-7-pierre-louis.bossart@linux.intel.com> From: Cezary Rojewski Message-ID: <03b6091b-af41-ac54-43c7-196a3583a731@intel.com> Date: Tue, 6 Aug 2019 17:27:28 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190806005522.22642-7-pierre-louis.bossart@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-08-06 02:55, Pierre-Louis Bossart wrote: > diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c > index 5d9729b4d634..89c55e4bb72c 100644 > --- a/drivers/soundwire/cadence_master.c > +++ b/drivers/soundwire/cadence_master.c > @@ -48,6 +48,8 @@ > #define CDNS_MCP_SSPSTAT 0xC > #define CDNS_MCP_FRAME_SHAPE 0x10 > #define CDNS_MCP_FRAME_SHAPE_INIT 0x14 > +#define CDNS_MCP_FRAME_SHAPE_COL_MASK GENMASK(2, 0) > +#define CDNS_MCP_FRAME_SHAPE_ROW_OFFSET 3 > > #define CDNS_MCP_CONFIG_UPDATE 0x18 > #define CDNS_MCP_CONFIG_UPDATE_BIT BIT(0) > @@ -175,7 +177,6 @@ > /* Driver defaults */ > > #define CDNS_DEFAULT_CLK_DIVIDER 0 > -#define CDNS_DEFAULT_FRAME_SHAPE 0x30 > #define CDNS_DEFAULT_SSP_INTERVAL 0x18 > #define CDNS_TX_TIMEOUT 2000 > > @@ -901,6 +902,20 @@ int sdw_cdns_pdi_init(struct sdw_cdns *cdns, > } > EXPORT_SYMBOL(sdw_cdns_pdi_init); > > +static u32 cdns_set_initial_frame_shape(int n_rows, int n_cols) > +{ > + u32 val; > + int c; > + int r; > + > + r = sdw_find_row_index(n_rows); > + c = sdw_find_col_index(n_cols) & CDNS_MCP_FRAME_SHAPE_COL_MASK; > + > + val = (r << CDNS_MCP_FRAME_SHAPE_ROW_OFFSET) | c; > + > + return val; > +} > + Guess this have been said already, but this function could be simplified - unless you really want to keep explicit variable declaration. Both "c" and "r" declarations could be merged into single line while "val" is not needed at all. One more thing - is AND bitwise op really needed for cols explicitly? We know all col values upfront - these are static and declared in global table nearby. Static declaration takes care of "initial range-check". Is another one necessary? Moreover, this is a _get_ and certainly not a _set_ type of function. I'd even consider renaming it to: "cdns_get_frame_shape" as this is neither a _set_ nor an explicit initial frame shape setter. It might be even helpful to split two usages: #define sdw_frame_shape(col_idx, row_idx) \ ((row_idx << CDNS_MCP_FRAME_SHAPE_ROW_OFFSET) | col_idx) u32 cdns_get_frame_shape(u16 rows, u16 cols) { u16 c, r; r = sdw_find_row_index(rows); c = sdw_find_col_index(cols); return sdw_frame_shape(c, r); } The above may even be simplified into one-liner.