All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaud Pouliquen <arnaud.pouliquen@st.com>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Cc: "kernel@stlinux.com" <kernel@stlinux.com>,
	Takashi Iwai <tiwai@suse.de>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	Jyri Sarha <jsarha@ti.com>, David Airlie <airlied@linux.ie>,
	"broonie@kernel.org" <broonie@kernel.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH 2/2] ASoC: hdmi-codec: add channel mapping control
Date: Tue, 13 Dec 2016 15:49:49 +0100	[thread overview]
Message-ID: <3943870f-c98b-da0e-e4e7-0a4a3fd337c7@st.com> (raw)
In-Reply-To: <d8b4e5cf-f297-f075-801f-6517393d9ca7@sakamocchi.jp>



On 12/13/2016 02:58 PM, Takashi Sakamoto wrote:
> On 2016年12月13日 22:23, Takashi Sakamoto wrote:
>> Hi Arnaud,
>>>> This table is invariant in lifetime of the storage object, as well.
>>>> Let's put into .rodata section, too.
>>>>
>>> This table is updated in hdmi_codec_cea_init_channel_alloc so can not be
>>> constant. In theory i could declare all field instead of computing some.
>>> But for lisibility, i would prefer to just declare ca_index  and
>>> speakers allocation field in this table (i will declared both as const)
>>
>> You should pay enough attention to a case that one system has several
>> GPUs to which relevant GPU drivers register HDMI_CODEC_DRV_NAME platform
>> device. The 'static' modifier has an effect to keep just one storage
>> object, thus your code causes bugs in the case.
> 
> Oops, the bug is unrelated to the static modifier. The modifier is for 
> reference scope. I'll correct as the file local symbol has just one 
> storage object.
> 
> (I might be tired tonight...)
> 
i understood in this way :-)
As 'ca_index' and "speakers" fiel are constants
the fields computed in hdmi_codec_cea_init_channel_alloc will
not change if the functions is called several time ( multi-instances).
but agree that it is not very clean, but this should work.
To avoid to compute several time, i can also add a test in
hdmi_codec_cea_init_channel_alloc to do it only one time (by testing
hdmi_codec_channel_alloc[0].channels), or perhaps better an atomic local
variable to avoid side effect for Multiprocessor archs.

Now the second approach is to define all the field. This indeeds a big
table (around 256 lines instead of 32 lines):

static const struct hdmi_codec_cea_spk_alloc hdmi_codec_channel_alloc[] = {
	{
		.ca_index = 0x00,
		.speakers = {   0,    0,   0,   0,   0,    0,  FR,  FL } },
		.channels = 2,
		.spk_mask = FR | FL,
		.spk_na_mask = 0x00,
	},
	{ /* 2.1 */
		.ca_index = 0x01,
		.speakers = {   0,    0,   0,   0,   0,  LFE,  FR,  FL } },
		.channels = 3,
		.spk_mask = FR | FL | LFE,
		.spk_na_mask = 0x00,
	},
	{ /* Dolby Surround */
		.ca_index = 0x02,
		.speakers = {   0,    0,   0,   0,  FC,    0,  FR,  FL } },
		.channels = 4,
		.spk_mask = FR | FL | FC,
		.spk_na_mask = BIT(2),
	},
[...]

	{
		.ca_index = 0x1f,
		.speakers = { FRC,  FLC,  RR,  RL,  FC,  LFE,  FR,  FL } },
		.channels = 8,
		.spk_mask = FRC | FLC | RR | RL | FC | LFE | FR | FL,
		.spk_na_mask = 0x0,
	},

I would prefer the first one to save lines, but i can implement the
second one (or another one if you have an alternative to propose).

Regards
Arnaud
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2016-12-13 14:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08 16:37 [PATCH 0/2] Generic HDMI codec: Add channel mapping control Arnaud Pouliquen
2016-12-08 16:37 ` [PATCH 1/2] DRM: add help to get ELD speaker allocation Arnaud Pouliquen
2017-01-20 15:29   ` Applied "DRM: add help to get ELD speaker allocation" to the asoc tree Mark Brown
2016-12-08 16:37 ` [PATCH 2/2] ASoC: hdmi-codec: add channel mapping control Arnaud Pouliquen
2016-12-11  6:09   ` Takashi Sakamoto
2016-12-12  9:38     ` Arnaud Pouliquen
2016-12-12  9:54       ` Takashi Iwai
2016-12-12 12:12         ` Takashi Sakamoto
2016-12-12 12:55           ` Takashi Iwai
2016-12-12 14:05             ` Takashi Sakamoto
2016-12-12 15:12               ` Arnaud Pouliquen
2016-12-12 12:03       ` Takashi Sakamoto
2016-12-12 13:46         ` Arnaud Pouliquen
2016-12-13 13:23           ` Takashi Sakamoto
2016-12-13 13:58             ` Takashi Sakamoto
2016-12-13 14:49               ` Arnaud Pouliquen [this message]
2016-12-12 17:16         ` Arnaud Pouliquen
2016-12-08 20:52 ` [PATCH 0/2] Generic HDMI codec: Add " Takashi Sakamoto
2016-12-08 21:13   ` Takashi Sakamoto
2016-12-09 14:06     ` Arnaud Pouliquen
2016-12-11  1:16       ` Takashi Sakamoto

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=3943870f-c98b-da0e-e4e7-0a4a3fd337c7@st.com \
    --to=arnaud.pouliquen@st.com \
    --cc=airlied@linux.ie \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=kernel@stlinux.com \
    --cc=lgirdwood@gmail.com \
    --cc=o-takashi@sakamocchi.jp \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.