Skip to content

Commit

Permalink
Merge branch 'for-next' into for-linus
Browse files Browse the repository at this point in the history
Merged 4.8 changes.
  • Loading branch information
Takashi Iwai committed Jul 25, 2016
2 parents 76df529 + 275353b commit cf81d6b
Show file tree
Hide file tree
Showing 34 changed files with 180 additions and 216 deletions.
12 changes: 6 additions & 6 deletions Documentation/sound/alsa/timestamping.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ provides a refined estimate with a delay.
event or application query.
The difference (tstamp - trigger_tstamp) defines the elapsed time.

The ALSA API provides reports two basic pieces of information, avail
The ALSA API provides two basic pieces of information, avail
and delay, which combined with the trigger and current system
timestamps allow for applications to keep track of the 'fullness' of
the ring buffer and the amount of queued samples.
Expand Down Expand Up @@ -53,21 +53,21 @@ case):
The analog time is taken at the last stage of the playback, as close
as possible to the actual transducer

The link time is taken at the output of the SOC/chipset as the samples
The link time is taken at the output of the SoC/chipset as the samples
are pushed on a link. The link time can be directly measured if
supported in hardware by sample counters or wallclocks (e.g. with
HDAudio 24MHz or PTP clock for networked solutions) or indirectly
estimated (e.g. with the frame counter in USB).

The DMA time is measured using counters - typically the least reliable
of all measurements due to the bursty natured of DMA transfers.
of all measurements due to the bursty nature of DMA transfers.

The app time corresponds to the time tracked by an application after
writing in the ring buffer.

The application can query what the hardware supports, define which
The application can query the hardware capabilities, define which
audio time it wants reported by selecting the relevant settings in
audio_tstamp_config fields, get an estimate of the timestamp
audio_tstamp_config fields, thus get an estimate of the timestamp
accuracy. It can also request the delay-to-analog be included in the
measurement. Direct access to the link time is very interesting on
platforms that provide an embedded DSP; measuring directly the link
Expand Down Expand Up @@ -169,7 +169,7 @@ playback: systime: 938107562 nsec, audio time 938112708 nsec, systime delta -51
Example 1 shows that the timestamp at the DMA level is close to 1ms
ahead of the actual playback time (as a side time this sort of
measurement can help define rewind safeguards). Compensating for the
DMA-link delay in example 2 helps remove the hardware buffering abut
DMA-link delay in example 2 helps remove the hardware buffering but
the information is still very jittery, with up to one sample of
error. In example 3 where the timestamps are measured with the link
wallclock, the timestamps show a monotonic behavior and a lower
Expand Down
32 changes: 32 additions & 0 deletions sound/core/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,36 @@ static int snd_ctl_elem_list(struct snd_card *card,
return 0;
}

static bool validate_element_member_dimension(struct snd_ctl_elem_info *info)
{
unsigned int members;
unsigned int i;

if (info->dimen.d[0] == 0)
return true;

members = 1;
for (i = 0; i < ARRAY_SIZE(info->dimen.d); ++i) {
if (info->dimen.d[i] == 0)
break;
members *= info->dimen.d[i];

/*
* info->count should be validated in advance, to guarantee
* calculation soundness.
*/
if (members > info->count)
return false;
}

for (++i; i < ARRAY_SIZE(info->dimen.d); ++i) {
if (info->dimen.d[i] > 0)
return false;
}

return members == info->count;
}

static int snd_ctl_elem_info(struct snd_ctl_file *ctl,
struct snd_ctl_elem_info *info)
{
Expand Down Expand Up @@ -1274,6 +1304,8 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
if (info->count < 1 ||
info->count > max_value_counts[info->type])
return -EINVAL;
if (!validate_element_member_dimension(info))
return -EINVAL;
private_size = value_sizes[info->type] * info->count;

/*
Expand Down
10 changes: 5 additions & 5 deletions sound/core/seq/oss/seq_oss_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ struct seq_oss_synth {
static int max_synth_devs;
static struct seq_oss_synth *synth_devs[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
static struct seq_oss_synth midi_synth_dev = {
-1, /* seq_device */
SYNTH_TYPE_MIDI, /* synth_type */
0, /* synth_subtype */
16, /* nr_voices */
"MIDI", /* name */
.seq_device = -1,
.synth_type = SYNTH_TYPE_MIDI,
.synth_subtype = 0,
.nr_voices = 16,
.name = "MIDI",
};

static DEFINE_SPINLOCK(register_lock);
Expand Down
23 changes: 9 additions & 14 deletions sound/core/seq/seq_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static void snd_seq_timer_interrupt(struct snd_timer_instance *timeri,
snd_seq_timer_update_tick(&tmr->tick, resolution);

/* register actual time of this timer update */
do_gettimeofday(&tmr->last_update);
ktime_get_ts64(&tmr->last_update);

spin_unlock_irqrestore(&tmr->lock, flags);

Expand Down Expand Up @@ -392,7 +392,7 @@ static int seq_timer_start(struct snd_seq_timer *tmr)
return -EINVAL;
snd_timer_start(tmr->timeri, tmr->ticks);
tmr->running = 1;
do_gettimeofday(&tmr->last_update);
ktime_get_ts64(&tmr->last_update);
return 0;
}

Expand Down Expand Up @@ -420,7 +420,7 @@ static int seq_timer_continue(struct snd_seq_timer *tmr)
}
snd_timer_start(tmr->timeri, tmr->ticks);
tmr->running = 1;
do_gettimeofday(&tmr->last_update);
ktime_get_ts64(&tmr->last_update);
return 0;
}

Expand All @@ -444,17 +444,12 @@ snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr)
spin_lock_irqsave(&tmr->lock, flags);
cur_time = tmr->cur_time;
if (tmr->running) {
struct timeval tm;
int usec;
do_gettimeofday(&tm);
usec = (int)(tm.tv_usec - tmr->last_update.tv_usec);
if (usec < 0) {
cur_time.tv_nsec += (1000000 + usec) * 1000;
cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec - 1;
} else {
cur_time.tv_nsec += usec * 1000;
cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec;
}
struct timespec64 tm;

ktime_get_ts64(&tm);
tm = timespec64_sub(tm, tmr->last_update);
cur_time.tv_nsec = tm.tv_nsec;
cur_time.tv_sec = tm.tv_sec;
snd_seq_sanity_real_time(&cur_time);
}
spin_unlock_irqrestore(&tmr->lock, flags);
Expand Down
2 changes: 1 addition & 1 deletion sound/core/seq/seq_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct snd_seq_timer {
unsigned int skew;
unsigned int skew_base;

struct timeval last_update; /* time of last clock update, used for interpolation */
struct timespec64 last_update; /* time of last clock update, used for interpolation */

spinlock_t lock;
};
Expand Down
28 changes: 25 additions & 3 deletions sound/hda/hdmi_chmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ static void hdmi_std_setup_channel_mapping(struct hdac_chmap *chmap,
int hdmi_slot = 0;
/* fill actual channel mappings in ALSA channel (i) order */
for (i = 0; i < ch_alloc->channels; i++) {
while (!ch_alloc->speakers[7 - hdmi_slot] && !WARN_ON(hdmi_slot >= 8))
while (!WARN_ON(hdmi_slot >= 8) &&
!ch_alloc->speakers[7 - hdmi_slot])
hdmi_slot++; /* skip zero slots */

hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++;
Expand Down Expand Up @@ -430,6 +431,12 @@ static int to_cea_slot(int ordered_ca, unsigned char pos)
int mask = snd_hdac_chmap_to_spk_mask(pos);
int i;

/* Add sanity check to pass klockwork check.
* This should never happen.
*/
if (ordered_ca >= ARRAY_SIZE(channel_allocations))
return -1;

if (mask) {
for (i = 0; i < 8; i++) {
if (channel_allocations[ordered_ca].speakers[7 - i] == mask)
Expand All @@ -456,7 +463,15 @@ EXPORT_SYMBOL_GPL(snd_hdac_spk_to_chmap);
/* from CEA slot to ALSA API channel position */
static int from_cea_slot(int ordered_ca, unsigned char slot)
{
int mask = channel_allocations[ordered_ca].speakers[7 - slot];
int mask;

/* Add sanity check to pass klockwork check.
* This should never happen.
*/
if (slot >= 8)
return 0;

mask = channel_allocations[ordered_ca].speakers[7 - slot];

return snd_hdac_spk_to_chmap(mask);
}
Expand Down Expand Up @@ -523,7 +538,8 @@ static void hdmi_setup_fake_chmap(unsigned char *map, int ca)
int ordered_ca = get_channel_allocation_order(ca);

for (i = 0; i < 8; i++) {
if (i < channel_allocations[ordered_ca].channels)
if (ordered_ca < ARRAY_SIZE(channel_allocations) &&
i < channel_allocations[ordered_ca].channels)
map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f);
else
map[i] = 0;
Expand Down Expand Up @@ -551,6 +567,12 @@ int snd_hdac_get_active_channels(int ca)
{
int ordered_ca = get_channel_allocation_order(ca);

/* Add sanity check to pass klockwork check.
* This should never happen.
*/
if (ordered_ca >= ARRAY_SIZE(channel_allocations))
ordered_ca = 0;

return channel_allocations[ordered_ca].channels;
}
EXPORT_SYMBOL_GPL(snd_hdac_get_active_channels);
Expand Down
2 changes: 1 addition & 1 deletion sound/i2c/other/ak4114.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int snd_ak4114_create(struct snd_card *card,

__fail:
snd_ak4114_free(chip);
return err < 0 ? err : -EIO;
return err;
}
EXPORT_SYMBOL(snd_ak4114_create);

Expand Down
2 changes: 1 addition & 1 deletion sound/i2c/other/ak4117.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t

__fail:
snd_ak4117_free(chip);
return err < 0 ? err : -EIO;
return err;
}

void snd_ak4117_reg_write(struct ak4117 *chip, unsigned char reg, unsigned char mask, unsigned char val)
Expand Down
13 changes: 1 addition & 12 deletions sound/isa/ad1848/ad1848.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,4 @@ static struct isa_driver snd_ad1848_driver = {
}
};

static int __init alsa_card_ad1848_init(void)
{
return isa_register_driver(&snd_ad1848_driver, SNDRV_CARDS);
}

static void __exit alsa_card_ad1848_exit(void)
{
isa_unregister_driver(&snd_ad1848_driver);
}

module_init(alsa_card_ad1848_init);
module_exit(alsa_card_ad1848_exit);
module_isa_driver(snd_ad1848_driver, SNDRV_CARDS);
13 changes: 1 addition & 12 deletions sound/isa/adlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,4 @@ static struct isa_driver snd_adlib_driver = {
}
};

static int __init alsa_card_adlib_init(void)
{
return isa_register_driver(&snd_adlib_driver, SNDRV_CARDS);
}

static void __exit alsa_card_adlib_exit(void)
{
isa_unregister_driver(&snd_adlib_driver);
}

module_init(alsa_card_adlib_init);
module_exit(alsa_card_adlib_exit);
module_isa_driver(snd_adlib_driver, SNDRV_CARDS);
13 changes: 1 addition & 12 deletions sound/isa/cmi8328.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,4 @@ static struct isa_driver snd_cmi8328_driver = {
},
};

static int __init alsa_card_cmi8328_init(void)
{
return isa_register_driver(&snd_cmi8328_driver, CMI8328_MAX);
}

static void __exit alsa_card_cmi8328_exit(void)
{
isa_unregister_driver(&snd_cmi8328_driver);
}

module_init(alsa_card_cmi8328_init)
module_exit(alsa_card_cmi8328_exit)
module_isa_driver(snd_cmi8328_driver, CMI8328_MAX);
13 changes: 1 addition & 12 deletions sound/isa/cs423x/cs4231.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,4 @@ static struct isa_driver snd_cs4231_driver = {
}
};

static int __init alsa_card_cs4231_init(void)
{
return isa_register_driver(&snd_cs4231_driver, SNDRV_CARDS);
}

static void __exit alsa_card_cs4231_exit(void)
{
isa_unregister_driver(&snd_cs4231_driver);
}

module_init(alsa_card_cs4231_init);
module_exit(alsa_card_cs4231_exit);
module_isa_driver(snd_cs4231_driver, SNDRV_CARDS);
13 changes: 1 addition & 12 deletions sound/isa/galaxy/galaxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,15 +634,4 @@ static struct isa_driver snd_galaxy_driver = {
}
};

static int __init alsa_card_galaxy_init(void)
{
return isa_register_driver(&snd_galaxy_driver, SNDRV_CARDS);
}

static void __exit alsa_card_galaxy_exit(void)
{
isa_unregister_driver(&snd_galaxy_driver);
}

module_init(alsa_card_galaxy_init);
module_exit(alsa_card_galaxy_exit);
module_isa_driver(snd_galaxy_driver, SNDRV_CARDS);
13 changes: 1 addition & 12 deletions sound/isa/gus/gusclassic.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,4 @@ static struct isa_driver snd_gusclassic_driver = {
}
};

static int __init alsa_card_gusclassic_init(void)
{
return isa_register_driver(&snd_gusclassic_driver, SNDRV_CARDS);
}

static void __exit alsa_card_gusclassic_exit(void)
{
isa_unregister_driver(&snd_gusclassic_driver);
}

module_init(alsa_card_gusclassic_init);
module_exit(alsa_card_gusclassic_exit);
module_isa_driver(snd_gusclassic_driver, SNDRV_CARDS);
13 changes: 1 addition & 12 deletions sound/isa/gus/gusextreme.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,4 @@ static struct isa_driver snd_gusextreme_driver = {
}
};

static int __init alsa_card_gusextreme_init(void)
{
return isa_register_driver(&snd_gusextreme_driver, SNDRV_CARDS);
}

static void __exit alsa_card_gusextreme_exit(void)
{
isa_unregister_driver(&snd_gusextreme_driver);
}

module_init(alsa_card_gusextreme_init);
module_exit(alsa_card_gusextreme_exit);
module_isa_driver(snd_gusextreme_driver, SNDRV_CARDS);
13 changes: 1 addition & 12 deletions sound/isa/gus/gusmax.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,4 @@ static struct isa_driver snd_gusmax_driver = {
},
};

static int __init alsa_card_gusmax_init(void)
{
return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS);
}

static void __exit alsa_card_gusmax_exit(void)
{
isa_unregister_driver(&snd_gusmax_driver);
}

module_init(alsa_card_gusmax_init)
module_exit(alsa_card_gusmax_exit)
module_isa_driver(snd_gusmax_driver, SNDRV_CARDS);
Loading

0 comments on commit cf81d6b

Please sign in to comment.