All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] ALSA: control: optimization for position offset macro of TLV data
@ 2018-05-13 22:09 Takashi Sakamoto
  2018-05-13 22:09 ` [PATCH 1/4] ALSA: control: complement TLV macro for db-minmax and db-linear types Takashi Sakamoto
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Takashi Sakamoto @ 2018-05-13 22:09 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel

Hi,

This patchset is a supplement for a commit 08f9f4485f21 ('ALSA: core
api: define offsets for TLV items') for items below:
 - add position offset macro for db-minmax and db-linear types of TLV data
 - optimization with these macros

Takashi Sakamoto (4):
  ALSA: control: complement TLV macro for db-minmax and db-linear types
  ALSA: vmaster: use position offset macro of TLV data
  ALSA: hda: use position offset macro of TLV data
  ALSA: isight: use position offset macro of TLV data

 include/uapi/sound/tlv.h    |  8 ++++++++
 sound/core/vmaster.c        | 16 +++++++++-------
 sound/firewire/isight.c     | 10 ++++++----
 sound/pci/hda/hda_codec.c   | 22 +++++++++++-----------
 sound/pci/hda/hda_generic.c |  2 +-
 5 files changed, 35 insertions(+), 23 deletions(-)

-- 
2.14.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] ALSA: control: complement TLV macro for db-minmax and db-linear types
  2018-05-13 22:09 [PATCH 0/4] ALSA: control: optimization for position offset macro of TLV data Takashi Sakamoto
@ 2018-05-13 22:09 ` Takashi Sakamoto
  2018-05-13 22:09 ` [PATCH 2/4] ALSA: vmaster: use position offset macro of TLV data Takashi Sakamoto
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Takashi Sakamoto @ 2018-05-13 22:09 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel, Ranjani Sridharan

A commit 08f9f4485f21 ('ALSA: core api: define offsets for TLV items')
introduced a series of macro for offset of db-scale type of TLV, however
there are some types of TLV to add similar macros.

This commit complements macros for offset of db-minmax and db-linear types
of TLV data.

Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 include/uapi/sound/tlv.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/uapi/sound/tlv.h b/include/uapi/sound/tlv.h
index e3437e96519a..7d6d65f60a42 100644
--- a/include/uapi/sound/tlv.h
+++ b/include/uapi/sound/tlv.h
@@ -83,6 +83,10 @@
 		SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
 	}
 
+/* Accessor offsets for min, max items in db-minmax types of TLV. */
+#define SNDRV_CTL_TLVO_DB_MINMAX_MIN	2
+#define SNDRV_CTL_TLVO_DB_MINMAX_MAX	3
+
 /* linear volume between min_dB and max_dB (.01dB unit) */
 #define SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
 	SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_LINEAR, (min_dB), (max_dB))
@@ -91,6 +95,10 @@
 		SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
 	}
 
+/* Accessor offsets for min, max items in db-linear type of TLV. */
+#define SNDRV_CTL_TLVO_DB_LINEAR_MIN	2
+#define SNDRV_CTL_TLVO_DB_LINEAR_MAX	3
+
 /* dB range container:
  * Items in dB range container must be ordered by their values and by their
  * dB values. This implies that larger values must correspond with larger
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] ALSA: vmaster: use position offset macro of TLV data
  2018-05-13 22:09 [PATCH 0/4] ALSA: control: optimization for position offset macro of TLV data Takashi Sakamoto
  2018-05-13 22:09 ` [PATCH 1/4] ALSA: control: complement TLV macro for db-minmax and db-linear types Takashi Sakamoto
@ 2018-05-13 22:09 ` Takashi Sakamoto
  2018-05-13 22:09 ` [PATCH 3/4] ALSA: hda: " Takashi Sakamoto
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Takashi Sakamoto @ 2018-05-13 22:09 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/core/vmaster.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index 9e96186742d0..58fa3f94722a 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -421,13 +421,15 @@ struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
 	kctl->private_free = master_free;
 
 	/* additional (constant) TLV read */
-	if (tlv &&
-	    (tlv[0] == SNDRV_CTL_TLVT_DB_SCALE ||
-	     tlv[0] == SNDRV_CTL_TLVT_DB_MINMAX ||
-	     tlv[0] == SNDRV_CTL_TLVT_DB_MINMAX_MUTE)) {
-		kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
-		memcpy(master->tlv, tlv, sizeof(master->tlv));
-		kctl->tlv.p = master->tlv;
+	if (tlv) {
+		unsigned int type = tlv[SNDRV_CTL_TLVO_TYPE];
+		if (type == SNDRV_CTL_TLVT_DB_SCALE ||
+		    type == SNDRV_CTL_TLVT_DB_MINMAX ||
+		    type == SNDRV_CTL_TLVT_DB_MINMAX_MUTE) {
+			kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
+			memcpy(master->tlv, tlv, sizeof(master->tlv));
+			kctl->tlv.p = master->tlv;
+		}
 	}
 
 	return kctl;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] ALSA: hda: use position offset macro of TLV data
  2018-05-13 22:09 [PATCH 0/4] ALSA: control: optimization for position offset macro of TLV data Takashi Sakamoto
  2018-05-13 22:09 ` [PATCH 1/4] ALSA: control: complement TLV macro for db-minmax and db-linear types Takashi Sakamoto
  2018-05-13 22:09 ` [PATCH 2/4] ALSA: vmaster: use position offset macro of TLV data Takashi Sakamoto
@ 2018-05-13 22:09 ` Takashi Sakamoto
  2018-05-13 22:09 ` [PATCH 4/4] ALSA: isight: " Takashi Sakamoto
  2018-05-14 15:49 ` [PATCH 0/4] ALSA: control: optimization for " Takashi Iwai
  4 siblings, 0 replies; 7+ messages in thread
From: Takashi Sakamoto @ 2018-05-13 22:09 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/pci/hda/hda_codec.c   | 22 +++++++++++-----------
 sound/pci/hda/hda_generic.c |  2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 63f177d975fd..08151f3c0b13 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1493,10 +1493,10 @@ static void get_ctl_amp_tlv(struct snd_kcontrol *kcontrol, unsigned int *tlv)
 	val1 = ((int)val1) * ((int)val2);
 	if (min_mute || (caps & AC_AMPCAP_MIN_MUTE))
 		val2 |= TLV_DB_SCALE_MUTE;
-	tlv[0] = SNDRV_CTL_TLVT_DB_SCALE;
-	tlv[1] = 2 * sizeof(unsigned int);
-	tlv[2] = val1;
-	tlv[3] = val2;
+	tlv[SNDRV_CTL_TLVO_TYPE] = SNDRV_CTL_TLVT_DB_SCALE;
+	tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(unsigned int);
+	tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = val1;
+	tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] = val2;
 }
 
 /**
@@ -1544,10 +1544,10 @@ void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
 	nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
 	step = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
 	step = (step + 1) * 25;
-	tlv[0] = SNDRV_CTL_TLVT_DB_SCALE;
-	tlv[1] = 2 * sizeof(unsigned int);
-	tlv[2] = -nums * step;
-	tlv[3] = step;
+	tlv[SNDRV_CTL_TLVO_TYPE] = SNDRV_CTL_TLVT_DB_SCALE;
+	tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(unsigned int);
+	tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] = -nums * step;
+	tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] = step;
 }
 EXPORT_SYMBOL_GPL(snd_hda_set_vmaster_tlv);
 
@@ -1845,10 +1845,10 @@ static int init_slave_0dB(struct snd_kcontrol *slave,
 	} else if (kctl->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)
 		tlv = kctl->tlv.p;
 
-	if (!tlv || tlv[0] != SNDRV_CTL_TLVT_DB_SCALE)
+	if (!tlv || tlv[SNDRV_CTL_TLVO_TYPE] != SNDRV_CTL_TLVT_DB_SCALE)
 		return 0;
 
-	step = tlv[3];
+	step = tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP];
 	step &= ~TLV_DB_SCALE_MUTE;
 	if (!step)
 		return 0;
@@ -1860,7 +1860,7 @@ static int init_slave_0dB(struct snd_kcontrol *slave,
 	}
 
 	arg->step = step;
-	val = -tlv[2] / step;
+	val = -tlv[SNDRV_CTL_TLVO_DB_SCALE_MIN] / step;
 	if (val > 0) {
 		put_kctl_with_value(slave, val);
 		return val;
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 51030f040745..db773e219aaa 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -2065,7 +2065,7 @@ static int parse_output_paths(struct hda_codec *codec)
 			snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
 						HDA_OUTPUT, spec->vmaster_tlv);
 			if (spec->dac_min_mute)
-				spec->vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
+				spec->vmaster_tlv[SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP] |= TLV_DB_SCALE_MUTE;
 		}
 	}
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] ALSA: isight: use position offset macro of TLV data
  2018-05-13 22:09 [PATCH 0/4] ALSA: control: optimization for position offset macro of TLV data Takashi Sakamoto
                   ` (2 preceding siblings ...)
  2018-05-13 22:09 ` [PATCH 3/4] ALSA: hda: " Takashi Sakamoto
@ 2018-05-13 22:09 ` Takashi Sakamoto
  2018-05-14  6:32   ` Clemens Ladisch
  2018-05-14 15:49 ` [PATCH 0/4] ALSA: control: optimization for " Takashi Iwai
  4 siblings, 1 reply; 7+ messages in thread
From: Takashi Sakamoto @ 2018-05-13 22:09 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/isight.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
index 46092fa3ff9b..3919e186a30b 100644
--- a/sound/firewire/isight.c
+++ b/sound/firewire/isight.c
@@ -569,18 +569,20 @@ static int isight_create_mixer(struct isight *isight)
 		return err;
 	isight->gain_max = be32_to_cpu(value);
 
-	isight->gain_tlv[0] = SNDRV_CTL_TLVT_DB_MINMAX;
-	isight->gain_tlv[1] = 2 * sizeof(unsigned int);
+	isight->gain_tlv[SNDRV_CTL_TLVO_TYPE] = SNDRV_CTL_TLVT_DB_MINMAX;
+	isight->gain_tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(unsigned int);
 
 	err = reg_read(isight, REG_GAIN_DB_START, &value);
 	if (err < 0)
 		return err;
-	isight->gain_tlv[2] = (s32)be32_to_cpu(value) * 100;
+	isight->gain_tlv[SNDRV_CTL_TLVO_DB_MINMAX_MIN] =
+						(s32)be32_to_cpu(value) * 100;
 
 	err = reg_read(isight, REG_GAIN_DB_END, &value);
 	if (err < 0)
 		return err;
-	isight->gain_tlv[3] = (s32)be32_to_cpu(value) * 100;
+	isight->gain_tlv[SNDRV_CTL_TLVO_DB_MINMAX_MAX] =
+						(s32)be32_to_cpu(value) * 100;
 
 	ctl = snd_ctl_new1(&gain_control, isight);
 	if (ctl)
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] ALSA: isight: use position offset macro of TLV data
  2018-05-13 22:09 ` [PATCH 4/4] ALSA: isight: " Takashi Sakamoto
@ 2018-05-14  6:32   ` Clemens Ladisch
  0 siblings, 0 replies; 7+ messages in thread
From: Clemens Ladisch @ 2018-05-14  6:32 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel, Takashi Sakamoto

Takashi Sakamoto wrote:
> A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
> of TLV data. This commit applies a code optimization.
>
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

Acked-by: Clemens Ladisch <clemens@ladisch.de>

> ---
>  sound/firewire/isight.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
> index 46092fa3ff9b..3919e186a30b 100644
> --- a/sound/firewire/isight.c
> +++ b/sound/firewire/isight.c
> @@ -569,18 +569,20 @@ static int isight_create_mixer(struct isight *isight)
>  		return err;
>  	isight->gain_max = be32_to_cpu(value);
>
> -	isight->gain_tlv[0] = SNDRV_CTL_TLVT_DB_MINMAX;
> -	isight->gain_tlv[1] = 2 * sizeof(unsigned int);
> +	isight->gain_tlv[SNDRV_CTL_TLVO_TYPE] = SNDRV_CTL_TLVT_DB_MINMAX;
> +	isight->gain_tlv[SNDRV_CTL_TLVO_LEN] = 2 * sizeof(unsigned int);
>
>  	err = reg_read(isight, REG_GAIN_DB_START, &value);
>  	if (err < 0)
>  		return err;
> -	isight->gain_tlv[2] = (s32)be32_to_cpu(value) * 100;
> +	isight->gain_tlv[SNDRV_CTL_TLVO_DB_MINMAX_MIN] =
> +						(s32)be32_to_cpu(value) * 100;
>
>  	err = reg_read(isight, REG_GAIN_DB_END, &value);
>  	if (err < 0)
>  		return err;
> -	isight->gain_tlv[3] = (s32)be32_to_cpu(value) * 100;
> +	isight->gain_tlv[SNDRV_CTL_TLVO_DB_MINMAX_MAX] =
> +						(s32)be32_to_cpu(value) * 100;
>
>  	ctl = snd_ctl_new1(&gain_control, isight);
>  	if (ctl)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/4] ALSA: control: optimization for position offset macro of TLV data
  2018-05-13 22:09 [PATCH 0/4] ALSA: control: optimization for position offset macro of TLV data Takashi Sakamoto
                   ` (3 preceding siblings ...)
  2018-05-13 22:09 ` [PATCH 4/4] ALSA: isight: " Takashi Sakamoto
@ 2018-05-14 15:49 ` Takashi Iwai
  4 siblings, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2018-05-14 15:49 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: alsa-devel, clemens

On Mon, 14 May 2018 00:09:49 +0200,
Takashi Sakamoto wrote:
> 
> Hi,
> 
> This patchset is a supplement for a commit 08f9f4485f21 ('ALSA: core
> api: define offsets for TLV items') for items below:
>  - add position offset macro for db-minmax and db-linear types of TLV data
>  - optimization with these macros
> 
> Takashi Sakamoto (4):
>   ALSA: control: complement TLV macro for db-minmax and db-linear types
>   ALSA: vmaster: use position offset macro of TLV data
>   ALSA: hda: use position offset macro of TLV data
>   ALSA: isight: use position offset macro of TLV data

Applied all four patches now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-14 15:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-13 22:09 [PATCH 0/4] ALSA: control: optimization for position offset macro of TLV data Takashi Sakamoto
2018-05-13 22:09 ` [PATCH 1/4] ALSA: control: complement TLV macro for db-minmax and db-linear types Takashi Sakamoto
2018-05-13 22:09 ` [PATCH 2/4] ALSA: vmaster: use position offset macro of TLV data Takashi Sakamoto
2018-05-13 22:09 ` [PATCH 3/4] ALSA: hda: " Takashi Sakamoto
2018-05-13 22:09 ` [PATCH 4/4] ALSA: isight: " Takashi Sakamoto
2018-05-14  6:32   ` Clemens Ladisch
2018-05-14 15:49 ` [PATCH 0/4] ALSA: control: optimization for " Takashi Iwai

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.