Hello community, here is the log from the commit of package alsa for openSUSE:Factory checked in at 2014-07-26 12:19:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/alsa (Old) and /work/SRC/openSUSE:Factory/.alsa.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "alsa" Changes: -------- --- /work/SRC/openSUSE:Factory/alsa/alsa.changes 2014-06-25 06:57:36.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.alsa.new/alsa.changes 2014-07-26 12:19:46.000000000 +0200 @@ -1,0 +2,24 @@ +Tue Jul 22 17:46:51 CEST 2014 - [email protected] + +- Remove superfluous Loopback.conf from the source, as it was + already included in 1.0.28 tarball +- Backport upstream fixes: UCM dummy PCM definition, ICE1712 surround + definitions, USB-audio secondary PCM definition, PCM rate plugin + boundary overwrap fix, MONOTONIC_RAW timestamp support, PCM route + plugin 3-byte format fixes, etc: + 0001-ucm-Document-PlaybackPCMIsDummy-and-CapturePCMIsDumm.patch + 0002-ICE1712-add-surround71-pcm-definition.patch + 0003-USB-Audio-Add-second-S-PDIF-device-on-Phiree-U2.patch + 0004-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch + 0005-pcm-Provide-a-CLOCK_MONOTONIC_RAW-timestamp-type.patch + 0006-Add-timestamp-type-to-sw_params-internal-only.patch + 0007-pcm-Add-sw_params-API-functions-to-get-set-timestamp.patch + 0008-pcm-Implement-timestamp-type-setup-in-hw-plugin.patch + 0009-pcm-Implement-timestamp-type-handling-in-all-plugins.patch + 0010-test-audio_time-Set-timestamp-type-explicitly.patch + 0011-pcm-route-Use-get-put-labels-for-all-3-byte-formats.patch + 0012-pcm-Fill-sw_params-proto-field.patch + 0013-pcm-route-Use-get32-for-multi-source-route-calculati.patch + 0014-pcm-Drop-snd_pcm_linear_-get-put-32_index.patch + +------------------------------------------------------------------- Old: ---- Loopback.conf New: ---- 0001-ucm-Document-PlaybackPCMIsDummy-and-CapturePCMIsDumm.patch 0002-ICE1712-add-surround71-pcm-definition.patch 0003-USB-Audio-Add-second-S-PDIF-device-on-Phiree-U2.patch 0004-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch 0005-pcm-Provide-a-CLOCK_MONOTONIC_RAW-timestamp-type.patch 0006-Add-timestamp-type-to-sw_params-internal-only.patch 0007-pcm-Add-sw_params-API-functions-to-get-set-timestamp.patch 0008-pcm-Implement-timestamp-type-setup-in-hw-plugin.patch 0009-pcm-Implement-timestamp-type-handling-in-all-plugins.patch 0010-test-audio_time-Set-timestamp-type-explicitly.patch 0011-pcm-route-Use-get-put-labels-for-all-3-byte-formats.patch 0012-pcm-Fill-sw_params-proto-field.patch 0013-pcm-route-Use-get32-for-multi-source-route-calculati.patch 0014-pcm-Drop-snd_pcm_linear_-get-put-32_index.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ alsa.spec ++++++ --- /var/tmp/diff_new_pack.VB9ARf/_old 2014-07-26 12:19:47.000000000 +0200 +++ /var/tmp/diff_new_pack.VB9ARf/_new 2014-07-26 12:19:47.000000000 +0200 @@ -49,9 +49,22 @@ Source34: alsa-init.sh Source40: 50-alsa.conf Source41: install-snd-module -Source50: Loopback.conf # Patch: alsa-lib-git-fixes.diff # upstream fixes +Patch1: 0001-ucm-Document-PlaybackPCMIsDummy-and-CapturePCMIsDumm.patch +Patch2: 0002-ICE1712-add-surround71-pcm-definition.patch +Patch3: 0003-USB-Audio-Add-second-S-PDIF-device-on-Phiree-U2.patch +Patch4: 0004-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch +Patch5: 0005-pcm-Provide-a-CLOCK_MONOTONIC_RAW-timestamp-type.patch +Patch6: 0006-Add-timestamp-type-to-sw_params-internal-only.patch +Patch7: 0007-pcm-Add-sw_params-API-functions-to-get-set-timestamp.patch +Patch8: 0008-pcm-Implement-timestamp-type-setup-in-hw-plugin.patch +Patch9: 0009-pcm-Implement-timestamp-type-handling-in-all-plugins.patch +Patch10: 0010-test-audio_time-Set-timestamp-type-explicitly.patch +Patch11: 0011-pcm-route-Use-get-put-labels-for-all-3-byte-formats.patch +Patch12: 0012-pcm-Fill-sw_params-proto-field.patch +Patch13: 0013-pcm-route-Use-get32-for-multi-source-route-calculati.patch +Patch14: 0014-pcm-Drop-snd_pcm_linear_-get-put-32_index.patch # rest suse patches Patch99: alsa-lib-doxygen-avoid-crash-for-11.3.diff BuildRequires: doxygen @@ -119,8 +132,21 @@ %prep %setup -q -n alsa-lib-%{package_version} -cp %{SOURCE50} src/conf/cards # %patch -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 %if 0%{?suse_version} == 1130 %patch99 -p1 %endif ++++++ 0001-ucm-Document-PlaybackPCMIsDummy-and-CapturePCMIsDumm.patch ++++++ >From 7a748af4db17cb0b26d19e5f9939d277128ec94b Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen <[email protected]> Date: Thu, 26 Jun 2014 13:30:25 +0300 Subject: [PATCH 01/14] ucm: Document PlaybackPCMIsDummy and CapturePCMIsDummy values At least PulseAudio needs special handling for dummy devices. To allow that to happen automatically, the UCM configuration should contain the information about which PCMs are dummy. Signed-off-by: Tanu Kaskinen <[email protected]> Acked-by: Liam Girdwood <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- include/use-case.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/use-case.h b/include/use-case.h index 4e13249133e6..f30168f86471 100644 --- a/include/use-case.h +++ b/include/use-case.h @@ -258,7 +258,17 @@ int snd_use_case_get_list(snd_use_case_mgr_t *uc_mgr, * Recommended names for values: * TQ - Tone Quality * PlaybackPCM - full PCM playback device name + * PlaybackPCMIsDummy - Valid values: "yes" and "no". If set to "yes", the + * PCM named by the PlaybackPCM value is a dummy device, + * meaning that opening it enables an audio path in the + * hardware, but writing to the PCM device has no + * effect. * CapturePCM - full PCM capture device name + * CapturePCMIsDummy - Valid values: "yes" and "no". If set to "yes", the + * PCM named by the CapturePCM value is a dummy device, + * meaning that opening it enables an audio path in the + * hardware, but reading from the PCM device has no + * effect. * PlaybackRate - playback device sample rate * PlaybackChannels - playback device channel count * PlaybackCTL - playback control device name -- 2.0.1 ++++++ 0002-ICE1712-add-surround71-pcm-definition.patch ++++++ >From 27cc710b5784cb3ab68cff2a9d9daf9fa479149e Mon Sep 17 00:00:00 2001 From: "Alexander E. Patrakov" <[email protected]> Date: Tue, 1 Jul 2014 00:40:48 +0600 Subject: [PATCH 02/14] ICE1712: add surround71 pcm definition The M-Audio Delta 1010 card has 7.1 analog output, but no ready-made pcm definition to use it. Signed-off-by: Alexander E. Patrakov <[email protected]> Reported-and-tested-by: Matt Zagrabelny <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- src/conf/cards/ICE1712.conf | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/conf/cards/ICE1712.conf b/src/conf/cards/ICE1712.conf index 398fa7ad5307..db62684e25f2 100644 --- a/src/conf/cards/ICE1712.conf +++ b/src/conf/cards/ICE1712.conf @@ -78,6 +78,7 @@ ICE1712.pcm.surround40.0 { <confdir:pcm/surround41.conf> <confdir:pcm/surround50.conf> <confdir:pcm/surround51.conf> +<confdir:pcm/surround71.conf> ICE1712.pcm.surround51.0 { @args [ CARD ] @@ -98,6 +99,27 @@ ICE1712.pcm.surround51.0 { slave.channels 10 } +ICE1712.pcm.surround71.0 { + @args [ CARD ] + @args.CARD { + type string + } + type route + ttable.0.0 1 + ttable.1.1 1 + ttable.2.2 1 + ttable.3.3 1 + ttable.4.4 1 + ttable.5.5 1 + ttable.6.6 1 + ttable.7.7 1 + slave.pcm { + type hw + card $CARD + } + slave.channels 10 +} + <confdir:pcm/iec958.conf> ICE1712.pcm.iec958.0 { -- 2.0.1 ++++++ 0003-USB-Audio-Add-second-S-PDIF-device-on-Phiree-U2.patch ++++++ >From ea865bba4615d906144ae5d4f72a4aad2baffe1f Mon Sep 17 00:00:00 2001 From: Anssi Hannula <[email protected]> Date: Tue, 8 Jul 2014 11:19:20 +0300 Subject: [PATCH 03/14] USB-Audio: Add second S/PDIF device on Phiree U2 Phiree U2 has an unusual configuration. It only has S/PDIF output, but there are still two devices presented: - device 0: PCM audio, subject to volume control - device 1: non-PCM data (passthrough), not subject to volume control It looks like the AES bits are set according to the selected device, since outputting PCM data via device 1 will not work (silence). Currently only the device 0 is shown via the "iec958" alias, and the second device is not accessible via hinted aliases. Simply provide access to both of these devices via the "iec958" alias. Reported-by: touc @ XBMC forum Signed-off-by: Anssi Hannula <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- src/conf/cards/USB-Audio.conf | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/conf/cards/USB-Audio.conf b/src/conf/cards/USB-Audio.conf index ce3ae019f7f6..77a48b9f5562 100644 --- a/src/conf/cards/USB-Audio.conf +++ b/src/conf/cards/USB-Audio.conf @@ -52,6 +52,11 @@ USB-Audio.pcm.iec958_device { "USB Device 0x46d:0x992" 999 } +# Second iec958 device number, if any. +USB-Audio.pcm.iec958_2_device { + "PHIREE U2" 1 # 0 = PCM S/PDIF, 1 = non-PCM S/PDIF +} + # If a device requires non-standard definitions for front, surround40, # surround51, surround71 or iec958, they can be defined here. @@ -422,4 +427,39 @@ USB-Audio.pcm.iec958.0 { } } +USB-Audio.pcm.iec958.1 { + @args [ CARD AES0 AES1 AES2 AES3 ] + @args.CARD { type string } + @args.AES0 { type integer } + @args.AES1 { type integer } + @args.AES2 { type integer } + @args.AES3 { type integer } + @func refer + name { + @func concat + strings [ + "cards.USB-Audio." + { @func card_name card $CARD } + ".pcm.iec958_2:CARD=" $CARD + ",AES0=" $AES0 ",AES1=" $AES1 ",AES2=" $AES2 ",AES3=" $AES3 + ] + } + default { + # FIXME: we cannot set the AES parameters + type hw + card $CARD + device { + @func refer + name { + @func concat + strings [ + "cards.USB-Audio.pcm.iec958_2_device." + { @func card_name card $CARD } + ] + } + default 999 + } + } +} + # vim: ft=alsaconf -- 2.0.1 ++++++ 0004-pcm-rate-fix-hw_ptr-exceed-the-boundary.patch ++++++ >From 035f196bcdc1e9903ed52ad1859dc23d3aa74e72 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang <[email protected]> Date: Mon, 14 Jul 2014 16:55:48 +0800 Subject: [PATCH 04/14] pcm: rate: fix hw_ptr exceed the boundary For long time test case, the hw_ptr will exceed the boundary, then cause the avail size wrong. Signed-off-by: Shengjiu Wang <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- src/pcm/pcm_rate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index 7f667d4c6a52..2563d824ddb8 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -574,6 +574,8 @@ static inline void snd_pcm_rate_sync_hwptr(snd_pcm_t *pcm) rate->hw_ptr = (slave_hw_ptr / rate->gen.slave->period_size) * pcm->period_size + rate->ops.input_frames(rate->obj, slave_hw_ptr % rate->gen.slave->period_size); + + rate->hw_ptr %= pcm->boundary; } static int snd_pcm_rate_hwsync(snd_pcm_t *pcm) -- 2.0.1 ++++++ 0005-pcm-Provide-a-CLOCK_MONOTONIC_RAW-timestamp-type.patch ++++++ >From 85e4704151677b8fcc5ccfc396071828e9ec1b8e Mon Sep 17 00:00:00 2001 From: Mark Brown <[email protected]> Date: Tue, 8 Jul 2014 16:52:32 +0200 Subject: [PATCH 05/14] pcm: Provide a CLOCK_MONOTONIC_RAW timestamp type For applications which need to synchronise with external timebases such as broadcast TV applications the kernel monotonic time is not optimal as it includes adjustments from NTP and so may still include discontinuities due to that. A raw monotonic time which does not include any adjustments is available in the kernel from getrawmonotonic() so provide userspace with a new timestamp type SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW which provides timestamps based on this as an option. Reported-by: Daniel Thompson <[email protected]> Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> --- include/sound/asound.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/sound/asound.h b/include/sound/asound.h index 1774a5c3ef10..9061cdd5b69f 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -457,7 +457,8 @@ struct snd_xfern { enum { SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, /* gettimeofday equivalent */ SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, /* posix_clock_monotonic equivalent */ - SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, + SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW, /* monotonic_raw (no NTP) */ + SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW, }; /* channel positions */ -- 2.0.1 ++++++ 0006-Add-timestamp-type-to-sw_params-internal-only.patch ++++++ >From 5250a8e212fd927735cfc27612b060c31dc3a230 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <[email protected]> Date: Thu, 10 Jul 2014 14:22:33 +0200 Subject: [PATCH 06/14] Add timestamp type to sw_params (internal only) This patch is just the udpate of sound/asound.h taken from the kernel commit. The API changes and PCM structure changes will follow after this. Signed-off-by: Takashi Iwai <[email protected]> --- include/sound/asound.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/sound/asound.h b/include/sound/asound.h index 9061cdd5b69f..552f41bd1ca9 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -136,7 +136,7 @@ struct snd_hwdep_dsp_image { * * *****************************************************************************/ -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 11) +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 12) typedef unsigned long snd_pcm_uframes_t; typedef signed long snd_pcm_sframes_t; @@ -386,7 +386,9 @@ struct snd_pcm_sw_params { snd_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */ snd_pcm_uframes_t silence_size; /* silence block size */ snd_pcm_uframes_t boundary; /* pointers wrap point */ - unsigned char reserved[64]; /* reserved for future */ + unsigned int tstamp_type; /* timestamp type */ + int pads; /* alignment, reserved */ + unsigned char reserved[56]; /* reserved for future */ }; struct snd_pcm_channel_info { -- 2.0.1 ++++++ 0007-pcm-Add-sw_params-API-functions-to-get-set-timestamp.patch ++++++ >From 0d393c29a272b6fc97e9fca3252fb1c58f86e75b Mon Sep 17 00:00:00 2001 From: Takashi Iwai <[email protected]> Date: Thu, 10 Jul 2014 14:26:37 +0200 Subject: [PATCH 07/14] pcm: Add sw_params API functions to get/set timestamp type For obtaining / changing the timestamp type, add the corresponding sw_params accessor API functions together with the public definitions of timestamp types. This patch only adds the functions and defines but doesn't bring the functional changes yet. Signed-off-by: Takashi Iwai <[email protected]> --- include/pcm.h | 9 +++++++++ src/pcm/pcm.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/pcm/pcm_local.h | 1 + src/pcm/pcm_params.c | 1 + 4 files changed, 64 insertions(+) diff --git a/include/pcm.h b/include/pcm.h index 95b8aed6de2a..11e9f0dfba13 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -317,6 +317,13 @@ typedef enum _snd_pcm_tstamp { SND_PCM_TSTAMP_LAST = SND_PCM_TSTAMP_ENABLE } snd_pcm_tstamp_t; +typedef enum _snd_pcm_tstamp_type { + SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, /** gettimeofday equivalent */ + SND_PCM_TSTAMP_TYPE_MONOTONIC, /** posix_clock_monotonic equivalent */ + SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW, /** monotonic_raw (no NTP) */ + SND_PCM_TSTAMP_TYPE_LAST = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW, +} snd_pcm_tstamp_type_t; + /** Unsigned frames quantity */ typedef unsigned long snd_pcm_uframes_t; /** Signed frames quantity */ @@ -844,6 +851,8 @@ int snd_pcm_sw_params_get_boundary(const snd_pcm_sw_params_t *params, snd_pcm_uf int snd_pcm_sw_params_set_tstamp_mode(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_t val); int snd_pcm_sw_params_get_tstamp_mode(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_t *val); +int snd_pcm_sw_params_set_tstamp_type(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t val); +int snd_pcm_sw_params_get_tstamp_type(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t *val); int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); int snd_pcm_sw_params_get_avail_min(const snd_pcm_sw_params_t *params, snd_pcm_uframes_t *val); int snd_pcm_sw_params_set_period_event(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, int val); diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 7e46014627c2..89844430bf35 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -1483,6 +1483,7 @@ int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsign #define XRUN(v) [SND_PCM_XRUN_##v] = #v #define SILENCE(v) [SND_PCM_SILENCE_##v] = #v #define TSTAMP(v) [SND_PCM_TSTAMP_##v] = #v +#define TSTAMP_TYPE(v) [SND_PCM_TSTAMP_TYPE_##v] = #v #define ACCESS(v) [SND_PCM_ACCESS_##v] = #v #define START(v) [SND_PCM_START_##v] = #v #define HW_PARAM(v) [SND_PCM_HW_PARAM_##v] = #v @@ -1680,6 +1681,12 @@ static const char *const snd_pcm_tstamp_mode_names[] = { TSTAMP(NONE), TSTAMP(ENABLE), }; + +static const char *const snd_pcm_tstamp_type_names[] = { + TSTAMP_TYPE(GETTIMEOFDAY), + TSTAMP_TYPE(MONOTONIC), + TSTAMP_TYPE(MONOTONIC_RAW), +}; #endif /** @@ -1826,6 +1833,18 @@ const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode) } /** + * \brief get name of PCM tstamp type setting + * \param mode PCM tstamp type + * \return ascii name of PCM tstamp type setting + */ +const char *snd_pcm_tstamp_type_name(snd_pcm_tstamp_t type) +{ + if (type > SND_PCM_TSTAMP_TYPE_LAST) + return NULL; + return snd_pcm_tstamp_type_names[type]; +} + +/** * \brief get name of PCM state * \param state PCM state * \return ascii name of PCM state @@ -1899,6 +1918,7 @@ int snd_pcm_dump_sw_setup(snd_pcm_t *pcm, snd_output_t *out) return -EIO; } snd_output_printf(out, " tstamp_mode : %s\n", snd_pcm_tstamp_mode_name(pcm->tstamp_mode)); + snd_output_printf(out, " tstamp_type : %s\n", snd_pcm_tstamp_type_name(pcm->tstamp_mode)); snd_output_printf(out, " period_step : %d\n", pcm->period_step); snd_output_printf(out, " avail_min : %ld\n", pcm->avail_min); snd_output_printf(out, " period_event : %i\n", pcm->period_event); @@ -5591,6 +5611,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) return -EIO; } params->tstamp_mode = pcm->tstamp_mode; + params->tstamp_type = pcm->tstamp_type; params->period_step = pcm->period_step; params->sleep_min = 0; params->avail_min = pcm->avail_min; @@ -5613,6 +5634,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) int snd_pcm_sw_params_dump(snd_pcm_sw_params_t *params, snd_output_t *out) { snd_output_printf(out, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(params->tstamp_mode)); + snd_output_printf(out, "tstamp_type: %s\n", snd_pcm_tstamp_type_name(params->tstamp_type)); snd_output_printf(out, "period_step: %u\n", params->period_step); snd_output_printf(out, "avail_min: %lu\n", params->avail_min); snd_output_printf(out, "start_threshold: %ld\n", params->start_threshold); @@ -5811,6 +5833,37 @@ int snd_pcm_sw_params_get_tstamp_mode(const snd_pcm_sw_params_t *params, snd_pcm } /** + * \brief Set timestamp type inside a software configuration container + * \param pcm PCM handle + * \param params Software configuration container + * \param val Timestamp type + * \return 0 otherwise a negative error code + */ +int snd_pcm_sw_params_set_tstamp_type(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t val) +{ + assert(pcm && params); + if (CHECK_SANITY(val > SND_PCM_TSTAMP_TYPE_LAST)) { + SNDMSG("invalid tstamp_type value %d", val); + return -EINVAL; + } + params->tstamp_type = val; + return 0; +} + +/** + * \brief Get timestamp type from a software configuration container + * \param params Software configuration container + * \param val Returned timestamp type + * \return 0 otherwise a negative error code + */ +int snd_pcm_sw_params_get_tstamp_type(const snd_pcm_sw_params_t *params, snd_pcm_tstamp_type_t *val) +{ + assert(params && val); + *val = params->tstamp_type; + return 0; +} + +/** * \brief (DEPRECATED) Set minimum number of ticks to sleep inside a software configuration container * \param pcm PCM handle * \param params Software configuration container diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 8a6c7431cc40..3ed7e1a88792 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -202,6 +202,7 @@ struct _snd_pcm { unsigned int period_time; /* period duration */ snd_interval_t periods; snd_pcm_tstamp_t tstamp_mode; /* timestamp mode */ + snd_pcm_tstamp_type_t tstamp_type; /* timestamp type */ unsigned int period_step; snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */ int period_event; diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 0b66e8cbbe64..4adbefae0530 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -2258,6 +2258,7 @@ static int snd_pcm_sw_params_default(snd_pcm_t *pcm, snd_pcm_sw_params_t *params assert(pcm && params); assert(pcm->setup); params->tstamp_mode = SND_PCM_TSTAMP_NONE; + params->tstamp_type = pcm->tstamp_type; params->period_step = 1; params->sleep_min = 0; params->avail_min = pcm->period_size; -- 2.0.1 ++++++ 0008-pcm-Implement-timestamp-type-setup-in-hw-plugin.patch ++++++ >From 9b716075de4f2f7f15e428ee7efaa8960ef45b9c Mon Sep 17 00:00:00 2001 From: Takashi Iwai <[email protected]> Date: Thu, 10 Jul 2014 14:32:50 +0200 Subject: [PATCH 08/14] pcm: Implement timestamp type setup in hw plugin This patch implements the support for sw_params timestamp type in PCM hw layer. As gettimestamp() is still unchanged, the resultant timstamps may be still with CLOCK_MONOTONIC even if you pass monotonic raw type. More fixes will follow. Signed-off-by: Takashi Iwai <[email protected]> --- src/pcm/pcm_hw.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index ed8319728130..bafa8debeb0b 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -304,7 +304,8 @@ static int snd_pcm_hw_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) if (params->info != ~0U) { params->info &= ~0xf0000000; - params->info |= (pcm->monotonic ? SND_PCM_INFO_MONOTONIC : 0); + if (pcm->tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY) + params->info |= SND_PCM_INFO_MONOTONIC; } return 0; @@ -328,7 +329,8 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) return err; } params->info &= ~0xf0000000; - params->info |= (pcm->monotonic ? SND_PCM_INFO_MONOTONIC : 0); + if (pcm->tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY) + params->info |= SND_PCM_INFO_MONOTONIC; err = sync_ptr(hw, 0); if (err < 0) return err; @@ -435,6 +437,7 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params) int old_period_event = sw_get_period_event(params); sw_set_period_event(params, 0); if ((snd_pcm_tstamp_t) params->tstamp_mode == pcm->tstamp_mode && + (snd_pcm_tstamp_type_t) params->tstamp_type == pcm->tstamp_type && params->period_step == pcm->period_step && params->start_threshold == pcm->start_threshold && params->stop_threshold == pcm->stop_threshold && @@ -444,11 +447,33 @@ static int snd_pcm_hw_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params) hw->mmap_control->avail_min = params->avail_min; return sync_ptr(hw, 0); } + if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW && + hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 12)) { + SYSMSG("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW"); + return -EINVAL; + } + if (params->tstamp_type == SND_PCM_TSTAMP_TYPE_MONOTONIC && + hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 5)) { + SYSMSG("Kernel doesn't support SND_PCM_TSTAMP_TYPE_MONOTONIC"); + return -EINVAL; + } if (ioctl(fd, SNDRV_PCM_IOCTL_SW_PARAMS, params) < 0) { err = -errno; SYSMSG("SNDRV_PCM_IOCTL_SW_PARAMS failed (%i)", err); return err; } + if ((snd_pcm_tstamp_type_t) params->tstamp_type != pcm->tstamp_type) { + if (hw->version < SNDRV_PROTOCOL_VERSION(2, 0, 12)) { + int on = (snd_pcm_tstamp_type_t) params->tstamp_type == + SND_PCM_TSTAMP_TYPE_MONOTONIC; + if (ioctl(fd, SNDRV_PCM_IOCTL_TSTAMP, &on) < 0) { + err = -errno; + SNDMSG("TSTAMP failed\n"); + return err; + } + } + pcm->tstamp_type = params->tstamp_type; + } sw_set_period_event(params, old_period_event); hw->mmap_control->avail_min = params->avail_min; if (hw->period_event != old_period_event) { @@ -1381,7 +1406,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, int fd, int mmap_emulation ATTRIBUTE_UNUSED, int sync_ptr_ioctl) { - int ver, mode, monotonic = 0; + int ver, mode; + snd_pcm_tstamp_type_t tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY; long fmode; snd_pcm_t *pcm = NULL; snd_pcm_hw_t *hw = NULL; @@ -1429,7 +1455,7 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, SNDMSG("TTSTAMP failed\n"); return ret; } - monotonic = 1; + tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC; } } else #endif @@ -1471,7 +1497,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name, pcm->private_data = hw; pcm->poll_fd = fd; pcm->poll_events = info.stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN; - pcm->monotonic = monotonic; + pcm->tstamp_type = tstamp_type; + pcm->monotonic = tstamp_type != SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY; ret = snd_pcm_hw_mmap_status(pcm); if (ret < 0) { -- 2.0.1 ++++++ 0009-pcm-Implement-timestamp-type-handling-in-all-plugins.patch ++++++ ++++ 602 lines (skipped) ++++++ 0010-test-audio_time-Set-timestamp-type-explicitly.patch ++++++ >From 52444bd43afbadb8637f5fac3fe5fd90575ee216 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <[email protected]> Date: Mon, 14 Jul 2014 18:12:49 +0200 Subject: [PATCH 10/14] test/audio_time: Set timestamp type explicitly Signed-off-by: Takashi Iwai <[email protected]> --- test/audio_time.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/audio_time.c b/test/audio_time.c index 03817c7c673b..7435db6a7fd8 100644 --- a/test/audio_time.c +++ b/test/audio_time.c @@ -57,6 +57,7 @@ void gettimestamp(snd_pcm_t *handle, snd_htimestamp_t *timestamp, #define TRACK_PLAYBACK /* dump playback timing info */ #define TRACK_SAMPLE_COUNTS /* show difference between sample counters and audiotimestamps returned by driver */ #define PLAYBACK_BUFFERS 4 +#define TSTAMP_TYPE SND_PCM_TSTAMP_TYPE_MONOTONIC int main(void) @@ -128,6 +129,12 @@ int main(void) goto _exit; } + err = snd_pcm_sw_params_set_tstamp_type(handle_p, swparams_p, TSTAMP_TYPE); + if (err < 0) { + printf("Unable to set tstamp type : %s\n", snd_strerror(err)); + goto _exit; + } + /* write the sw parameters */ err = snd_pcm_sw_params(handle_p, swparams_p); if (err < 0) { @@ -177,6 +184,12 @@ int main(void) goto _exit; } + err = snd_pcm_sw_params_set_tstamp_type(handle_c, swparams_c, TSTAMP_TYPE); + if (err < 0) { + printf("Unable to set tstamp type : %s\n", snd_strerror(err)); + goto _exit; + } + /* write the sw parameters */ err = snd_pcm_sw_params(handle_c, swparams_c); if (err < 0) { -- 2.0.1 ++++++ 0011-pcm-route-Use-get-put-labels-for-all-3-byte-formats.patch ++++++ >From de63b942acf520a25ff469cf338a99eb3da65570 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <[email protected]> Date: Mon, 21 Jul 2014 16:30:54 +0200 Subject: [PATCH 11/14] pcm: route: Use get/put labels for all 3 byte formats So far, use_getput flag is set only when the src or dest format is 24bit physical width. But, also 18 and 20 bit physical width formats should set the flag, too. This patch makes the check broader to cover all 3 bytes formats. Signed-off-by: Takashi Iwai <[email protected]> --- src/pcm/pcm_route.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 2f0be38b1906..72c198cb25d2 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -644,8 +644,10 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) } if (err < 0) return err; - route->params.use_getput = snd_pcm_format_physical_width(src_format) == 24 || - snd_pcm_format_physical_width(dst_format) == 24; + /* 3 bytes formats? */ + route->params.use_getput = + (snd_pcm_format_physical_width(src_format) + 7) / 3 == 3 || + (snd_pcm_format_physical_width(dst_format) + 7) / 3 == 3; route->params.get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S16); route->params.put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, dst_format); route->params.conv_idx = snd_pcm_linear_convert_index(src_format, dst_format); -- 2.0.1 ++++++ 0012-pcm-Fill-sw_params-proto-field.patch ++++++ >From 55c53625212702debf55c719ec62f6c81c780927 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <[email protected]> Date: Wed, 16 Jul 2014 17:48:34 +0200 Subject: [PATCH 12/14] pcm: Fill sw_params proto field Fill the new proto field introduced to sw_params with the current PCM protocol version. This makes tstamp_type evaluated properly in the kernel. Signed-off-by: Takashi Iwai <[email protected]> --- include/sound/asound.h | 4 ++-- src/pcm/pcm.c | 1 + src/pcm/pcm_params.c | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/sound/asound.h b/include/sound/asound.h index 552f41bd1ca9..c819df421434 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -386,8 +386,8 @@ struct snd_pcm_sw_params { snd_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */ snd_pcm_uframes_t silence_size; /* silence block size */ snd_pcm_uframes_t boundary; /* pointers wrap point */ - unsigned int tstamp_type; /* timestamp type */ - int pads; /* alignment, reserved */ + unsigned int proto; /* protocol version */ + unsigned int tstamp_type; /* timestamp type (req. proto >= 2.0.12) */ unsigned char reserved[56]; /* reserved for future */ }; diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 89844430bf35..1399a5b2e671 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -5610,6 +5610,7 @@ int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params) SNDMSG("PCM not set up"); return -EIO; } + params->proto = SNDRV_PCM_VERSION; params->tstamp_mode = pcm->tstamp_mode; params->tstamp_type = pcm->tstamp_type; params->period_step = pcm->period_step; diff --git a/src/pcm/pcm_params.c b/src/pcm/pcm_params.c index 4adbefae0530..6e57904e445b 100644 --- a/src/pcm/pcm_params.c +++ b/src/pcm/pcm_params.c @@ -2257,6 +2257,7 @@ static int snd_pcm_sw_params_default(snd_pcm_t *pcm, snd_pcm_sw_params_t *params { assert(pcm && params); assert(pcm->setup); + params->proto = SNDRV_PCM_VERSION; params->tstamp_mode = SND_PCM_TSTAMP_NONE; params->tstamp_type = pcm->tstamp_type; params->period_step = 1; -- 2.0.1 ++++++ 0013-pcm-route-Use-get32-for-multi-source-route-calculati.patch ++++++ >From fd84adc63e307572d05274be44c782a787087cda Mon Sep 17 00:00:00 2001 From: Takashi Iwai <[email protected]> Date: Tue, 22 Jul 2014 11:55:40 +0200 Subject: [PATCH 13/14] pcm: route: Use get32 for multi-source route calculation The PCM route plugin can assign the destination value from average of multiple sources with attenuation. This requires the read of each channel value, sums and writes the resultant value in the requested format. Currently, get_labels is used for reading source values while put32_labels is used for writing the dest value. This is, however, a buggy implementation; get_labels gives the value as is only with endianness and signedness conversions, but put32_labels assumes that the value is normalized to 32bit int and it shifts down to the dest format. In addition, the current code lacks get_labels entries for the 24bit formats, as Shengjiu Wang spotted out. For fixing these bugs, this patch replaces the read with get32_labels and use always 64bit int for sum. This simplifies the code a lot and drops many lines. Signed-off-by: Takashi Iwai <[email protected]> --- src/pcm/pcm_route.c | 128 +++++++++------------------------------------------ src/pcm/plugin_ops.h | 81 -------------------------------- 2 files changed, 23 insertions(+), 186 deletions(-) diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 72c198cb25d2..5dac7ebcb7df 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -60,7 +60,7 @@ typedef struct { typedef struct snd_pcm_route_ttable_dst snd_pcm_route_ttable_dst_t; typedef struct { - enum {UINT32=0, UINT64=1, FLOAT=2} sum_idx; + enum {UINT64, FLOAT} sum_idx; unsigned int get_idx; unsigned int put_idx; unsigned int conv_idx; @@ -233,55 +233,34 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, const snd_pcm_route_ttable_dst_t* ttable, const snd_pcm_route_params_t *params) { -#define GETS_LABELS +#define GET32_LABELS #define PUT32_LABELS #include "plugin_ops.h" -#undef GETS_LABELS +#undef GET32_LABELS #undef PUT32_LABELS - static void *const zero_labels[3] = { - &&zero_int32, &&zero_int64, + static void *const zero_labels[2] = { + &&zero_int64, #if SND_PCM_PLUGIN_ROUTE_FLOAT &&zero_float #endif }; /* sum_type att */ - static void *const add_labels[3 * 2] = { - &&add_int32_noatt, &&add_int32_att, + static void *const add_labels[2 * 2] = { &&add_int64_noatt, &&add_int64_att, #if SND_PCM_PLUGIN_ROUTE_FLOAT &&add_float_noatt, &&add_float_att #endif }; - /* sum_type att shift */ - static void *const norm_labels[3 * 2 * 4] = { - 0, - &&norm_int32_8_noatt, - &&norm_int32_16_noatt, - &&norm_int32_24_noatt, - 0, - &&norm_int32_8_att, - &&norm_int32_16_att, - &&norm_int32_24_att, - &&norm_int64_0_noatt, - &&norm_int64_8_noatt, - &&norm_int64_16_noatt, - &&norm_int64_24_noatt, - &&norm_int64_0_att, - &&norm_int64_8_att, - &&norm_int64_16_att, - &&norm_int64_24_att, + /* sum_type att */ + static void *const norm_labels[2 * 2] = { + &&norm_int64_noatt, + &&norm_int64_att, #if SND_PCM_PLUGIN_ROUTE_FLOAT - &&norm_float_0, - &&norm_float_8, - &&norm_float_16, - &&norm_float_24, - &&norm_float_0, - &&norm_float_8, - &&norm_float_16, - &&norm_float_24, + &&norm_float, + &&norm_float, #endif }; - void *zero, *get, *add, *norm, *put32; + void *zero, *get32, *add, *norm, *put32; int nsrcs = ttable->nsrcs; char *dst; int dst_step; @@ -323,9 +302,9 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, } zero = zero_labels[params->sum_idx]; - get = gets_labels[params->get_idx]; + get32 = get32_labels[params->get_idx]; add = add_labels[params->sum_idx * 2 + ttable->att]; - norm = norm_labels[params->sum_idx * 8 + ttable->att * 4 + 4 - params->src_size]; + norm = norm_labels[params->sum_idx * 2 + ttable->att]; put32 = put32_labels[params->put_idx]; dst = snd_pcm_channel_area_addr(dst_area, dst_offset); dst_step = snd_pcm_channel_area_step(dst_area); @@ -336,9 +315,6 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, /* Zero sum */ goto *zero; - zero_int32: - sum.as_sint32 = 0; - goto zero_end; zero_int64: sum.as_sint64 = 0; goto zero_end; @@ -352,21 +328,14 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, const char *src = srcs[srcidx]; /* Get sample */ - goto *get; -#define GETS_END after_get + goto *get32; +#define GET32_END after_get #include "plugin_ops.h" -#undef GETS_END +#undef GET32_END after_get: /* Sum */ goto *add; - add_int32_att: - sum.as_sint32 += sample * ttp->as_int; - goto after_sum; - add_int32_noatt: - if (ttp->as_int) - sum.as_sint32 += sample; - goto after_sum; add_int64_att: sum.as_sint64 += (int64_t) sample * ttp->as_int; goto after_sum; @@ -390,48 +359,10 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, /* Normalization */ goto *norm; - norm_int32_8_att: - sum.as_sint64 = sum.as_sint32; - norm_int64_8_att: - sum.as_sint64 <<= 8; - norm_int64_0_att: + norm_int64_att: div(sum.as_sint64); - goto norm_int; - - norm_int32_16_att: - sum.as_sint64 = sum.as_sint32; - norm_int64_16_att: - sum.as_sint64 <<= 16; - div(sum.as_sint64); - goto norm_int; - - norm_int32_24_att: - sum.as_sint64 = sum.as_sint32; - norm_int64_24_att: - sum.as_sint64 <<= 24; - div(sum.as_sint64); - goto norm_int; - - norm_int32_8_noatt: - sum.as_sint64 = sum.as_sint32; - norm_int64_8_noatt: - sum.as_sint64 <<= 8; - goto norm_int; - - norm_int32_16_noatt: - sum.as_sint64 = sum.as_sint32; - norm_int64_16_noatt: - sum.as_sint64 <<= 16; - goto norm_int; - - norm_int32_24_noatt: - sum.as_sint64 = sum.as_sint32; - norm_int64_24_noatt: - sum.as_sint64 <<= 24; - goto norm_int; - - norm_int64_0_noatt: - norm_int: + /* fallthru */ + norm_int64_noatt: if (sum.as_sint64 > (int64_t)0x7fffffff) sample = 0x7fffffff; /* maximum positive value */ else if (sum.as_sint64 < -(int64_t)0x80000000) @@ -441,16 +372,6 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, goto after_norm; #if SND_PCM_PLUGIN_ROUTE_FLOAT - norm_float_8: - sum.as_float *= 1 << 8; - goto norm_float; - norm_float_16: - sum.as_float *= 1 << 16; - goto norm_float; - norm_float_24: - sum.as_float *= 1 << 24; - goto norm_float; - norm_float_0: norm_float: sum.as_float = rint(sum.as_float); if (sum.as_float > (int64_t)0x7fffffff) @@ -648,7 +569,7 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) route->params.use_getput = (snd_pcm_format_physical_width(src_format) + 7) / 3 == 3 || (snd_pcm_format_physical_width(dst_format) + 7) / 3 == 3; - route->params.get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S16); + route->params.get_idx = snd_pcm_linear_get32_index(src_format, SND_PCM_FORMAT_S32); route->params.put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, dst_format); route->params.conv_idx = snd_pcm_linear_convert_index(src_format, dst_format); route->params.src_size = snd_pcm_format_width(src_format) / 8; @@ -656,10 +577,7 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) #if SND_PCM_PLUGIN_ROUTE_FLOAT route->params.sum_idx = FLOAT; #else - if (snd_pcm_format_width(src_format) == 32) - route->params.sum_idx = UINT64; - else - route->params.sum_idx = UINT32; + route->params.sum_idx = UINT64; #endif return 0; } diff --git a/src/pcm/plugin_ops.h b/src/pcm/plugin_ops.h index 21535c9ca8d6..eb8c2c4f4dac 100644 --- a/src/pcm/plugin_ops.h +++ b/src/pcm/plugin_ops.h @@ -668,87 +668,6 @@ getu_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GETU_END; } #endif -#ifdef GETS_LABELS -/* width endswap sign_toggle */ -static void *const gets_labels[4 * 2 * 2] = { - &&gets_1_1, /* 8h -> 8h */ - &&gets_1_9, /* 8h ^> 8h */ - &&gets_1_1, /* 8s -> 8h */ - &&gets_1_9, /* 8s ^> 8h */ - &&gets_12_12, /* 16h -> 16h */ - &&gets_12_92, /* 16h ^> 16h */ - &&gets_12_21, /* 16s -> 16h */ - &&gets_12_A1, /* 16s ^> 16h */ - &&gets_0123_0123, /* 24h -> 24h */ - &&gets_0123_0923, /* 24h ^> 24h */ - &&gets_1230_0321, /* 24s -> 24h */ - &&gets_1230_0B21, /* 24s ^> 24h */ - &&gets_1234_1234, /* 32h -> 32h */ - &&gets_1234_9234, /* 32h ^> 32h */ - &&gets_1234_4321, /* 32s -> 32h */ - &&gets_1234_C321, /* 32s ^> 32h */ -}; -#endif - -#ifdef GETS_END -while (0) { -gets_1_1: sample = as_s8c(src); goto GETS_END; -gets_1_9: sample = (int8_t)(as_s8c(src) ^ 0x80); goto GETS_END; -gets_12_12: sample = as_s16c(src); goto GETS_END; -gets_12_92: sample = (int16_t)(as_s16c(src) ^ 0x8000); goto GETS_END; -gets_12_21: sample = (int16_t)bswap_16(as_s16c(src)); goto GETS_END; -gets_12_A1: sample = (int16_t)bswap_16(as_s16c(src) ^ 0x80); goto GETS_END; -gets_0123_0123: sample = sx24((int32_t)(as_s32c(src) << 8) >> 8); goto GETS_END; -gets_0123_0923: sample = sx24((int32_t)((as_s32c(src) ^ 0x800000) << 8) >> 8); goto GETS_END; -gets_1230_0321: sample = sx24((int32_t)(bswap_32(as_s32c(src)) << 8) >> 8); goto GETS_END; -gets_1230_0B21: sample = sx24((int32_t)(bswap_32(as_s32c(src) ^ 0x8000) << 8) >> 8); goto GETS_END; -gets_1234_1234: sample = as_s32c(src); goto GETS_END; -gets_1234_9234: sample = (int32_t)(as_s32c(src) ^ 0x80000000); goto GETS_END; -gets_1234_4321: sample = (int32_t)bswap_32(as_s32c(src)); goto GETS_END; -gets_1234_C321: sample = (int32_t)bswap_32(as_s32c(src) ^ 0x80); goto GETS_END; -} -#endif - -#ifdef PUT_LABELS -/* width endswap sign_toggle */ -static void *const put_labels[4 * 2 * 2] = { - &&put_1_1, /* 8h -> 8h */ - &&put_1_9, /* 8h ^> 8h */ - &&put_1_1, /* 8h -> 8s */ - &&put_1_9, /* 8h ^> 8s */ - &&put_12_12, /* 16h -> 16h */ - &&put_12_92, /* 16h ^> 16h */ - &&put_12_21, /* 16h -> 16s */ - &&put_12_29, /* 16h ^> 16s */ - &&put_0123_0123, /* 24h -> 24h */ - &&put_0123_0923, /* 24h ^> 24h */ - &&put_0123_3210, /* 24h -> 24s */ - &&put_0123_3290, /* 24h ^> 24s */ - &&put_1234_1234, /* 32h -> 32h */ - &&put_1234_9234, /* 32h ^> 32h */ - &&put_1234_4321, /* 32h -> 32s */ - &&put_1234_4329, /* 32h ^> 32s */ -}; -#endif - -#ifdef PUT_END -put_1_1: as_s8(dst) = sample; goto PUT_END; -put_1_9: as_u8(dst) = sample ^ 0x80; goto PUT_END; -put_12_12: as_s16(dst) = sample; goto PUT_END; -put_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT_END; -put_12_21: as_s16(dst) = bswap_16(sample); goto PUT_END; -put_12_29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT_END; -/* this always writes the unused byte in 24-bit formats as 0x00 */ -put_0123_0123: as_s32(dst) = sx24(sample & 0x00ffffff); goto PUT_END; -put_0123_0923: as_u32(dst) = sx24((sample & 0x00ffffff) ^ 0x800000); goto PUT_END; -put_0123_3210: as_s32(dst) = sx24s(bswap_32(sample) & 0xffffff00); goto PUT_END; -put_0123_3290: as_u32(dst) = sx24s((bswap_32(sample) & 0xffffff00) ^ 0x8000); goto PUT_END; -put_1234_1234: as_s32(dst) = sample; goto PUT_END; -put_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT_END; -put_1234_4321: as_s32(dst) = bswap_32(sample); goto PUT_END; -put_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT_END; -#endif - #ifdef PUT32F_LABELS /* type (0 = float, 1 = float64), endswap */ static void *const put32float_labels[2 * 2] = { -- 2.0.1 ++++++ 0014-pcm-Drop-snd_pcm_linear_-get-put-32_index.patch ++++++ >From 7a5646f58ba2e8154a274a5ae0f8ec963f331f97 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <[email protected]> Date: Tue, 22 Jul 2014 12:20:50 +0200 Subject: [PATCH 14/14] pcm: Drop snd_pcm_linear_{get|put}32_index() These are identical with snd_pcm_linear_{get|put}_index(). Signed-off-by: Takashi Iwai <[email protected]> --- src/pcm/pcm_lfloat.c | 4 ++-- src/pcm/pcm_linear.c | 44 ++++---------------------------------------- src/pcm/pcm_plugin.h | 4 ---- src/pcm/pcm_route.c | 4 ++-- 4 files changed, 8 insertions(+), 48 deletions(-) diff --git a/src/pcm/pcm_lfloat.c b/src/pcm/pcm_lfloat.c index 324282f0b7fc..2f3e578fc503 100644 --- a/src/pcm/pcm_lfloat.c +++ b/src/pcm/pcm_lfloat.c @@ -286,11 +286,11 @@ static int snd_pcm_lfloat_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) err = INTERNAL(snd_pcm_hw_params_get_format)(params, &dst_format); } if (snd_pcm_format_linear(src_format)) { - lfloat->int32_idx = snd_pcm_linear_get32_index(src_format, SND_PCM_FORMAT_S32); + lfloat->int32_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S32); lfloat->float32_idx = snd_pcm_lfloat_put_s32_index(dst_format); lfloat->func = snd_pcm_lfloat_convert_integer_float; } else { - lfloat->int32_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, dst_format); + lfloat->int32_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S32, dst_format); lfloat->float32_idx = snd_pcm_lfloat_get_s32_index(src_format); lfloat->func = snd_pcm_lfloat_convert_float_integer; } diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c index 3d5bbb8a3688..9a92abd04fb8 100644 --- a/src/pcm/pcm_linear.c +++ b/src/pcm/pcm_linear.c @@ -107,11 +107,6 @@ int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_f } } -int snd_pcm_linear_get32_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format) -{ - return snd_pcm_linear_get_index(src_format, dst_format); -} - int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format) { int sign, width, pwidth, endian; @@ -143,37 +138,6 @@ int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_f } } -int snd_pcm_linear_put32_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format) -{ - int sign, width, pwidth, endian; - sign = (snd_pcm_format_signed(src_format) != - snd_pcm_format_signed(dst_format)); -#ifdef SND_LITTLE_ENDIAN - endian = snd_pcm_format_big_endian(dst_format); -#else - endian = snd_pcm_format_little_endian(dst_format); -#endif - if (endian < 0) - endian = 0; - pwidth = snd_pcm_format_physical_width(dst_format); - width = snd_pcm_format_width(dst_format); - if (pwidth == 24) { - switch (width) { - case 24: - width = 0; break; - case 20: - width = 1; break; - case 18: - default: - width = 2; break; - } - return width * 4 + endian * 2 + sign + 16; - } else { - width = width / 8 - 1; - return width * 4 + endian * 2 + sign; - } -} - void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, unsigned int channels, snd_pcm_uframes_t frames, @@ -342,11 +306,11 @@ static int snd_pcm_linear_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) snd_pcm_format_physical_width(linear->sformat) == 24); if (linear->use_getput) { if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { - linear->get_idx = snd_pcm_linear_get32_index(format, SND_PCM_FORMAT_S32); - linear->put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, linear->sformat); + linear->get_idx = snd_pcm_linear_get_index(format, SND_PCM_FORMAT_S32); + linear->put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S32, linear->sformat); } else { - linear->get_idx = snd_pcm_linear_get32_index(linear->sformat, SND_PCM_FORMAT_S32); - linear->put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, format); + linear->get_idx = snd_pcm_linear_get_index(linear->sformat, SND_PCM_FORMAT_S32); + linear->put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S32, format); } } else { if (pcm->stream == SND_PCM_STREAM_PLAYBACK) diff --git a/src/pcm/pcm_plugin.h b/src/pcm/pcm_plugin.h index 19e82c3e7321..b0a3e1869ea1 100644 --- a/src/pcm/pcm_plugin.h +++ b/src/pcm/pcm_plugin.h @@ -86,8 +86,6 @@ snd_pcm_sframes_t snd_pcm_plugin_undo_write_generic /* make local functions really local */ #define snd_pcm_linear_get_index snd1_pcm_linear_get_index #define snd_pcm_linear_put_index snd1_pcm_linear_put_index -#define snd_pcm_linear_get32_index snd1_pcm_linear_get32_index -#define snd_pcm_linear_put32_index snd1_pcm_linear_put32_index #define snd_pcm_linear_convert_index snd1_pcm_linear_convert_index #define snd_pcm_linear_convert snd1_pcm_linear_convert #define snd_pcm_linear_getput snd1_pcm_linear_getput @@ -100,8 +98,6 @@ snd_pcm_sframes_t snd_pcm_plugin_undo_write_generic int snd_pcm_linear_get_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format); int snd_pcm_linear_put_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format); -int snd_pcm_linear_get32_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format); -int snd_pcm_linear_put32_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format); int snd_pcm_linear_convert_index(snd_pcm_format_t src_format, snd_pcm_format_t dst_format); void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index 5dac7ebcb7df..e7de9b51f1fc 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -569,8 +569,8 @@ static int snd_pcm_route_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params) route->params.use_getput = (snd_pcm_format_physical_width(src_format) + 7) / 3 == 3 || (snd_pcm_format_physical_width(dst_format) + 7) / 3 == 3; - route->params.get_idx = snd_pcm_linear_get32_index(src_format, SND_PCM_FORMAT_S32); - route->params.put_idx = snd_pcm_linear_put32_index(SND_PCM_FORMAT_S32, dst_format); + route->params.get_idx = snd_pcm_linear_get_index(src_format, SND_PCM_FORMAT_S32); + route->params.put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S32, dst_format); route->params.conv_idx = snd_pcm_linear_convert_index(src_format, dst_format); route->params.src_size = snd_pcm_format_width(src_format) / 8; route->params.dst_sfmt = dst_format; -- 2.0.1 -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
