Skip to content

Commit cf81d6b

Browse files
committed
Merge branch 'for-next' into for-linus
Merged 4.8 changes.
2 parents 76df529 + 275353b commit cf81d6b

34 files changed

+180
-216
lines changed

Diff for: Documentation/sound/alsa/timestamping.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ provides a refined estimate with a delay.
1414
event or application query.
1515
The difference (tstamp - trigger_tstamp) defines the elapsed time.
1616

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

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

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

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

68-
The application can query what the hardware supports, define which
68+
The application can query the hardware capabilities, define which
6969
audio time it wants reported by selecting the relevant settings in
70-
audio_tstamp_config fields, get an estimate of the timestamp
70+
audio_tstamp_config fields, thus get an estimate of the timestamp
7171
accuracy. It can also request the delay-to-analog be included in the
7272
measurement. Direct access to the link time is very interesting on
7373
platforms that provide an embedded DSP; measuring directly the link
@@ -169,7 +169,7 @@ playback: systime: 938107562 nsec, audio time 938112708 nsec, systime delta -51
169169
Example 1 shows that the timestamp at the DMA level is close to 1ms
170170
ahead of the actual playback time (as a side time this sort of
171171
measurement can help define rewind safeguards). Compensating for the
172-
DMA-link delay in example 2 helps remove the hardware buffering abut
172+
DMA-link delay in example 2 helps remove the hardware buffering but
173173
the information is still very jittery, with up to one sample of
174174
error. In example 3 where the timestamps are measured with the link
175175
wallclock, the timestamps show a monotonic behavior and a lower

Diff for: sound/core/control.c

+32
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,36 @@ static int snd_ctl_elem_list(struct snd_card *card,
807807
return 0;
808808
}
809809

810+
static bool validate_element_member_dimension(struct snd_ctl_elem_info *info)
811+
{
812+
unsigned int members;
813+
unsigned int i;
814+
815+
if (info->dimen.d[0] == 0)
816+
return true;
817+
818+
members = 1;
819+
for (i = 0; i < ARRAY_SIZE(info->dimen.d); ++i) {
820+
if (info->dimen.d[i] == 0)
821+
break;
822+
members *= info->dimen.d[i];
823+
824+
/*
825+
* info->count should be validated in advance, to guarantee
826+
* calculation soundness.
827+
*/
828+
if (members > info->count)
829+
return false;
830+
}
831+
832+
for (++i; i < ARRAY_SIZE(info->dimen.d); ++i) {
833+
if (info->dimen.d[i] > 0)
834+
return false;
835+
}
836+
837+
return members == info->count;
838+
}
839+
810840
static int snd_ctl_elem_info(struct snd_ctl_file *ctl,
811841
struct snd_ctl_elem_info *info)
812842
{
@@ -1274,6 +1304,8 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
12741304
if (info->count < 1 ||
12751305
info->count > max_value_counts[info->type])
12761306
return -EINVAL;
1307+
if (!validate_element_member_dimension(info))
1308+
return -EINVAL;
12771309
private_size = value_sizes[info->type] * info->count;
12781310

12791311
/*

Diff for: sound/core/seq/oss/seq_oss_synth.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ struct seq_oss_synth {
7070
static int max_synth_devs;
7171
static struct seq_oss_synth *synth_devs[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
7272
static struct seq_oss_synth midi_synth_dev = {
73-
-1, /* seq_device */
74-
SYNTH_TYPE_MIDI, /* synth_type */
75-
0, /* synth_subtype */
76-
16, /* nr_voices */
77-
"MIDI", /* name */
73+
.seq_device = -1,
74+
.synth_type = SYNTH_TYPE_MIDI,
75+
.synth_subtype = 0,
76+
.nr_voices = 16,
77+
.name = "MIDI",
7878
};
7979

8080
static DEFINE_SPINLOCK(register_lock);

Diff for: sound/core/seq/seq_timer.c

+9-14
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static void snd_seq_timer_interrupt(struct snd_timer_instance *timeri,
165165
snd_seq_timer_update_tick(&tmr->tick, resolution);
166166

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

170170
spin_unlock_irqrestore(&tmr->lock, flags);
171171

@@ -392,7 +392,7 @@ static int seq_timer_start(struct snd_seq_timer *tmr)
392392
return -EINVAL;
393393
snd_timer_start(tmr->timeri, tmr->ticks);
394394
tmr->running = 1;
395-
do_gettimeofday(&tmr->last_update);
395+
ktime_get_ts64(&tmr->last_update);
396396
return 0;
397397
}
398398

@@ -420,7 +420,7 @@ static int seq_timer_continue(struct snd_seq_timer *tmr)
420420
}
421421
snd_timer_start(tmr->timeri, tmr->ticks);
422422
tmr->running = 1;
423-
do_gettimeofday(&tmr->last_update);
423+
ktime_get_ts64(&tmr->last_update);
424424
return 0;
425425
}
426426

@@ -444,17 +444,12 @@ snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr)
444444
spin_lock_irqsave(&tmr->lock, flags);
445445
cur_time = tmr->cur_time;
446446
if (tmr->running) {
447-
struct timeval tm;
448-
int usec;
449-
do_gettimeofday(&tm);
450-
usec = (int)(tm.tv_usec - tmr->last_update.tv_usec);
451-
if (usec < 0) {
452-
cur_time.tv_nsec += (1000000 + usec) * 1000;
453-
cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec - 1;
454-
} else {
455-
cur_time.tv_nsec += usec * 1000;
456-
cur_time.tv_sec += tm.tv_sec - tmr->last_update.tv_sec;
457-
}
447+
struct timespec64 tm;
448+
449+
ktime_get_ts64(&tm);
450+
tm = timespec64_sub(tm, tmr->last_update);
451+
cur_time.tv_nsec = tm.tv_nsec;
452+
cur_time.tv_sec = tm.tv_sec;
458453
snd_seq_sanity_real_time(&cur_time);
459454
}
460455
spin_unlock_irqrestore(&tmr->lock, flags);

Diff for: sound/core/seq/seq_timer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct snd_seq_timer {
5252
unsigned int skew;
5353
unsigned int skew_base;
5454

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

5757
spinlock_t lock;
5858
};

Diff for: sound/hda/hdmi_chmap.c

+25-3
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@ static void hdmi_std_setup_channel_mapping(struct hdac_chmap *chmap,
353353
int hdmi_slot = 0;
354354
/* fill actual channel mappings in ALSA channel (i) order */
355355
for (i = 0; i < ch_alloc->channels; i++) {
356-
while (!ch_alloc->speakers[7 - hdmi_slot] && !WARN_ON(hdmi_slot >= 8))
356+
while (!WARN_ON(hdmi_slot >= 8) &&
357+
!ch_alloc->speakers[7 - hdmi_slot])
357358
hdmi_slot++; /* skip zero slots */
358359

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

434+
/* Add sanity check to pass klockwork check.
435+
* This should never happen.
436+
*/
437+
if (ordered_ca >= ARRAY_SIZE(channel_allocations))
438+
return -1;
439+
433440
if (mask) {
434441
for (i = 0; i < 8; i++) {
435442
if (channel_allocations[ordered_ca].speakers[7 - i] == mask)
@@ -456,7 +463,15 @@ EXPORT_SYMBOL_GPL(snd_hdac_spk_to_chmap);
456463
/* from CEA slot to ALSA API channel position */
457464
static int from_cea_slot(int ordered_ca, unsigned char slot)
458465
{
459-
int mask = channel_allocations[ordered_ca].speakers[7 - slot];
466+
int mask;
467+
468+
/* Add sanity check to pass klockwork check.
469+
* This should never happen.
470+
*/
471+
if (slot >= 8)
472+
return 0;
473+
474+
mask = channel_allocations[ordered_ca].speakers[7 - slot];
460475

461476
return snd_hdac_spk_to_chmap(mask);
462477
}
@@ -523,7 +538,8 @@ static void hdmi_setup_fake_chmap(unsigned char *map, int ca)
523538
int ordered_ca = get_channel_allocation_order(ca);
524539

525540
for (i = 0; i < 8; i++) {
526-
if (i < channel_allocations[ordered_ca].channels)
541+
if (ordered_ca < ARRAY_SIZE(channel_allocations) &&
542+
i < channel_allocations[ordered_ca].channels)
527543
map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f);
528544
else
529545
map[i] = 0;
@@ -551,6 +567,12 @@ int snd_hdac_get_active_channels(int ca)
551567
{
552568
int ordered_ca = get_channel_allocation_order(ca);
553569

570+
/* Add sanity check to pass klockwork check.
571+
* This should never happen.
572+
*/
573+
if (ordered_ca >= ARRAY_SIZE(channel_allocations))
574+
ordered_ca = 0;
575+
554576
return channel_allocations[ordered_ca].channels;
555577
}
556578
EXPORT_SYMBOL_GPL(snd_hdac_get_active_channels);

Diff for: sound/i2c/other/ak4114.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int snd_ak4114_create(struct snd_card *card,
121121

122122
__fail:
123123
snd_ak4114_free(chip);
124-
return err < 0 ? err : -EIO;
124+
return err;
125125
}
126126
EXPORT_SYMBOL(snd_ak4114_create);
127127

Diff for: sound/i2c/other/ak4117.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t
110110

111111
__fail:
112112
snd_ak4117_free(chip);
113-
return err < 0 ? err : -EIO;
113+
return err;
114114
}
115115

116116
void snd_ak4117_reg_write(struct ak4117 *chip, unsigned char reg, unsigned char mask, unsigned char val)

Diff for: sound/isa/ad1848/ad1848.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,4 @@ static struct isa_driver snd_ad1848_driver = {
170170
}
171171
};
172172

173-
static int __init alsa_card_ad1848_init(void)
174-
{
175-
return isa_register_driver(&snd_ad1848_driver, SNDRV_CARDS);
176-
}
177-
178-
static void __exit alsa_card_ad1848_exit(void)
179-
{
180-
isa_unregister_driver(&snd_ad1848_driver);
181-
}
182-
183-
module_init(alsa_card_ad1848_init);
184-
module_exit(alsa_card_ad1848_exit);
173+
module_isa_driver(snd_ad1848_driver, SNDRV_CARDS);

Diff for: sound/isa/adlib.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,4 @@ static struct isa_driver snd_adlib_driver = {
112112
}
113113
};
114114

115-
static int __init alsa_card_adlib_init(void)
116-
{
117-
return isa_register_driver(&snd_adlib_driver, SNDRV_CARDS);
118-
}
119-
120-
static void __exit alsa_card_adlib_exit(void)
121-
{
122-
isa_unregister_driver(&snd_adlib_driver);
123-
}
124-
125-
module_init(alsa_card_adlib_init);
126-
module_exit(alsa_card_adlib_exit);
115+
module_isa_driver(snd_adlib_driver, SNDRV_CARDS);

Diff for: sound/isa/cmi8328.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -469,15 +469,4 @@ static struct isa_driver snd_cmi8328_driver = {
469469
},
470470
};
471471

472-
static int __init alsa_card_cmi8328_init(void)
473-
{
474-
return isa_register_driver(&snd_cmi8328_driver, CMI8328_MAX);
475-
}
476-
477-
static void __exit alsa_card_cmi8328_exit(void)
478-
{
479-
isa_unregister_driver(&snd_cmi8328_driver);
480-
}
481-
482-
module_init(alsa_card_cmi8328_init)
483-
module_exit(alsa_card_cmi8328_exit)
472+
module_isa_driver(snd_cmi8328_driver, CMI8328_MAX);

Diff for: sound/isa/cs423x/cs4231.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,4 @@ static struct isa_driver snd_cs4231_driver = {
186186
}
187187
};
188188

189-
static int __init alsa_card_cs4231_init(void)
190-
{
191-
return isa_register_driver(&snd_cs4231_driver, SNDRV_CARDS);
192-
}
193-
194-
static void __exit alsa_card_cs4231_exit(void)
195-
{
196-
isa_unregister_driver(&snd_cs4231_driver);
197-
}
198-
199-
module_init(alsa_card_cs4231_init);
200-
module_exit(alsa_card_cs4231_exit);
189+
module_isa_driver(snd_cs4231_driver, SNDRV_CARDS);

Diff for: sound/isa/galaxy/galaxy.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -634,15 +634,4 @@ static struct isa_driver snd_galaxy_driver = {
634634
}
635635
};
636636

637-
static int __init alsa_card_galaxy_init(void)
638-
{
639-
return isa_register_driver(&snd_galaxy_driver, SNDRV_CARDS);
640-
}
641-
642-
static void __exit alsa_card_galaxy_exit(void)
643-
{
644-
isa_unregister_driver(&snd_galaxy_driver);
645-
}
646-
647-
module_init(alsa_card_galaxy_init);
648-
module_exit(alsa_card_galaxy_exit);
637+
module_isa_driver(snd_galaxy_driver, SNDRV_CARDS);

Diff for: sound/isa/gus/gusclassic.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,4 @@ static struct isa_driver snd_gusclassic_driver = {
229229
}
230230
};
231231

232-
static int __init alsa_card_gusclassic_init(void)
233-
{
234-
return isa_register_driver(&snd_gusclassic_driver, SNDRV_CARDS);
235-
}
236-
237-
static void __exit alsa_card_gusclassic_exit(void)
238-
{
239-
isa_unregister_driver(&snd_gusclassic_driver);
240-
}
241-
242-
module_init(alsa_card_gusclassic_init);
243-
module_exit(alsa_card_gusclassic_exit);
232+
module_isa_driver(snd_gusclassic_driver, SNDRV_CARDS);

Diff for: sound/isa/gus/gusextreme.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,4 @@ static struct isa_driver snd_gusextreme_driver = {
358358
}
359359
};
360360

361-
static int __init alsa_card_gusextreme_init(void)
362-
{
363-
return isa_register_driver(&snd_gusextreme_driver, SNDRV_CARDS);
364-
}
365-
366-
static void __exit alsa_card_gusextreme_exit(void)
367-
{
368-
isa_unregister_driver(&snd_gusextreme_driver);
369-
}
370-
371-
module_init(alsa_card_gusextreme_init);
372-
module_exit(alsa_card_gusextreme_exit);
361+
module_isa_driver(snd_gusextreme_driver, SNDRV_CARDS);

Diff for: sound/isa/gus/gusmax.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,4 @@ static struct isa_driver snd_gusmax_driver = {
370370
},
371371
};
372372

373-
static int __init alsa_card_gusmax_init(void)
374-
{
375-
return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS);
376-
}
377-
378-
static void __exit alsa_card_gusmax_exit(void)
379-
{
380-
isa_unregister_driver(&snd_gusmax_driver);
381-
}
382-
383-
module_init(alsa_card_gusmax_init)
384-
module_exit(alsa_card_gusmax_exit)
373+
module_isa_driver(snd_gusmax_driver, SNDRV_CARDS);

0 commit comments

Comments
 (0)