alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: "Rojewski, Cezary" <cezary.rojewski@intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "pierre-louis.bossart@linux.intel.com"
	<pierre-louis.bossart@linux.intel.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"Kaczmarski, Filip" <filip.kaczmarski@intel.com>,
	"N, Harshapriya" <harshapriya.n@intel.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"Barlik, Marcin" <marcin.barlik@intel.com>,
	"zwisler@google.com" <zwisler@google.com>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"tiwai@suse.com" <tiwai@suse.com>,
	"Proborszcz, Filip" <filip.proborszcz@intel.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"amadeuszx.slawinski@linux.intel.com"
	<amadeuszx.slawinski@linux.intel.com>,
	"Wasko, Michal" <michal.wasko@intel.com>,
	"cujomalainey@chromium.org" <cujomalainey@chromium.org>,
	"Hejmowski, Krzysztof" <krzysztof.hejmowski@intel.com>,
	"ppapierkowski@habana.ai" <ppapierkowski@habana.ai>,
	"Gopal,  Vamshi Krishna" <vamshi.krishna.gopal@intel.com>
Subject: RE: [PATCH v8 06/14] ASoC: Intel: catpt: PCM operations
Date: Wed, 23 Sep 2020 18:23:22 +0000	[thread overview]
Message-ID: <bd5b35fd96be42579bf6d7861379772f@intel.com> (raw)
In-Reply-To: <20200923135422.GM3956970@smile.fi.intel.com>

On 2020-09-23 3:54 PM, Andy Shevchenko wrote:
> On Wed, Sep 23, 2020 at 02:25:00PM +0200, Cezary Rojewski wrote:
>> DSP designed for Lynxpoint and Wildcat Point offers no dynamic topology
>> i.e. all pipelines are already defined within firmware and host is
>> relegated to allocing stream for predefined pins. This is represented by
>> 'catpt_topology' member.
>>

...

>> +static u32 catpt_get_channel_map(enum catpt_channel_config config)
>> +{
>> +	switch (config) {
>> +	case CATPT_CHANNEL_CONFIG_MONO:
>> +		return (GENMASK(31, 4) | CATPT_CHANNEL_CENTER);
> 
> In all cases outer parentheses are not needed. Also I expected to see DUAL MONO
> case here, rather than below.
> 

Ack for the parentheses but what's wrong with the sweet '_STEREO' name?
This function is based on internal equivalent. As I aim to ease any
further debug/development by aligning with Windows equivalent, name
changes for no real reason do not help with that goal.

If I'm missing something about 'DUAL MONO', feel free to correct me.

>> +	case CATPT_CHANNEL_CONFIG_STEREO:
>> +		return (GENMASK(31, 8) | CATPT_CHANNEL_LEFT
>> +				       | (CATPT_CHANNEL_RIGHT << 4));
>> +
>> +	case CATPT_CHANNEL_CONFIG_2_POINT_1:
>> +		return (GENMASK(31, 12) | CATPT_CHANNEL_LEFT
>> +					| (CATPT_CHANNEL_RIGHT << 4)
>> +					| (CATPT_CHANNEL_LFE << 8));
>> +
>> +	case CATPT_CHANNEL_CONFIG_3_POINT_0:
>> +		return (GENMASK(31, 12) | CATPT_CHANNEL_LEFT
>> +					| (CATPT_CHANNEL_CENTER << 4)
>> +					| (CATPT_CHANNEL_RIGHT << 8));
>> +
>> +	case CATPT_CHANNEL_CONFIG_3_POINT_1:
>> +		return (GENMASK(31, 16) | CATPT_CHANNEL_LEFT
>> +					| (CATPT_CHANNEL_CENTER << 4)
>> +					| (CATPT_CHANNEL_RIGHT << 8)
>> +					| (CATPT_CHANNEL_LFE << 12));
>> +
>> +	case CATPT_CHANNEL_CONFIG_QUATRO:
>> +		return (GENMASK(31, 16) | CATPT_CHANNEL_LEFT
>> +					| (CATPT_CHANNEL_RIGHT << 4)
>> +					| (CATPT_CHANNEL_LEFT_SURROUND << 8)
>> +					| (CATPT_CHANNEL_RIGHT_SURROUND << 12));
>> +
>> +	case CATPT_CHANNEL_CONFIG_4_POINT_0:
>> +		return (GENMASK(31, 16) | CATPT_CHANNEL_LEFT
>> +					| (CATPT_CHANNEL_CENTER << 4)
>> +					| (CATPT_CHANNEL_RIGHT << 8)
>> +					| (CATPT_CHANNEL_CENTER_SURROUND << 12));
>> +
>> +	case CATPT_CHANNEL_CONFIG_5_POINT_0:
>> +		return (GENMASK(31, 20) | CATPT_CHANNEL_LEFT
>> +					| (CATPT_CHANNEL_CENTER << 4)
>> +					| (CATPT_CHANNEL_RIGHT << 8)
>> +					| (CATPT_CHANNEL_LEFT_SURROUND << 12)
>> +					| (CATPT_CHANNEL_RIGHT_SURROUND << 16));
>> +
>> +	case CATPT_CHANNEL_CONFIG_5_POINT_1:
>> +		return (GENMASK(31, 24) | CATPT_CHANNEL_CENTER
>> +					| (CATPT_CHANNEL_LEFT << 4)
>> +					| (CATPT_CHANNEL_RIGHT << 8)
>> +					| (CATPT_CHANNEL_LEFT_SURROUND << 12)
>> +					| (CATPT_CHANNEL_RIGHT_SURROUND << 16)
>> +					| (CATPT_CHANNEL_LFE << 20));
>> +
>> +	case CATPT_CHANNEL_CONFIG_DUAL_MONO:
>> +		return (GENMASK(31, 8) | CATPT_CHANNEL_LEFT
>> +				       | (CATPT_CHANNEL_LEFT << 4));
>> +
>> +	default:
>> +		return U32_MAX;
>> +	}
>> +}
>> +

...

>> +#define DSP_VOLUME_MAX	S32_MAX /* 0db */
> 
>> +static const u32 volume_map[] = {
>> +	DSP_VOLUME_MAX >> 30,
>> +	DSP_VOLUME_MAX >> 29,
>> +	DSP_VOLUME_MAX >> 28,
>> +	DSP_VOLUME_MAX >> 27,
>> +	DSP_VOLUME_MAX >> 26,
>> +	DSP_VOLUME_MAX >> 25,
>> +	DSP_VOLUME_MAX >> 24,
>> +	DSP_VOLUME_MAX >> 23,
>> +	DSP_VOLUME_MAX >> 22,
>> +	DSP_VOLUME_MAX >> 21,
>> +	DSP_VOLUME_MAX >> 20,
>> +	DSP_VOLUME_MAX >> 19,
>> +	DSP_VOLUME_MAX >> 18,
>> +	DSP_VOLUME_MAX >> 17,
>> +	DSP_VOLUME_MAX >> 16,
>> +	DSP_VOLUME_MAX >> 15,
>> +	DSP_VOLUME_MAX >> 14,
>> +	DSP_VOLUME_MAX >> 13,
>> +	DSP_VOLUME_MAX >> 12,
>> +	DSP_VOLUME_MAX >> 11,
>> +	DSP_VOLUME_MAX >> 10,
>> +	DSP_VOLUME_MAX >> 9,
>> +	DSP_VOLUME_MAX >> 8,
>> +	DSP_VOLUME_MAX >> 7,
>> +	DSP_VOLUME_MAX >> 6,
>> +	DSP_VOLUME_MAX >> 5,
>> +	DSP_VOLUME_MAX >> 4,
>> +	DSP_VOLUME_MAX >> 3,
>> +	DSP_VOLUME_MAX >> 2,
>> +	DSP_VOLUME_MAX >> 1,
>> +	DSP_VOLUME_MAX >> 0,
>> +};
> 
> Why not to get rid of this table completely?
> 

I don't see anything wrong with this lookup table. If you insist I can
get rid of it - that's the last piece of /haswell/ that survived the
"cleanup" afterall..

>> +static u32 ctlvol_to_dspvol(u32 value)
>> +{
>> +	if (value >= ARRAY_SIZE(volume_map))
>> +		value = 0;
>> +	return volume_map[value];
> 
> 	if (value > 30)
> 		value = 0;
> 	return DSP_VOLUME_MAX >> (30 - value);
> 

I suppose 'DSP_VOLUME_STEP_MAX 30' is to be defined right next to
DSP_VOLUME_MAX.

As I said in earlier responses, please note size of this table is
helpful when assigning kcontrol info in catpt_volume_info(). Macro will
take its place then.

>> +}
>> +
>> +static u32 dspvol_to_ctlvol(u32 volume)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE(volume_map); i++)
>> +		if (volume_map[i] >= volume)
>> +			return i;
>> +	return i - 1;
> 
> fls() ?
> 

Well, fls(DSP_VOLUME_MAX) yields 31 which is inappropriate for
kcontrol with value range: 0-30.

Guess you meant: __fls(). Following is the implementation (accounting
for edge cases):
	if (volume > DSP_VOLUME_MAX)
		return DSP_VOLUME_STEP_MAX;
	return volume ? __fls(volume) : 0;


Thanks,
Czarek


  parent reply	other threads:[~2020-09-23 18:24 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 12:24 [PATCH v8 00/14] ASoC: Intel: Catpt - Lynx and Wildcat point Cezary Rojewski
2020-09-23 12:24 ` [PATCH v8 01/14] ASoC: Intel: Add catpt base members Cezary Rojewski
2020-09-23 13:18   ` Andy Shevchenko
2020-09-23 12:24 ` [PATCH v8 02/14] ASoC: Intel: catpt: Implement IPC protocol Cezary Rojewski
2020-09-23 13:17   ` Andy Shevchenko
2020-09-23 19:24     ` Rojewski, Cezary
2020-09-23 19:33       ` Rojewski, Cezary
2020-09-23 12:24 ` [PATCH v8 03/14] ASoC: Intel: catpt: Add IPC message handlers Cezary Rojewski
2020-09-23 13:25   ` Andy Shevchenko
2020-09-23 12:24 ` [PATCH v8 04/14] ASoC: Intel: catpt: Define DSP operations Cezary Rojewski
2020-09-23 13:26   ` Andy Shevchenko
2020-09-23 12:24 ` [PATCH v8 05/14] ASoC: Intel: catpt: Firmware loading and context restore Cezary Rojewski
2020-09-23 13:29   ` Andy Shevchenko
2020-09-23 12:25 ` [PATCH v8 06/14] ASoC: Intel: catpt: PCM operations Cezary Rojewski
2020-09-23 13:54   ` Andy Shevchenko
2020-09-23 14:53     ` Mark Brown
2020-09-23 18:23     ` Rojewski, Cezary [this message]
2020-09-24 14:22       ` Andy Shevchenko
2020-09-26  8:52         ` Rojewski, Cezary
2020-09-23 12:25 ` [PATCH v8 07/14] ASoC: Intel: catpt: Device driver lifecycle Cezary Rojewski
2020-09-23 13:31   ` Andy Shevchenko
2020-09-23 12:25 ` [PATCH v8 08/14] ASoC: Intel: catpt: Event tracing Cezary Rojewski
2020-09-23 13:29   ` Andy Shevchenko
2020-09-23 12:25 ` [PATCH v8 09/14] ASoC: Intel: catpt: Simple sysfs attributes Cezary Rojewski
2020-09-23 13:34   ` Andy Shevchenko
2020-09-23 18:31     ` Rojewski, Cezary
2020-09-24 14:24       ` Andy Shevchenko
2020-09-23 17:17   ` Greg KH
2020-09-23 12:25 ` [PATCH v8 10/14] ASoC: Intel: haswell: Remove haswell-solution specific code Cezary Rojewski
2020-09-23 12:25 ` [PATCH v8 11/14] ASoC: Intel: broadwell: " Cezary Rojewski
2020-09-23 12:25 ` [PATCH v8 12/14] ASoC: Intel: bdw-5650: " Cezary Rojewski
2020-09-23 12:25 ` [PATCH v8 13/14] ASoC: Intel: bdw-5677: " Cezary Rojewski
2020-09-23 12:25 ` [PATCH v8 14/14] ASoC: Intel: Select catpt and deprecate haswell Cezary Rojewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bd5b35fd96be42579bf6d7861379772f@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=cujomalainey@chromium.org \
    --cc=filip.kaczmarski@intel.com \
    --cc=filip.proborszcz@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=harshapriya.n@intel.com \
    --cc=krzysztof.hejmowski@intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=marcin.barlik@intel.com \
    --cc=michal.wasko@intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ppapierkowski@habana.ai \
    --cc=tiwai@suse.com \
    --cc=vamshi.krishna.gopal@intel.com \
    --cc=zwisler@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).