···655655and next kernels are found in for-linus and for-next branches,656656respectively.657657658658-If you are using the latest Linus tree, it'd be better to pull the659659-above GIT tree onto it. If you are using the older kernels, an easy660660-way to try the latest ALSA code is to build from the snapshot661661-tarball. There are daily tarballs and the latest snapshot tarball.662662-All can be built just like normal alsa-driver release packages, that663663-is, installed via the usual spells: configure, make and make664664-install(-modules). See INSTALL in the package. The snapshot tarballs665665-are found at:666666-667667-- ftp://ftp.suse.com/pub/people/tiwai/snapshot/668668-669658670659Sending a Bug Report671660~~~~~~~~~~~~~~~~~~~~···688699alsa-info689700~~~~~~~~~690701The script `alsa-info.sh` is a very useful tool to gather the audio691691-device information. You can fetch the latest version from:702702+device information. It's included in alsa-utils package. The latest703703+version can be found on git repository:704704+705705+- git://git.alsa-project.org/alsa-utils.git706706+707707+The script can be fetched directly from the following URL, too:692708693709- http://www.alsa-project.org/alsa-info.sh694710···830836(mixer) elements, set/get the control element value, simulate the PCM831837operation, the jack plugging simulation, etc.832838833833-The package is found in:834834-835835-- ftp://ftp.suse.com/pub/people/tiwai/misc/836836-837837-A git repository is available:839839+The program is found in the git repository below:838840839841- git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-emu.git840842841841-See README file in the tarball for more details about hda-emu843843+See README file in the repository for more details about hda-emu842844program.843845844846
+2-2
Documentation/sound/alsa/compress_offload.txt
···149149================150150When playing thru an album, the decoders have the ability to skip the encoder151151delay and padding and directly move from one track content to another. The end152152-user can perceive this as gapless playback as we dont have silence while152152+user can perceive this as gapless playback as we don't have silence while153153switching from one track to another154154155155Also, there might be low-intensity noises due to encoding. Perfect gapless is···184184- Fill data of the first track185185- Trigger start186186- User-space finished sending all,187187-- Indicaite next track data by sending set_next_track187187+- Indicate next track data by sending set_next_track188188- Set metadata of the next track189189- then call partial_drain to flush most of buffer in DSP190190- Fill data of the next track
+1-1
Documentation/sound/alsa/soc/dapm.txt
···132132SND_SOC_DAPM_MIXER("Output Mixer", WM8731_PWR, 4, 1, wm8731_output_mixer_controls,133133 ARRAY_SIZE(wm8731_output_mixer_controls)),134134135135-If you dont want the mixer elements prefixed with the name of the mixer widget,135135+If you don't want the mixer elements prefixed with the name of the mixer widget,136136you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same137137as for SND_SOC_DAPM_MIXER.138138
+1-1
Documentation/sound/alsa/soc/overview.txt
···6363 and any audio DSP drivers for that platform.64646565 * Machine class driver: The machine driver class acts as the glue that6666- decribes and binds the other component drivers together to form an ALSA6666+ describes and binds the other component drivers together to form an ALSA6767 "sound card device". It handles any machine specific controls and6868 machine level audio events (e.g. turning on an amp at start of playback).6969
+1-1
Documentation/sound/alsa/timestamping.txt
···129129interpolation of the results130130131131In some hardware-specific configuration, the system timestamp is132132-latched by a low-level audio subsytem, and the information provided132132+latched by a low-level audio subsystem, and the information provided133133back to the driver. Due to potential delays in the communication with134134the hardware, there is a risk of misalignment with the avail and delay135135information. To make sure applications are not confused, a
+2
include/sound/hda_chmap.h
···3636 int (*chmap_validate)(struct hdac_chmap *hchmap, int ca,3737 int channels, unsigned char *chmap);38383939+ int (*get_spk_alloc)(struct hdac_device *hdac, int pcm_idx);4040+3941 void (*get_chmap)(struct hdac_device *hdac, int pcm_idx,4042 unsigned char *chmap);4143 void (*set_chmap)(struct hdac_device *hdac, int pcm_idx,
+5-5
include/sound/hda_i915.h
···1010int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable);1111int snd_hdac_display_power(struct hdac_bus *bus, bool enable);1212void snd_hdac_i915_set_bclk(struct hdac_bus *bus);1313-int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid, int rate);1414-int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid,1313+int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid, int rate);1414+int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid,1515 bool *audio_enabled, char *buffer, int max_bytes);1616int snd_hdac_i915_init(struct hdac_bus *bus);1717int snd_hdac_i915_exit(struct hdac_bus *bus);···2828static inline void snd_hdac_i915_set_bclk(struct hdac_bus *bus)2929{3030}3131-static inline int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid,3232- int rate)3131+static inline int snd_hdac_sync_audio_rate(struct hdac_device *codec,3232+ hda_nid_t nid, int rate)3333{3434 return 0;3535}3636-static inline int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid,3636+static inline int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid,3737 bool *audio_enabled, char *buffer,3838 int max_bytes)3939{
···141141 Say Y here to use the HR-timer backend as the default sequencer142142 timer.143143144144-config SND_RTCTIMER145145- tristate "RTC Timer support"146146- depends on RTC147147- select SND_TIMER148148- help149149- Say Y here to enable RTC timer support for ALSA. ALSA uses150150- the RTC timer as a precise timing source and maps the RTC151151- timer to ALSA's timer interface. The ALSA sequencer code also152152- can use this timing source.153153-154154- To compile this driver as a module, choose M here: the module155155- will be called snd-rtctimer.156156-157157- Note that this option is exclusive with the new RTC drivers158158- (CONFIG_RTC_CLASS) since this requires the old API.159159-160160-config SND_SEQ_RTCTIMER_DEFAULT161161- bool "Use RTC as default sequencer timer"162162- depends on SND_RTCTIMER && SND_SEQUENCER163163- depends on !SND_SEQ_HRTIMER_DEFAULT164164- default y165165- help166166- Say Y here to use the RTC timer as the default sequencer167167- timer. This is strongly recommended because it ensures168168- precise MIDI timing even when the system timer runs at less169169- than 1000 Hz.170170-171171- If in doubt, say Y.172172-173144config SND_DYNAMIC_MINORS174145 bool "Dynamic device file minor numbers"175146 help
···11-/*22- * RTC based high-frequency timer33- *44- * Copyright (C) 2000 Takashi Iwai55- * based on rtctimer.c by Steve Ratcliffe66- *77- * This program is free software; you can redistribute it and/or modify88- * it under the terms of the GNU General Public License as published by99- * the Free Software Foundation; either version 2 of the License, or1010- * (at your option) any later version.1111- *1212- * This program is distributed in the hope that it will be useful,1313- * but WITHOUT ANY WARRANTY; without even the implied warranty of1414- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515- * GNU General Public License for more details.1616- *1717- * You should have received a copy of the GNU General Public License1818- * along with this program; if not, write to the Free Software1919- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2020- *2121- */2222-2323-#include <linux/init.h>2424-#include <linux/interrupt.h>2525-#include <linux/module.h>2626-#include <linux/log2.h>2727-#include <sound/core.h>2828-#include <sound/timer.h>2929-3030-#if IS_ENABLED(CONFIG_RTC)3131-3232-#include <linux/mc146818rtc.h>3333-3434-#define RTC_FREQ 1024 /* default frequency */3535-#define NANO_SEC 1000000000L /* 10^9 in sec */3636-3737-/*3838- * prototypes3939- */4040-static int rtctimer_open(struct snd_timer *t);4141-static int rtctimer_close(struct snd_timer *t);4242-static int rtctimer_start(struct snd_timer *t);4343-static int rtctimer_stop(struct snd_timer *t);4444-4545-4646-/*4747- * The hardware dependent description for this timer.4848- */4949-static struct snd_timer_hardware rtc_hw = {5050- .flags = SNDRV_TIMER_HW_AUTO |5151- SNDRV_TIMER_HW_FIRST |5252- SNDRV_TIMER_HW_TASKLET,5353- .ticks = 100000000L, /* FIXME: XXX */5454- .open = rtctimer_open,5555- .close = rtctimer_close,5656- .start = rtctimer_start,5757- .stop = rtctimer_stop,5858-};5959-6060-static int rtctimer_freq = RTC_FREQ; /* frequency */6161-static struct snd_timer *rtctimer;6262-static struct tasklet_struct rtc_tasklet;6363-static rtc_task_t rtc_task;6464-6565-6666-static int6767-rtctimer_open(struct snd_timer *t)6868-{6969- int err;7070-7171- err = rtc_register(&rtc_task);7272- if (err < 0)7373- return err;7474- t->private_data = &rtc_task;7575- return 0;7676-}7777-7878-static int7979-rtctimer_close(struct snd_timer *t)8080-{8181- rtc_task_t *rtc = t->private_data;8282- if (rtc) {8383- rtc_unregister(rtc);8484- tasklet_kill(&rtc_tasklet);8585- t->private_data = NULL;8686- }8787- return 0;8888-}8989-9090-static int9191-rtctimer_start(struct snd_timer *timer)9292-{9393- rtc_task_t *rtc = timer->private_data;9494- if (snd_BUG_ON(!rtc))9595- return -EINVAL;9696- rtc_control(rtc, RTC_IRQP_SET, rtctimer_freq);9797- rtc_control(rtc, RTC_PIE_ON, 0);9898- return 0;9999-}100100-101101-static int102102-rtctimer_stop(struct snd_timer *timer)103103-{104104- rtc_task_t *rtc = timer->private_data;105105- if (snd_BUG_ON(!rtc))106106- return -EINVAL;107107- rtc_control(rtc, RTC_PIE_OFF, 0);108108- return 0;109109-}110110-111111-static void rtctimer_tasklet(unsigned long data)112112-{113113- snd_timer_interrupt((struct snd_timer *)data, 1);114114-}115115-116116-/*117117- * interrupt118118- */119119-static void rtctimer_interrupt(void *private_data)120120-{121121- tasklet_schedule(private_data);122122-}123123-124124-125125-/*126126- * ENTRY functions127127- */128128-static int __init rtctimer_init(void)129129-{130130- int err;131131- struct snd_timer *timer;132132-133133- if (rtctimer_freq < 2 || rtctimer_freq > 8192 ||134134- !is_power_of_2(rtctimer_freq)) {135135- pr_err("ALSA: rtctimer: invalid frequency %d\n", rtctimer_freq);136136- return -EINVAL;137137- }138138-139139- /* Create a new timer and set up the fields */140140- err = snd_timer_global_new("rtc", SNDRV_TIMER_GLOBAL_RTC, &timer);141141- if (err < 0)142142- return err;143143-144144- timer->module = THIS_MODULE;145145- strcpy(timer->name, "RTC timer");146146- timer->hw = rtc_hw;147147- timer->hw.resolution = NANO_SEC / rtctimer_freq;148148-149149- tasklet_init(&rtc_tasklet, rtctimer_tasklet, (unsigned long)timer);150150-151151- /* set up RTC callback */152152- rtc_task.func = rtctimer_interrupt;153153- rtc_task.private_data = &rtc_tasklet;154154-155155- err = snd_timer_global_register(timer);156156- if (err < 0) {157157- snd_timer_global_free(timer);158158- return err;159159- }160160- rtctimer = timer; /* remember this */161161-162162- return 0;163163-}164164-165165-static void __exit rtctimer_exit(void)166166-{167167- if (rtctimer) {168168- snd_timer_global_free(rtctimer);169169- rtctimer = NULL;170170- }171171-}172172-173173-174174-/*175175- * exported stuff176176- */177177-module_init(rtctimer_init)178178-module_exit(rtctimer_exit)179179-180180-module_param(rtctimer_freq, int, 0444);181181-MODULE_PARM_DESC(rtctimer_freq, "timer frequency in Hz");182182-183183-MODULE_LICENSE("GPL");184184-185185-MODULE_ALIAS("snd-timer-" __stringify(SNDRV_TIMER_GLOBAL_RTC));186186-187187-#endif /* IS_ENABLED(CONFIG_RTC) */
···134134 Say Y here to include support for TASCAM.135135 * FW-1884136136 * FW-1082137137+ * FW-1804137138138139 To compile this driver as a module, choose M here: the module139140 will be called snd-firewire-tascam.
+3
sound/firewire/Makefile
···11+# To find a header included by define_trace.h.22+CFLAGS_amdtp-stream.o := -I$(src)33+14snd-firewire-lib-objs := lib.o iso-resources.o packets-buffer.o \25 fcp.o cmp.o amdtp-stream.o amdtp-am824.o36snd-isight-objs := isight.o
···1919#define CYCLES_PER_SECOND 80002020#define TICKS_PER_SECOND (TICKS_PER_CYCLE * CYCLES_PER_SECOND)21212222+/* Always support Linux tracing subsystem. */2323+#define CREATE_TRACE_POINTS2424+#include "amdtp-stream-trace.h"2525+2226#define TRANSFER_DELAY_TICKS 0x2e00 /* 479.17 microseconds */23272428/* isochronous header parameters */···91879288 init_waitqueue_head(&s->callback_wait);9389 s->callbacked = false;9494- s->sync_slave = NULL;95909691 s->fmt = fmt;9792 s->process_data_blocks = process_data_blocks;···105102 */106103void amdtp_stream_destroy(struct amdtp_stream *s)107104{105105+ /* Not initialized. */106106+ if (s->protocol == NULL)107107+ return;108108+108109 WARN_ON(amdtp_stream_running(s));109110 kfree(s->protocol);110111 mutex_destroy(&s->mutex);···251244 tasklet_kill(&s->period_tasklet);252245 s->pcm_buffer_pointer = 0;253246 s->pcm_period_pointer = 0;254254- s->pointer_flush = true;255247}256248EXPORT_SYMBOL(amdtp_stream_pcm_prepare);257249···355349 s->pcm_period_pointer += frames;356350 if (s->pcm_period_pointer >= pcm->runtime->period_size) {357351 s->pcm_period_pointer -= pcm->runtime->period_size;358358- s->pointer_flush = false;359352 tasklet_hi_schedule(&s->period_tasklet);360353 }361354}···368363 snd_pcm_period_elapsed(pcm);369364}370365371371-static int queue_packet(struct amdtp_stream *s,372372- unsigned int header_length,373373- unsigned int payload_length, bool skip)366366+static int queue_packet(struct amdtp_stream *s, unsigned int header_length,367367+ unsigned int payload_length)374368{375369 struct fw_iso_packet p = {0};376370 int err = 0;···380376 p.interrupt = IS_ALIGNED(s->packet_index + 1, INTERRUPT_INTERVAL);381377 p.tag = TAG_CIP;382378 p.header_length = header_length;383383- p.payload_length = (!skip) ? payload_length : 0;384384- p.skip = skip;379379+ if (payload_length > 0)380380+ p.payload_length = payload_length;381381+ else382382+ p.skip = true;385383 err = fw_iso_context_queue(s->context, &p, &s->buffer.iso_buffer,386384 s->buffer.packets[s->packet_index].offset);387385 if (err < 0) {···398392}399393400394static inline int queue_out_packet(struct amdtp_stream *s,401401- unsigned int payload_length, bool skip)395395+ unsigned int payload_length)402396{403403- return queue_packet(s, OUT_PACKET_HEADER_SIZE,404404- payload_length, skip);397397+ return queue_packet(s, OUT_PACKET_HEADER_SIZE, payload_length);405398}406399407400static inline int queue_in_packet(struct amdtp_stream *s)408401{409402 return queue_packet(s, IN_PACKET_HEADER_SIZE,410410- amdtp_stream_get_max_payload(s), false);403403+ amdtp_stream_get_max_payload(s));411404}412405413413-static int handle_out_packet(struct amdtp_stream *s, unsigned int data_blocks,414414- unsigned int syt)406406+static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle,407407+ unsigned int index)415408{416409 __be32 *buffer;410410+ unsigned int syt;411411+ unsigned int data_blocks;417412 unsigned int payload_length;418413 unsigned int pcm_frames;419414 struct snd_pcm_substream *pcm;420415421416 buffer = s->buffer.packets[s->packet_index].buffer;417417+ syt = calculate_syt(s, cycle);418418+ data_blocks = calculate_data_blocks(s, syt);422419 pcm_frames = s->process_data_blocks(s, buffer + 2, data_blocks, &syt);423420424421 buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) |···433424 (syt & CIP_SYT_MASK));434425435426 s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff;436436-437427 payload_length = 8 + data_blocks * 4 * s->data_block_quadlets;438438- if (queue_out_packet(s, payload_length, false) < 0)428428+429429+ trace_out_packet(s, cycle, buffer, payload_length, index);430430+431431+ if (queue_out_packet(s, payload_length) < 0)439432 return -EIO;440433441434 pcm = ACCESS_ONCE(s->pcm);···449438}450439451440static int handle_in_packet(struct amdtp_stream *s,452452- unsigned int payload_quadlets, __be32 *buffer,453453- unsigned int *data_blocks, unsigned int syt)441441+ unsigned int payload_quadlets, unsigned int cycle,442442+ unsigned int index)454443{444444+ __be32 *buffer;455445 u32 cip_header[2];456456- unsigned int fmt, fdf;446446+ unsigned int fmt, fdf, syt;457447 unsigned int data_block_quadlets, data_block_counter, dbc_interval;448448+ unsigned int data_blocks;458449 struct snd_pcm_substream *pcm;459450 unsigned int pcm_frames;460451 bool lost;461452453453+ buffer = s->buffer.packets[s->packet_index].buffer;462454 cip_header[0] = be32_to_cpu(buffer[0]);463455 cip_header[1] = be32_to_cpu(buffer[1]);456456+457457+ trace_in_packet(s, cycle, cip_header, payload_quadlets, index);464458465459 /*466460 * This module supports 'Two-quadlet CIP header with SYT field'.···476460 dev_info_ratelimited(&s->unit->device,477461 "Invalid CIP header for AMDTP: %08X:%08X\n",478462 cip_header[0], cip_header[1]);479479- *data_blocks = 0;463463+ data_blocks = 0;480464 pcm_frames = 0;481465 goto end;482466 }···487471 dev_info_ratelimited(&s->unit->device,488472 "Detect unexpected protocol: %08x %08x\n",489473 cip_header[0], cip_header[1]);490490- *data_blocks = 0;474474+ data_blocks = 0;491475 pcm_frames = 0;492476 goto end;493477 }···496480 fdf = (cip_header[1] & CIP_FDF_MASK) >> CIP_FDF_SHIFT;497481 if (payload_quadlets < 3 ||498482 (fmt == CIP_FMT_AM && fdf == AMDTP_FDF_NO_DATA)) {499499- *data_blocks = 0;483483+ data_blocks = 0;500484 } else {501485 data_block_quadlets =502486 (cip_header[0] & CIP_DBS_MASK) >> CIP_DBS_SHIFT;···510494 if (s->flags & CIP_WRONG_DBS)511495 data_block_quadlets = s->data_block_quadlets;512496513513- *data_blocks = (payload_quadlets - 2) / data_block_quadlets;497497+ data_blocks = (payload_quadlets - 2) / data_block_quadlets;514498 }515499516500 /* Check data block counter continuity */517501 data_block_counter = cip_header[0] & CIP_DBC_MASK;518518- if (*data_blocks == 0 && (s->flags & CIP_EMPTY_HAS_WRONG_DBC) &&502502+ if (data_blocks == 0 && (s->flags & CIP_EMPTY_HAS_WRONG_DBC) &&519503 s->data_block_counter != UINT_MAX)520504 data_block_counter = s->data_block_counter;521505···526510 } else if (!(s->flags & CIP_DBC_IS_END_EVENT)) {527511 lost = data_block_counter != s->data_block_counter;528512 } else {529529- if ((*data_blocks > 0) && (s->tx_dbc_interval > 0))513513+ if (data_blocks > 0 && s->tx_dbc_interval > 0)530514 dbc_interval = s->tx_dbc_interval;531515 else532532- dbc_interval = *data_blocks;516516+ dbc_interval = data_blocks;533517534518 lost = data_block_counter !=535519 ((s->data_block_counter + dbc_interval) & 0xff);···542526 return -EIO;543527 }544528545545- pcm_frames = s->process_data_blocks(s, buffer + 2, *data_blocks, &syt);529529+ syt = be32_to_cpu(buffer[1]) & CIP_SYT_MASK;530530+ pcm_frames = s->process_data_blocks(s, buffer + 2, data_blocks, &syt);546531547532 if (s->flags & CIP_DBC_IS_END_EVENT)548533 s->data_block_counter = data_block_counter;549534 else550535 s->data_block_counter =551551- (data_block_counter + *data_blocks) & 0xff;536536+ (data_block_counter + data_blocks) & 0xff;552537end:553538 if (queue_in_packet(s) < 0)554539 return -EIO;···561544 return 0;562545}563546564564-static void out_stream_callback(struct fw_iso_context *context, u32 cycle,547547+/*548548+ * In CYCLE_TIMER register of IEEE 1394, 7 bits are used to represent second. On549549+ * the other hand, in DMA descriptors of 1394 OHCI, 3 bits are used to represent550550+ * it. Thus, via Linux firewire subsystem, we can get the 3 bits for second.551551+ */552552+static inline u32 compute_cycle_count(u32 tstamp)553553+{554554+ return (((tstamp >> 13) & 0x07) * 8000) + (tstamp & 0x1fff);555555+}556556+557557+static inline u32 increment_cycle_count(u32 cycle, unsigned int addend)558558+{559559+ cycle += addend;560560+ if (cycle >= 8 * CYCLES_PER_SECOND)561561+ cycle -= 8 * CYCLES_PER_SECOND;562562+ return cycle;563563+}564564+565565+static inline u32 decrement_cycle_count(u32 cycle, unsigned int subtrahend)566566+{567567+ if (cycle < subtrahend)568568+ cycle += 8 * CYCLES_PER_SECOND;569569+ return cycle - subtrahend;570570+}571571+572572+static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,565573 size_t header_length, void *header,566574 void *private_data)567575{568576 struct amdtp_stream *s = private_data;569569- unsigned int i, syt, packets = header_length / 4;570570- unsigned int data_blocks;577577+ unsigned int i, packets = header_length / 4;578578+ u32 cycle;571579572580 if (s->packet_index < 0)573581 return;574582575575- /*576576- * Compute the cycle of the last queued packet.577577- * (We need only the four lowest bits for the SYT, so we can ignore578578- * that bits 0-11 must wrap around at 3072.)579579- */580580- cycle += QUEUE_LENGTH - packets;583583+ cycle = compute_cycle_count(tstamp);584584+585585+ /* Align to actual cycle count for the last packet. */586586+ cycle = increment_cycle_count(cycle, QUEUE_LENGTH - packets);581587582588 for (i = 0; i < packets; ++i) {583583- syt = calculate_syt(s, ++cycle);584584- data_blocks = calculate_data_blocks(s, syt);585585-586586- if (handle_out_packet(s, data_blocks, syt) < 0) {589589+ cycle = increment_cycle_count(cycle, 1);590590+ if (handle_out_packet(s, cycle, i) < 0) {587591 s->packet_index = -1;588592 amdtp_stream_pcm_abort(s);589593 return;···614576 fw_iso_context_queue_flush(s->context);615577}616578617617-static void in_stream_callback(struct fw_iso_context *context, u32 cycle,579579+static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,618580 size_t header_length, void *header,619581 void *private_data)620582{621583 struct amdtp_stream *s = private_data;622622- unsigned int p, syt, packets;584584+ unsigned int i, packets;623585 unsigned int payload_quadlets, max_payload_quadlets;624624- unsigned int data_blocks;625625- __be32 *buffer, *headers = header;586586+ __be32 *headers = header;587587+ u32 cycle;626588627589 if (s->packet_index < 0)628590 return;···630592 /* The number of packets in buffer */631593 packets = header_length / IN_PACKET_HEADER_SIZE;632594595595+ cycle = compute_cycle_count(tstamp);596596+597597+ /* Align to actual cycle count for the last packet. */598598+ cycle = decrement_cycle_count(cycle, packets);599599+633600 /* For buffer-over-run prevention. */634601 max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4;635602636636- for (p = 0; p < packets; p++) {637637- buffer = s->buffer.packets[s->packet_index].buffer;603603+ for (i = 0; i < packets; i++) {604604+ cycle = increment_cycle_count(cycle, 1);638605639606 /* The number of quadlets in this packet */640607 payload_quadlets =641641- (be32_to_cpu(headers[p]) >> ISO_DATA_LENGTH_SHIFT) / 4;608608+ (be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT) / 4;642609 if (payload_quadlets > max_payload_quadlets) {643610 dev_err(&s->unit->device,644611 "Detect jumbo payload: %02x %02x\n",645612 payload_quadlets, max_payload_quadlets);646646- s->packet_index = -1;647613 break;648614 }649615650650- syt = be32_to_cpu(buffer[1]) & CIP_SYT_MASK;651651- if (handle_in_packet(s, payload_quadlets, buffer,652652- &data_blocks, syt) < 0) {653653- s->packet_index = -1;616616+ if (handle_in_packet(s, payload_quadlets, cycle, i) < 0)654617 break;655655- }656656-657657- /* Process sync slave stream */658658- if (s->sync_slave && s->sync_slave->callbacked) {659659- if (handle_out_packet(s->sync_slave,660660- data_blocks, syt) < 0) {661661- s->packet_index = -1;662662- break;663663- }664664- }665618 }666619667667- /* Queueing error or detecting discontinuity */668668- if (s->packet_index < 0) {620620+ /* Queueing error or detecting invalid payload. */621621+ if (i < packets) {622622+ s->packet_index = -1;669623 amdtp_stream_pcm_abort(s);670670-671671- /* Abort sync slave. */672672- if (s->sync_slave) {673673- s->sync_slave->packet_index = -1;674674- amdtp_stream_pcm_abort(s->sync_slave);675675- }676624 return;677625 }678678-679679- /* when sync to device, flush the packets for slave stream */680680- if (s->sync_slave && s->sync_slave->callbacked)681681- fw_iso_context_queue_flush(s->sync_slave->context);682626683627 fw_iso_context_queue_flush(s->context);684628}685629686686-/* processing is done by master callback */687687-static void slave_stream_callback(struct fw_iso_context *context, u32 cycle,688688- size_t header_length, void *header,689689- void *private_data)690690-{691691- return;692692-}693693-694630/* this is executed one time */695631static void amdtp_stream_first_callback(struct fw_iso_context *context,696696- u32 cycle, size_t header_length,632632+ u32 tstamp, size_t header_length,697633 void *header, void *private_data)698634{699635 struct amdtp_stream *s = private_data;···681669682670 if (s->direction == AMDTP_IN_STREAM)683671 context->callback.sc = in_stream_callback;684684- else if (s->flags & CIP_SYNC_TO_DEVICE)685685- context->callback.sc = slave_stream_callback;686672 else687673 context->callback.sc = out_stream_callback;688674689689- context->callback.sc(context, cycle, header_length, header, s);675675+ context->callback.sc(context, tstamp, header_length, header, s);690676}691677692678/**···723713 goto err_unlock;724714 }725715726726- if (s->direction == AMDTP_IN_STREAM &&727727- s->flags & CIP_SKIP_INIT_DBC_CHECK)716716+ if (s->direction == AMDTP_IN_STREAM)728717 s->data_block_counter = UINT_MAX;729718 else730719 s->data_block_counter = 0;···764755 if (s->direction == AMDTP_IN_STREAM)765756 err = queue_in_packet(s);766757 else767767- err = queue_out_packet(s, 0, true);758758+ err = queue_out_packet(s, 0);768759 if (err < 0)769760 goto err_context;770761 } while (s->packet_index > 0);···803794 */804795unsigned long amdtp_stream_pcm_pointer(struct amdtp_stream *s)805796{806806- /* this optimization is allowed to be racy */807807- if (s->pointer_flush && amdtp_stream_running(s))797797+ /*798798+ * This function is called in software IRQ context of period_tasklet or799799+ * process context.800800+ *801801+ * When the software IRQ context was scheduled by software IRQ context802802+ * of IR/IT contexts, queued packets were already handled. Therefore,803803+ * no need to flush the queue in buffer anymore.804804+ *805805+ * When the process context reach here, some packets will be already806806+ * queued in the buffer. These packets should be handled immediately807807+ * to keep better granularity of PCM pointer.808808+ *809809+ * Later, the process context will sometimes schedules software IRQ810810+ * context of the period_tasklet. Then, no need to flush the queue by811811+ * the same reason as described for IR/IT contexts.812812+ */813813+ if (!in_interrupt() && amdtp_stream_running(s))808814 fw_iso_context_flush_completions(s->context);809809- else810810- s->pointer_flush = true;811815812816 return ACCESS_ONCE(s->pcm_buffer_pointer);813817}
+6-31
sound/firewire/amdtp-stream.h
···1717 * @CIP_BLOCKING: In blocking mode, each packet contains either zero or1818 * SYT_INTERVAL samples, with these two types alternating so that1919 * the overall sample rate comes out right.2020- * @CIP_SYNC_TO_DEVICE: In sync to device mode, time stamp in out packets is2121- * generated by in packets. Defaultly this driver generates timestamp.2220 * @CIP_EMPTY_WITH_TAG0: Only for in-stream. Empty in-packets have TAG0.2321 * @CIP_DBC_IS_END_EVENT: Only for in-stream. The value of dbc in an in-packet2422 * corresponds to the end of event in the packet. Out of IEC 61883.···2426 * The value of data_block_quadlets is used instead of reported value.2527 * @CIP_SKIP_DBC_ZERO_CHECK: Only for in-stream. Packets with zero in dbc is2628 * skipped for detecting discontinuity.2727- * @CIP_SKIP_INIT_DBC_CHECK: Only for in-stream. The value of dbc in first2828- * packet is not continuous from an initial value.2929 * @CIP_EMPTY_HAS_WRONG_DBC: Only for in-stream. The value of dbc in empty3030 * packet is wrong but the others are correct.3131 * @CIP_JUMBO_PAYLOAD: Only for in-stream. The number of data blocks in an···3337enum cip_flags {3438 CIP_NONBLOCKING = 0x00,3539 CIP_BLOCKING = 0x01,3636- CIP_SYNC_TO_DEVICE = 0x02,3737- CIP_EMPTY_WITH_TAG0 = 0x04,3838- CIP_DBC_IS_END_EVENT = 0x08,3939- CIP_WRONG_DBS = 0x10,4040- CIP_SKIP_DBC_ZERO_CHECK = 0x20,4141- CIP_SKIP_INIT_DBC_CHECK = 0x40,4242- CIP_EMPTY_HAS_WRONG_DBC = 0x80,4343- CIP_JUMBO_PAYLOAD = 0x100,4040+ CIP_EMPTY_WITH_TAG0 = 0x02,4141+ CIP_DBC_IS_END_EVENT = 0x04,4242+ CIP_WRONG_DBS = 0x08,4343+ CIP_SKIP_DBC_ZERO_CHECK = 0x10,4444+ CIP_EMPTY_HAS_WRONG_DBC = 0x20,4545+ CIP_JUMBO_PAYLOAD = 0x40,4446};45474648/**···126132 struct tasklet_struct period_tasklet;127133 unsigned int pcm_buffer_pointer;128134 unsigned int pcm_period_pointer;129129- bool pointer_flush;130135131136 /* To wait for first packet. */132137 bool callbacked;133138 wait_queue_head_t callback_wait;134134- struct amdtp_stream *sync_slave;135139136140 /* For backends to process data blocks. */137141 void *protocol;···213221static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)214222{215223 return sfc & 1;216216-}217217-218218-static inline void amdtp_stream_set_sync(enum cip_flags sync_mode,219219- struct amdtp_stream *master,220220- struct amdtp_stream *slave)221221-{222222- if (sync_mode == CIP_SYNC_TO_DEVICE) {223223- master->flags |= CIP_SYNC_TO_DEVICE;224224- slave->flags |= CIP_SYNC_TO_DEVICE;225225- master->sync_slave = slave;226226- } else {227227- master->flags &= ~CIP_SYNC_TO_DEVICE;228228- slave->flags &= ~CIP_SYNC_TO_DEVICE;229229- master->sync_slave = NULL;230230- }231231-232232- slave->sync_slave = NULL;233224}234225235226/**
+129-90
sound/firewire/bebob/bebob.c
···6767#define MODEL_MAUDIO_PROJECTMIX 0x0001009168686969static int7070-name_device(struct snd_bebob *bebob, unsigned int vendor_id)7070+name_device(struct snd_bebob *bebob)7171{7272 struct fw_device *fw_dev = fw_parent_device(bebob->unit);7373 char vendor[24] = {0};···126126 return err;127127}128128129129+static void bebob_free(struct snd_bebob *bebob)130130+{131131+ snd_bebob_stream_destroy_duplex(bebob);132132+ fw_unit_put(bebob->unit);133133+134134+ kfree(bebob->maudio_special_quirk);135135+136136+ mutex_destroy(&bebob->mutex);137137+ kfree(bebob);138138+}139139+129140/*130141 * This module releases the FireWire unit data after all ALSA character devices131142 * are released by applications. This is for releasing stream data or finishing···148137{149138 struct snd_bebob *bebob = card->private_data;150139151151- snd_bebob_stream_destroy_duplex(bebob);152152- fw_unit_put(bebob->unit);140140+ mutex_lock(&devices_mutex);141141+ clear_bit(bebob->card_index, devices_used);142142+ mutex_unlock(&devices_mutex);153143154154- kfree(bebob->maudio_special_quirk);155155-156156- if (bebob->card_index >= 0) {157157- mutex_lock(&devices_mutex);158158- clear_bit(bebob->card_index, devices_used);159159- mutex_unlock(&devices_mutex);160160- }161161-162162- mutex_destroy(&bebob->mutex);144144+ bebob_free(card->private_data);163145}164146165147static const struct snd_bebob_spec *···180176 return strncmp(name, "FW Audiophile Bootloader", 15) != 0;181177}182178183183-static int184184-bebob_probe(struct fw_unit *unit,185185- const struct ieee1394_device_id *entry)179179+static void180180+do_registration(struct work_struct *work)186181{187187- struct snd_card *card;188188- struct snd_bebob *bebob;189189- const struct snd_bebob_spec *spec;182182+ struct snd_bebob *bebob =183183+ container_of(work, struct snd_bebob, dwork.work);190184 unsigned int card_index;191185 int err;186186+187187+ if (bebob->registered)188188+ return;192189193190 mutex_lock(&devices_mutex);194191···198193 break;199194 }200195 if (card_index >= SNDRV_CARDS) {201201- err = -ENOENT;202202- goto end;196196+ mutex_unlock(&devices_mutex);197197+ return;203198 }204199205205- if ((entry->vendor_id == VEN_FOCUSRITE) &&206206- (entry->model_id == MODEL_FOCUSRITE_SAFFIRE_BOTH))207207- spec = get_saffire_spec(unit);208208- else if ((entry->vendor_id == VEN_MAUDIO1) &&209209- (entry->model_id == MODEL_MAUDIO_AUDIOPHILE_BOTH) &&210210- !check_audiophile_booted(unit))211211- spec = NULL;212212- else213213- spec = (const struct snd_bebob_spec *)entry->driver_data;214214-215215- if (spec == NULL) {216216- if ((entry->vendor_id == VEN_MAUDIO1) ||217217- (entry->vendor_id == VEN_MAUDIO2))218218- err = snd_bebob_maudio_load_firmware(unit);219219- else220220- err = -ENOSYS;221221- goto end;200200+ err = snd_card_new(&bebob->unit->device, index[card_index],201201+ id[card_index], THIS_MODULE, 0, &bebob->card);202202+ if (err < 0) {203203+ mutex_unlock(&devices_mutex);204204+ return;222205 }223206224224- err = snd_card_new(&unit->device, index[card_index], id[card_index],225225- THIS_MODULE, sizeof(struct snd_bebob), &card);226226- if (err < 0)227227- goto end;228228- bebob = card->private_data;229229- bebob->card_index = card_index;230230- set_bit(card_index, devices_used);231231- card->private_free = bebob_card_free;232232-233233- bebob->card = card;234234- bebob->unit = fw_unit_get(unit);235235- bebob->spec = spec;236236- mutex_init(&bebob->mutex);237237- spin_lock_init(&bebob->lock);238238- init_waitqueue_head(&bebob->hwdep_wait);239239-240240- err = name_device(bebob, entry->vendor_id);207207+ err = name_device(bebob);241208 if (err < 0)242209 goto error;243210244244- if ((entry->vendor_id == VEN_MAUDIO1) &&245245- (entry->model_id == MODEL_MAUDIO_FW1814))246246- err = snd_bebob_maudio_special_discover(bebob, true);247247- else if ((entry->vendor_id == VEN_MAUDIO1) &&248248- (entry->model_id == MODEL_MAUDIO_PROJECTMIX))249249- err = snd_bebob_maudio_special_discover(bebob, false);250250- else211211+ if (bebob->spec == &maudio_special_spec) {212212+ if (bebob->entry->model_id == MODEL_MAUDIO_FW1814)213213+ err = snd_bebob_maudio_special_discover(bebob, true);214214+ else215215+ err = snd_bebob_maudio_special_discover(bebob, false);216216+ } else {251217 err = snd_bebob_stream_discover(bebob);218218+ }219219+ if (err < 0)220220+ goto error;221221+222222+ err = snd_bebob_stream_init_duplex(bebob);252223 if (err < 0)253224 goto error;254225255226 snd_bebob_proc_init(bebob);256227257257- if ((bebob->midi_input_ports > 0) ||258258- (bebob->midi_output_ports > 0)) {228228+ if (bebob->midi_input_ports > 0 || bebob->midi_output_ports > 0) {259229 err = snd_bebob_create_midi_devices(bebob);260230 if (err < 0)261231 goto error;···244264 if (err < 0)245265 goto error;246266247247- err = snd_bebob_stream_init_duplex(bebob);267267+ err = snd_card_register(bebob->card);248268 if (err < 0)249269 goto error;250270251251- if (!bebob->maudio_special_quirk) {252252- err = snd_card_register(card);253253- if (err < 0) {254254- snd_bebob_stream_destroy_duplex(bebob);255255- goto error;256256- }271271+ set_bit(card_index, devices_used);272272+ mutex_unlock(&devices_mutex);273273+274274+ /*275275+ * After registered, bebob instance can be released corresponding to276276+ * releasing the sound card instance.277277+ */278278+ bebob->card->private_free = bebob_card_free;279279+ bebob->card->private_data = bebob;280280+ bebob->registered = true;281281+282282+ return;283283+error:284284+ mutex_unlock(&devices_mutex);285285+ snd_bebob_stream_destroy_duplex(bebob);286286+ snd_card_free(bebob->card);287287+ dev_info(&bebob->unit->device,288288+ "Sound card registration failed: %d\n", err);289289+}290290+291291+static int292292+bebob_probe(struct fw_unit *unit, const struct ieee1394_device_id *entry)293293+{294294+ struct snd_bebob *bebob;295295+ const struct snd_bebob_spec *spec;296296+297297+ if (entry->vendor_id == VEN_FOCUSRITE &&298298+ entry->model_id == MODEL_FOCUSRITE_SAFFIRE_BOTH)299299+ spec = get_saffire_spec(unit);300300+ else if (entry->vendor_id == VEN_MAUDIO1 &&301301+ entry->model_id == MODEL_MAUDIO_AUDIOPHILE_BOTH &&302302+ !check_audiophile_booted(unit))303303+ spec = NULL;304304+ else305305+ spec = (const struct snd_bebob_spec *)entry->driver_data;306306+307307+ if (spec == NULL) {308308+ if (entry->vendor_id == VEN_MAUDIO1 ||309309+ entry->vendor_id == VEN_MAUDIO2)310310+ return snd_bebob_maudio_load_firmware(unit);311311+ else312312+ return -ENODEV;313313+ }314314+315315+ /* Allocate this independent of sound card instance. */316316+ bebob = kzalloc(sizeof(struct snd_bebob), GFP_KERNEL);317317+ if (bebob == NULL)318318+ return -ENOMEM;319319+320320+ bebob->unit = fw_unit_get(unit);321321+ bebob->entry = entry;322322+ bebob->spec = spec;323323+ dev_set_drvdata(&unit->device, bebob);324324+325325+ mutex_init(&bebob->mutex);326326+ spin_lock_init(&bebob->lock);327327+ init_waitqueue_head(&bebob->hwdep_wait);328328+329329+ /* Allocate and register this sound card later. */330330+ INIT_DEFERRABLE_WORK(&bebob->dwork, do_registration);331331+332332+ if (entry->vendor_id != VEN_MAUDIO1 ||333333+ (entry->model_id != MODEL_MAUDIO_FW1814 &&334334+ entry->model_id != MODEL_MAUDIO_PROJECTMIX)) {335335+ snd_fw_schedule_registration(unit, &bebob->dwork);257336 } else {258337 /*259338 * This is a workaround. This bus reset seems to have an effect···324285 * signals from dbus and starts I/Os. To avoid I/Os till the325286 * future bus reset, registration is done in next update().326287 */327327- bebob->deferred_registration = true;328288 fw_schedule_bus_reset(fw_parent_device(bebob->unit)->card,329289 false, true);330290 }331291332332- dev_set_drvdata(&unit->device, bebob);333333-end:334334- mutex_unlock(&devices_mutex);335335- return err;336336-error:337337- mutex_unlock(&devices_mutex);338338- snd_card_free(card);339339- return err;292292+ return 0;340293}341294342295/*···355324 if (bebob == NULL)356325 return;357326358358- fcp_bus_reset(bebob->unit);359359-360360- if (bebob->deferred_registration) {361361- if (snd_card_register(bebob->card) < 0) {362362- snd_bebob_stream_destroy_duplex(bebob);363363- snd_card_free(bebob->card);364364- }365365- bebob->deferred_registration = false;366366- }327327+ /* Postpone a workqueue for deferred registration. */328328+ if (!bebob->registered)329329+ snd_fw_schedule_registration(unit, &bebob->dwork);330330+ else331331+ fcp_bus_reset(bebob->unit);367332}368333369334static void bebob_remove(struct fw_unit *unit)···369342 if (bebob == NULL)370343 return;371344372372- /* No need to wait for releasing card object in this context. */373373- snd_card_free_when_closed(bebob->card);345345+ /*346346+ * Confirm to stop the work for registration before the sound card is347347+ * going to be released. The work is not scheduled again because bus348348+ * reset handler is not called anymore.349349+ */350350+ cancel_delayed_work_sync(&bebob->dwork);351351+352352+ if (bebob->registered) {353353+ /* No need to wait for releasing card object in this context. */354354+ snd_card_free_when_closed(bebob->card);355355+ } else {356356+ /* Don't forget this case. */357357+ bebob_free(bebob);358358+ }374359}375360376361static const struct snd_bebob_rate_spec normal_rate_spec = {
+4-2
sound/firewire/bebob/bebob.h
···8383 struct mutex mutex;8484 spinlock_t lock;85858686+ bool registered;8787+ struct delayed_work dwork;8888+8989+ const struct ieee1394_device_id *entry;8690 const struct snd_bebob_spec *spec;87918892 unsigned int midi_input_ports;···94909591 bool connected;96929797- struct amdtp_stream *master;9893 struct amdtp_stream tx_stream;9994 struct amdtp_stream rx_stream;10095 struct cmp_connection out_conn;···114111115112 /* for M-Audio special devices */116113 void *maudio_special_quirk;117117- bool deferred_registration;118114119115 /* For BeBoB version quirk. */120116 unsigned int version;
+26-75
sound/firewire/bebob/bebob_stream.c
···484484}485485486486static int487487-get_sync_mode(struct snd_bebob *bebob, enum cip_flags *sync_mode)488488-{489489- enum snd_bebob_clock_type src;490490- int err;491491-492492- err = snd_bebob_stream_get_clock_src(bebob, &src);493493- if (err < 0)494494- return err;495495-496496- switch (src) {497497- case SND_BEBOB_CLOCK_TYPE_INTERNAL:498498- case SND_BEBOB_CLOCK_TYPE_EXTERNAL:499499- *sync_mode = CIP_SYNC_TO_DEVICE;500500- break;501501- default:502502- case SND_BEBOB_CLOCK_TYPE_SYT:503503- *sync_mode = 0;504504- break;505505- }506506-507507- return 0;508508-}509509-510510-static int511487start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream,512488 unsigned int rate)513489{···526550 goto end;527551 }528552529529- bebob->tx_stream.flags |= CIP_SKIP_INIT_DBC_CHECK;530530-531553 /*532554 * BeBoB v3 transfers packets with these qurks:533555 * - In the beginning of streaming, the value of dbc is incremented···558584int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate)559585{560586 const struct snd_bebob_rate_spec *rate_spec = bebob->spec->rate;561561- struct amdtp_stream *master, *slave;562562- enum cip_flags sync_mode;563587 unsigned int curr_rate;564588 int err = 0;565589···565593 if (bebob->substreams_counter == 0)566594 goto end;567595568568- err = get_sync_mode(bebob, &sync_mode);569569- if (err < 0)570570- goto end;571571- if (sync_mode == CIP_SYNC_TO_DEVICE) {572572- master = &bebob->tx_stream;573573- slave = &bebob->rx_stream;574574- } else {575575- master = &bebob->rx_stream;576576- slave = &bebob->tx_stream;577577- }578578-579596 /*580597 * Considering JACK/FFADO streaming:581598 * TODO: This can be removed hwdep functionality becomes popular.582599 */583583- err = check_connection_used_by_others(bebob, master);600600+ err = check_connection_used_by_others(bebob, &bebob->rx_stream);584601 if (err < 0)585602 goto end;586603···579618 * At bus reset, connections should not be broken here. So streams need580619 * to be re-started. This is a reason to use SKIP_INIT_DBC_CHECK flag.581620 */582582- if (amdtp_streaming_error(master))583583- amdtp_stream_stop(master);584584- if (amdtp_streaming_error(slave))585585- amdtp_stream_stop(slave);586586- if (!amdtp_stream_running(master) && !amdtp_stream_running(slave))621621+ if (amdtp_streaming_error(&bebob->rx_stream))622622+ amdtp_stream_stop(&bebob->rx_stream);623623+ if (amdtp_streaming_error(&bebob->tx_stream))624624+ amdtp_stream_stop(&bebob->tx_stream);625625+ if (!amdtp_stream_running(&bebob->rx_stream) &&626626+ !amdtp_stream_running(&bebob->tx_stream))587627 break_both_connections(bebob);588628589629 /* stop streams if rate is different */···597635 if (rate == 0)598636 rate = curr_rate;599637 if (rate != curr_rate) {600600- amdtp_stream_stop(master);601601- amdtp_stream_stop(slave);638638+ amdtp_stream_stop(&bebob->rx_stream);639639+ amdtp_stream_stop(&bebob->tx_stream);602640 break_both_connections(bebob);603641 }604642605643 /* master should be always running */606606- if (!amdtp_stream_running(master)) {607607- amdtp_stream_set_sync(sync_mode, master, slave);608608- bebob->master = master;609609-644644+ if (!amdtp_stream_running(&bebob->rx_stream)) {610645 /*611646 * NOTE:612647 * If establishing connections at first, Yamaha GO46···625666 if (err < 0)626667 goto end;627668628628- err = start_stream(bebob, master, rate);669669+ err = start_stream(bebob, &bebob->rx_stream, rate);629670 if (err < 0) {630671 dev_err(&bebob->unit->device,631672 "fail to run AMDTP master stream:%d\n", err);···644685 dev_err(&bebob->unit->device,645686 "fail to ensure sampling rate: %d\n",646687 err);647647- amdtp_stream_stop(master);688688+ amdtp_stream_stop(&bebob->rx_stream);648689 break_both_connections(bebob);649690 goto end;650691 }651692 }652693653694 /* wait first callback */654654- if (!amdtp_stream_wait_callback(master, CALLBACK_TIMEOUT)) {655655- amdtp_stream_stop(master);695695+ if (!amdtp_stream_wait_callback(&bebob->rx_stream,696696+ CALLBACK_TIMEOUT)) {697697+ amdtp_stream_stop(&bebob->rx_stream);656698 break_both_connections(bebob);657699 err = -ETIMEDOUT;658700 goto end;···661701 }662702663703 /* start slave if needed */664664- if (!amdtp_stream_running(slave)) {665665- err = start_stream(bebob, slave, rate);704704+ if (!amdtp_stream_running(&bebob->tx_stream)) {705705+ err = start_stream(bebob, &bebob->tx_stream, rate);666706 if (err < 0) {667707 dev_err(&bebob->unit->device,668708 "fail to run AMDTP slave stream:%d\n", err);669669- amdtp_stream_stop(master);709709+ amdtp_stream_stop(&bebob->rx_stream);670710 break_both_connections(bebob);671711 goto end;672712 }673713674714 /* wait first callback */675675- if (!amdtp_stream_wait_callback(slave, CALLBACK_TIMEOUT)) {676676- amdtp_stream_stop(slave);677677- amdtp_stream_stop(master);715715+ if (!amdtp_stream_wait_callback(&bebob->tx_stream,716716+ CALLBACK_TIMEOUT)) {717717+ amdtp_stream_stop(&bebob->tx_stream);718718+ amdtp_stream_stop(&bebob->rx_stream);678719 break_both_connections(bebob);679720 err = -ETIMEDOUT;680721 }···686725687726void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob)688727{689689- struct amdtp_stream *master, *slave;690690-691691- if (bebob->master == &bebob->rx_stream) {692692- slave = &bebob->tx_stream;693693- master = &bebob->rx_stream;694694- } else {695695- slave = &bebob->rx_stream;696696- master = &bebob->tx_stream;697697- }698698-699728 if (bebob->substreams_counter == 0) {700700- amdtp_stream_pcm_abort(master);701701- amdtp_stream_stop(master);729729+ amdtp_stream_pcm_abort(&bebob->rx_stream);730730+ amdtp_stream_stop(&bebob->rx_stream);702731703703- amdtp_stream_pcm_abort(slave);704704- amdtp_stream_stop(slave);732732+ amdtp_stream_pcm_abort(&bebob->tx_stream);733733+ amdtp_stream_stop(&bebob->tx_stream);705734706735 break_both_connections(bebob);707736 }
+15-26
sound/firewire/dice/dice.c
···2020#define WEISS_CATEGORY_ID 0x002121#define LOUD_CATEGORY_ID 0x1022222323-#define PROBE_DELAY_MS (2 * MSEC_PER_SEC)2424-2523/*2624 * Some models support several isochronous channels, while these streams are not2725 * always available. In this case, add the model name to this list.···199201200202 dice_card_strings(dice);201203204204+ err = snd_dice_stream_init_duplex(dice);205205+ if (err < 0)206206+ goto error;207207+202208 snd_dice_create_proc(dice);203209204210 err = snd_dice_create_pcm(dice);···231229232230 return;233231error:232232+ snd_dice_stream_destroy_duplex(dice);234233 snd_dice_transaction_destroy(dice);234234+ snd_dice_stream_destroy_duplex(dice);235235 snd_card_free(dice->card);236236 dev_info(&dice->unit->device,237237 "Sound card registration failed: %d\n", err);238238-}239239-240240-static void schedule_registration(struct snd_dice *dice)241241-{242242- struct fw_card *fw_card = fw_parent_device(dice->unit)->card;243243- u64 now, delay;244244-245245- now = get_jiffies_64();246246- delay = fw_card->reset_jiffies + msecs_to_jiffies(PROBE_DELAY_MS);247247-248248- if (time_after64(delay, now))249249- delay -= now;250250- else251251- delay = 0;252252-253253- mod_delayed_work(system_wq, &dice->dwork, delay);254238}255239256240static int dice_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)···261273 init_completion(&dice->clock_accepted);262274 init_waitqueue_head(&dice->hwdep_wait);263275264264- err = snd_dice_stream_init_duplex(dice);265265- if (err < 0) {266266- dice_free(dice);267267- return err;268268- }269269-270276 /* Allocate and register this sound card later. */271277 INIT_DEFERRABLE_WORK(&dice->dwork, do_registration);272272- schedule_registration(dice);278278+ snd_fw_schedule_registration(unit, &dice->dwork);273279274280 return 0;275281}···294312295313 /* Postpone a workqueue for deferred registration. */296314 if (!dice->registered)297297- schedule_registration(dice);315315+ snd_fw_schedule_registration(unit, &dice->dwork);298316299317 /* The handler address register becomes initialized. */300318 snd_dice_transaction_reinit(dice);···316334 {317335 .match_flags = IEEE1394_MATCH_VERSION,318336 .version = DICE_INTERFACE,337337+ },338338+ /* M-Audio Profire 610/2626 has a different value in version field. */339339+ {340340+ .match_flags = IEEE1394_MATCH_VENDOR_ID |341341+ IEEE1394_MATCH_SPECIFIER_ID,342342+ .vendor_id = 0x000d6c,343343+ .specifier_id = 0x000d6c,319344 },320345 { }321346};
+1-1
sound/firewire/digi00x/amdtp-dot.c
···421421422422 /* Use different mode between incoming/outgoing. */423423 if (dir == AMDTP_IN_STREAM) {424424- flags = CIP_NONBLOCKING | CIP_SKIP_INIT_DBC_CHECK;424424+ flags = CIP_NONBLOCKING;425425 process_data_blocks = process_tx_data_blocks;426426 } else {427427 flags = CIP_BLOCKING;
···121121}122122123123static int124124-get_sync_mode(struct snd_efw *efw, enum cip_flags *sync_mode)125125-{126126- enum snd_efw_clock_source clock_source;127127- int err;128128-129129- err = snd_efw_command_get_clock_source(efw, &clock_source);130130- if (err < 0)131131- return err;132132-133133- if (clock_source == SND_EFW_CLOCK_SOURCE_SYTMATCH)134134- return -ENOSYS;135135-136136- *sync_mode = CIP_SYNC_TO_DEVICE;137137- return 0;138138-}139139-140140-static int141124check_connection_used_by_others(struct snd_efw *efw, struct amdtp_stream *s)142125{143126 struct cmp_connection *conn;···191208192209int snd_efw_stream_start_duplex(struct snd_efw *efw, unsigned int rate)193210{194194- struct amdtp_stream *master, *slave;195195- unsigned int slave_substreams;196196- enum cip_flags sync_mode;197211 unsigned int curr_rate;198212 int err = 0;199213···198218 if (efw->playback_substreams == 0 && efw->capture_substreams == 0)199219 goto end;200220201201- err = get_sync_mode(efw, &sync_mode);202202- if (err < 0)203203- goto end;204204- if (sync_mode == CIP_SYNC_TO_DEVICE) {205205- master = &efw->tx_stream;206206- slave = &efw->rx_stream;207207- slave_substreams = efw->playback_substreams;208208- } else {209209- master = &efw->rx_stream;210210- slave = &efw->tx_stream;211211- slave_substreams = efw->capture_substreams;212212- }213213-214221 /*215222 * Considering JACK/FFADO streaming:216223 * TODO: This can be removed hwdep functionality becomes popular.217224 */218218- err = check_connection_used_by_others(efw, master);225225+ err = check_connection_used_by_others(efw, &efw->rx_stream);219226 if (err < 0)220227 goto end;221228222229 /* packet queueing error */223223- if (amdtp_streaming_error(slave))224224- stop_stream(efw, slave);225225- if (amdtp_streaming_error(master))226226- stop_stream(efw, master);230230+ if (amdtp_streaming_error(&efw->tx_stream))231231+ stop_stream(efw, &efw->tx_stream);232232+ if (amdtp_streaming_error(&efw->rx_stream))233233+ stop_stream(efw, &efw->rx_stream);227234228235 /* stop streams if rate is different */229236 err = snd_efw_command_get_sampling_rate(efw, &curr_rate);···219252 if (rate == 0)220253 rate = curr_rate;221254 if (rate != curr_rate) {222222- stop_stream(efw, slave);223223- stop_stream(efw, master);255255+ stop_stream(efw, &efw->tx_stream);256256+ stop_stream(efw, &efw->rx_stream);224257 }225258226259 /* master should be always running */227227- if (!amdtp_stream_running(master)) {228228- amdtp_stream_set_sync(sync_mode, master, slave);229229- efw->master = master;230230-260260+ if (!amdtp_stream_running(&efw->rx_stream)) {231261 err = snd_efw_command_set_sampling_rate(efw, rate);232262 if (err < 0)233263 goto end;234264235235- err = start_stream(efw, master, rate);265265+ err = start_stream(efw, &efw->rx_stream, rate);236266 if (err < 0) {237267 dev_err(&efw->unit->device,238268 "fail to start AMDTP master stream:%d\n", err);···238274 }239275240276 /* start slave if needed */241241- if (slave_substreams > 0 && !amdtp_stream_running(slave)) {242242- err = start_stream(efw, slave, rate);277277+ if (efw->capture_substreams > 0 &&278278+ !amdtp_stream_running(&efw->tx_stream)) {279279+ err = start_stream(efw, &efw->tx_stream, rate);243280 if (err < 0) {244281 dev_err(&efw->unit->device,245282 "fail to start AMDTP slave stream:%d\n", err);246246- stop_stream(efw, master);283283+ stop_stream(efw, &efw->rx_stream);247284 }248285 }249286end:···253288254289void snd_efw_stream_stop_duplex(struct snd_efw *efw)255290{256256- struct amdtp_stream *master, *slave;257257- unsigned int master_substreams, slave_substreams;291291+ if (efw->capture_substreams == 0) {292292+ stop_stream(efw, &efw->tx_stream);258293259259- if (efw->master == &efw->rx_stream) {260260- slave = &efw->tx_stream;261261- master = &efw->rx_stream;262262- slave_substreams = efw->capture_substreams;263263- master_substreams = efw->playback_substreams;264264- } else {265265- slave = &efw->rx_stream;266266- master = &efw->tx_stream;267267- slave_substreams = efw->playback_substreams;268268- master_substreams = efw->capture_substreams;269269- }270270-271271- if (slave_substreams == 0) {272272- stop_stream(efw, slave);273273-274274- if (master_substreams == 0)275275- stop_stream(efw, master);294294+ if (efw->playback_substreams == 0)295295+ stop_stream(efw, &efw->rx_stream);276296 }277297}278298
+32
sound/firewire/lib.c
···6767}6868EXPORT_SYMBOL(snd_fw_transaction);69697070+#define PROBE_DELAY_MS (2 * MSEC_PER_SEC)7171+7272+/**7373+ * snd_fw_schedule_registration - schedule work for sound card registration7474+ * @unit: an instance for unit on IEEE 1394 bus7575+ * @dwork: delayed work with callback function7676+ *7777+ * This function is not designed for general purposes. When new unit is7878+ * connected to IEEE 1394 bus, the bus is under bus-reset state because of7979+ * topological change. In this state, units tend to fail both of asynchronous8080+ * and isochronous communication. To avoid this problem, this function is used8181+ * to postpone sound card registration after the state. The callers must8282+ * set up instance of delayed work in advance.8383+ */8484+void snd_fw_schedule_registration(struct fw_unit *unit,8585+ struct delayed_work *dwork)8686+{8787+ u64 now, delay;8888+8989+ now = get_jiffies_64();9090+ delay = fw_parent_device(unit)->card->reset_jiffies9191+ + msecs_to_jiffies(PROBE_DELAY_MS);9292+9393+ if (time_after64(delay, now))9494+ delay -= now;9595+ else9696+ delay = 0;9797+9898+ mod_delayed_work(system_wq, dwork, delay);9999+}100100+EXPORT_SYMBOL(snd_fw_schedule_registration);101101+70102static void async_midi_port_callback(struct fw_card *card, int rcode,71103 void *data, size_t length,72104 void *callback_data)
···242242 * blocks than IEC 61883-6 defines.243243 */244244 if (stream == &oxfw->tx_stream) {245245- oxfw->tx_stream.flags |= CIP_SKIP_INIT_DBC_CHECK |246246- CIP_JUMBO_PAYLOAD;245245+ oxfw->tx_stream.flags |= CIP_JUMBO_PAYLOAD;247246 if (oxfw->wrong_dbs)248247 oxfw->tx_stream.flags |= CIP_WRONG_DBS;249248 }
+100-55
sound/firewire/oxfw/oxfw.c
···118118 return err;119119}120120121121-/*122122- * This module releases the FireWire unit data after all ALSA character devices123123- * are released by applications. This is for releasing stream data or finishing124124- * transactions safely. Thus at returning from .remove(), this module still keep125125- * references for the unit.126126- */127127-static void oxfw_card_free(struct snd_card *card)121121+static void oxfw_free(struct snd_oxfw *oxfw)128122{129129- struct snd_oxfw *oxfw = card->private_data;130123 unsigned int i;131124132125 snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);···135142136143 kfree(oxfw->spec);137144 mutex_destroy(&oxfw->mutex);145145+}146146+147147+/*148148+ * This module releases the FireWire unit data after all ALSA character devices149149+ * are released by applications. This is for releasing stream data or finishing150150+ * transactions safely. Thus at returning from .remove(), this module still keep151151+ * references for the unit.152152+ */153153+static void oxfw_card_free(struct snd_card *card)154154+{155155+ oxfw_free(card->private_data);138156}139157140158static int detect_quirks(struct snd_oxfw *oxfw)···209205 return 0;210206}211207212212-static int oxfw_probe(struct fw_unit *unit,213213- const struct ieee1394_device_id *entry)208208+static void do_registration(struct work_struct *work)214209{215215- struct snd_card *card;216216- struct snd_oxfw *oxfw;210210+ struct snd_oxfw *oxfw = container_of(work, struct snd_oxfw, dwork.work);217211 int err;218212219219- if (entry->vendor_id == VENDOR_LOUD && !detect_loud_models(unit))220220- return -ENODEV;213213+ if (oxfw->registered)214214+ return;221215222222- err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,223223- sizeof(*oxfw), &card);216216+ err = snd_card_new(&oxfw->unit->device, -1, NULL, THIS_MODULE, 0,217217+ &oxfw->card);224218 if (err < 0)225225- return err;226226-227227- card->private_free = oxfw_card_free;228228- oxfw = card->private_data;229229- oxfw->card = card;230230- mutex_init(&oxfw->mutex);231231- oxfw->unit = fw_unit_get(unit);232232- oxfw->entry = entry;233233- spin_lock_init(&oxfw->lock);234234- init_waitqueue_head(&oxfw->hwdep_wait);235235-236236- err = snd_oxfw_stream_discover(oxfw);237237- if (err < 0)238238- goto error;219219+ return;239220240221 err = name_card(oxfw);241222 if (err < 0)···229240 err = detect_quirks(oxfw);230241 if (err < 0)231242 goto error;243243+244244+ err = snd_oxfw_stream_discover(oxfw);245245+ if (err < 0)246246+ goto error;247247+248248+ err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->rx_stream);249249+ if (err < 0)250250+ goto error;251251+ if (oxfw->has_output) {252252+ err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->tx_stream);253253+ if (err < 0)254254+ goto error;255255+ }232256233257 err = snd_oxfw_create_pcm(oxfw);234258 if (err < 0)···257255 if (err < 0)258256 goto error;259257260260- err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->rx_stream);258258+ err = snd_card_register(oxfw->card);261259 if (err < 0)262260 goto error;263263- if (oxfw->has_output) {264264- err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->tx_stream);265265- if (err < 0)266266- goto error;267267- }268261269269- err = snd_card_register(card);270270- if (err < 0) {271271- snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);272272- if (oxfw->has_output)273273- snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);274274- goto error;275275- }262262+ /*263263+ * After registered, oxfw instance can be released corresponding to264264+ * releasing the sound card instance.265265+ */266266+ oxfw->card->private_free = oxfw_card_free;267267+ oxfw->card->private_data = oxfw;268268+ oxfw->registered = true;269269+270270+ return;271271+error:272272+ snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);273273+ if (oxfw->has_output)274274+ snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);275275+ snd_card_free(oxfw->card);276276+ dev_info(&oxfw->unit->device,277277+ "Sound card registration failed: %d\n", err);278278+}279279+280280+static int oxfw_probe(struct fw_unit *unit,281281+ const struct ieee1394_device_id *entry)282282+{283283+ struct snd_oxfw *oxfw;284284+285285+ if (entry->vendor_id == VENDOR_LOUD && !detect_loud_models(unit))286286+ return -ENODEV;287287+288288+ /* Allocate this independent of sound card instance. */289289+ oxfw = kzalloc(sizeof(struct snd_oxfw), GFP_KERNEL);290290+ if (oxfw == NULL)291291+ return -ENOMEM;292292+293293+ oxfw->entry = entry;294294+ oxfw->unit = fw_unit_get(unit);276295 dev_set_drvdata(&unit->device, oxfw);277296297297+ mutex_init(&oxfw->mutex);298298+ spin_lock_init(&oxfw->lock);299299+ init_waitqueue_head(&oxfw->hwdep_wait);300300+301301+ /* Allocate and register this sound card later. */302302+ INIT_DEFERRABLE_WORK(&oxfw->dwork, do_registration);303303+ snd_fw_schedule_registration(unit, &oxfw->dwork);304304+278305 return 0;279279-error:280280- snd_card_free(card);281281- return err;282306}283307284308static void oxfw_bus_reset(struct fw_unit *unit)285309{286310 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device);287311312312+ if (!oxfw->registered)313313+ snd_fw_schedule_registration(unit, &oxfw->dwork);314314+288315 fcp_bus_reset(oxfw->unit);289316290290- mutex_lock(&oxfw->mutex);317317+ if (oxfw->registered) {318318+ mutex_lock(&oxfw->mutex);291319292292- snd_oxfw_stream_update_simplex(oxfw, &oxfw->rx_stream);293293- if (oxfw->has_output)294294- snd_oxfw_stream_update_simplex(oxfw, &oxfw->tx_stream);320320+ snd_oxfw_stream_update_simplex(oxfw, &oxfw->rx_stream);321321+ if (oxfw->has_output)322322+ snd_oxfw_stream_update_simplex(oxfw, &oxfw->tx_stream);295323296296- mutex_unlock(&oxfw->mutex);324324+ mutex_unlock(&oxfw->mutex);297325298298- if (oxfw->entry->vendor_id == OUI_STANTON)299299- snd_oxfw_scs1x_update(oxfw);326326+ if (oxfw->entry->vendor_id == OUI_STANTON)327327+ snd_oxfw_scs1x_update(oxfw);328328+ }300329}301330302331static void oxfw_remove(struct fw_unit *unit)303332{304333 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device);305334306306- /* No need to wait for releasing card object in this context. */307307- snd_card_free_when_closed(oxfw->card);335335+ /*336336+ * Confirm to stop the work for registration before the sound card is337337+ * going to be released. The work is not scheduled again because bus338338+ * reset handler is not called anymore.339339+ */340340+ cancel_delayed_work_sync(&oxfw->dwork);341341+342342+ if (oxfw->registered) {343343+ /* No need to wait for releasing card object in this context. */344344+ snd_card_free_when_closed(oxfw->card);345345+ } else {346346+ /* Don't forget this case. */347347+ oxfw_free(oxfw);348348+ }308349}309350310351static const struct compat_info griffin_firewave = {
···8080}8181EXPORT_SYMBOL_GPL(snd_hdac_bus_init_cmd_io);82828383+/* wait for cmd dmas till they are stopped */8484+static void hdac_wait_for_cmd_dmas(struct hdac_bus *bus)8585+{8686+ unsigned long timeout;8787+8888+ timeout = jiffies + msecs_to_jiffies(100);8989+ while ((snd_hdac_chip_readb(bus, RIRBCTL) & AZX_RBCTL_DMA_EN)9090+ && time_before(jiffies, timeout))9191+ udelay(10);9292+9393+ timeout = jiffies + msecs_to_jiffies(100);9494+ while ((snd_hdac_chip_readb(bus, CORBCTL) & AZX_CORBCTL_RUN)9595+ && time_before(jiffies, timeout))9696+ udelay(10);9797+}9898+8399/**84100 * snd_hdac_bus_stop_cmd_io - clean up CORB/RIRB buffers85101 * @bus: HD-audio core bus···10690 /* disable ringbuffer DMAs */10791 snd_hdac_chip_writeb(bus, RIRBCTL, 0);10892 snd_hdac_chip_writeb(bus, CORBCTL, 0);9393+ hdac_wait_for_cmd_dmas(bus);10994 /* disable unsolicited responses */11095 snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, 0);11196 spin_unlock_irq(&bus->reg_lock);
+36-11
sound/hda/hdac_i915.c
···158158}159159EXPORT_SYMBOL_GPL(snd_hdac_i915_set_bclk);160160161161-/* There is a fixed mapping between audio pin node and display port162162- * on current Intel platforms:161161+/* There is a fixed mapping between audio pin node and display port.162162+ * on SNB, IVY, HSW, BSW, SKL, BXT, KBL:163163 * Pin Widget 5 - PORT B (port = 1 in i915 driver)164164 * Pin Widget 6 - PORT C (port = 2 in i915 driver)165165 * Pin Widget 7 - PORT D (port = 3 in i915 driver)166166+ *167167+ * on VLV, ILK:168168+ * Pin Widget 4 - PORT B (port = 1 in i915 driver)169169+ * Pin Widget 5 - PORT C (port = 2 in i915 driver)170170+ * Pin Widget 6 - PORT D (port = 3 in i915 driver)166171 */167167-static int pin2port(hda_nid_t pin_nid)172172+static int pin2port(struct hdac_device *codec, hda_nid_t pin_nid)168173{169169- if (WARN_ON(pin_nid < 5 || pin_nid > 7))174174+ int base_nid;175175+176176+ switch (codec->vendor_id) {177177+ case 0x80860054: /* ILK */178178+ case 0x80862804: /* ILK */179179+ case 0x80862882: /* VLV */180180+ base_nid = 3;181181+ break;182182+ default:183183+ base_nid = 4;184184+ break;185185+ }186186+187187+ if (WARN_ON(pin_nid <= base_nid || pin_nid > base_nid + 3))170188 return -1;171171- return pin_nid - 4;189189+ return pin_nid - base_nid;172190}173191174192/**175193 * snd_hdac_sync_audio_rate - Set N/CTS based on the sample rate176176- * @bus: HDA core bus194194+ * @codec: HDA codec177195 * @nid: the pin widget NID178196 * @rate: the sample rate to set179197 *···201183 * This function sets N/CTS value based on the given sample rate.202184 * Returns zero for success, or a negative error code.203185 */204204-int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid, int rate)186186+int snd_hdac_sync_audio_rate(struct hdac_device *codec, hda_nid_t nid, int rate)205187{188188+ struct hdac_bus *bus = codec->bus;206189 struct i915_audio_component *acomp = bus->audio_component;207190 int port;208191209192 if (!acomp || !acomp->ops || !acomp->ops->sync_audio_rate)210193 return -ENODEV;211211- port = pin2port(nid);194194+ port = pin2port(codec, nid);212195 if (port < 0)213196 return -EINVAL;214197 return acomp->ops->sync_audio_rate(acomp->dev, port, rate);···218199219200/**220201 * snd_hdac_acomp_get_eld - Get the audio state and ELD via component221221- * @bus: HDA core bus202202+ * @codec: HDA codec222203 * @nid: the pin widget NID223204 * @audio_enabled: the pointer to store the current audio state224205 * @buffer: the buffer pointer to store ELD bytes···236217 * thus it may be over @max_bytes. If it's over @max_bytes, it implies237218 * that only a part of ELD bytes have been fetched.238219 */239239-int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid,220220+int snd_hdac_acomp_get_eld(struct hdac_device *codec, hda_nid_t nid,240221 bool *audio_enabled, char *buffer, int max_bytes)241222{223223+ struct hdac_bus *bus = codec->bus;242224 struct i915_audio_component *acomp = bus->audio_component;243225 int port;244226245227 if (!acomp || !acomp->ops || !acomp->ops->get_eld)246228 return -ENODEV;247229248248- port = pin2port(nid);230230+ port = pin2port(codec, nid);249231 if (port < 0)250232 return -EINVAL;251233 return acomp->ops->get_eld(acomp->dev, port, audio_enabled,···358338 struct i915_audio_component *acomp;359339 int ret;360340341341+ if (WARN_ON(hdac_acomp))342342+ return -EBUSY;343343+361344 if (!i915_gfx_present())362345 return -ENODEV;363346···394371out_err:395372 kfree(acomp);396373 bus->audio_component = NULL;374374+ hdac_acomp = NULL;397375 dev_info(dev, "failed to add i915 component master (%d)\n", ret);398376399377 return ret;···428404429405 kfree(acomp);430406 bus->audio_component = NULL;407407+ hdac_acomp = NULL;431408432409 return 0;433410}
+40-4
sound/hda/hdmi_chmap.c
···625625 WARN_ON(count != channels);626626}627627628628+static int spk_mask_from_spk_alloc(int spk_alloc)629629+{630630+ int i;631631+ int spk_mask = eld_speaker_allocation_bits[0];632632+633633+ for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {634634+ if (spk_alloc & (1 << i))635635+ spk_mask |= eld_speaker_allocation_bits[i];636636+ }637637+638638+ return spk_mask;639639+}640640+628641static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,629642 unsigned int size, unsigned int __user *tlv)630643{631644 struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);632645 struct hdac_chmap *chmap = info->private_data;646646+ int pcm_idx = kcontrol->private_value;633647 unsigned int __user *dst;634648 int chs, count = 0;649649+ unsigned long max_chs;650650+ int type;651651+ int spk_alloc, spk_mask;635652636653 if (size < 8)637654 return -ENOMEM;···656639 return -EFAULT;657640 size -= 8;658641 dst = tlv + 2;659659- for (chs = 2; chs <= chmap->channels_max; chs++) {642642+643643+ spk_alloc = chmap->ops.get_spk_alloc(chmap->hdac, pcm_idx);644644+ spk_mask = spk_mask_from_spk_alloc(spk_alloc);645645+646646+ max_chs = hweight_long(spk_mask);647647+648648+ for (chs = 2; chs <= max_chs; chs++) {660649 int i;661650 struct hdac_cea_channel_speaker_allocation *cap;662651663652 cap = channel_allocations;664653 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) {665654 int chs_bytes = chs * 4;666666- int type = chmap->ops.chmap_cea_alloc_validate_get_type(667667- chmap, cap, chs);668655 unsigned int tlv_chmap[8];669656670670- if (type < 0)657657+ if (cap->channels != chs)671658 continue;659659+660660+ if (!(cap->spk_mask == (spk_mask & cap->spk_mask)))661661+ continue;662662+663663+ type = chmap->ops.chmap_cea_alloc_validate_get_type(664664+ chmap, cap, chs);665665+ if (type < 0)666666+ return -ENODEV;672667 if (size < 8)673668 return -ENOMEM;669669+674670 if (put_user(type, dst) ||675671 put_user(chs_bytes, dst + 1))676672 return -EFAULT;673673+677674 dst += 2;678675 size -= 8;679676 count += 8;677677+680678 if (size < chs_bytes)681679 return -ENOMEM;680680+682681 size -= chs_bytes;683682 count += chs_bytes;684683 chmap->ops.cea_alloc_to_tlv_chmap(chmap, cap,685684 tlv_chmap, chs);685685+686686 if (copy_to_user(dst, tlv_chmap, chs_bytes))687687 return -EFAULT;688688 dst += chs;689689 }690690 }691691+691692 if (put_user(count, tlv + 1))692693 return -EFAULT;694694+693695 return 0;694696}695697
···15481548 int val = 0;1549154915501550 spin_lock_irq(&ensoniq->reg_lock);15511551- if ((ensoniq->ctrl & ES_1371_GPIO_OUTM) >= 4)15511551+ if (ensoniq->ctrl & ES_1371_GPIO_OUT(4))15521552 val = 1;15531553 ucontrol->value.integer.value[0] = val;15541554 spin_unlock_irq(&ensoniq->reg_lock);
+7-3
sound/pci/hda/Kconfig
···5050 bool "Allow dynamic codec reconfiguration"5151 help5252 Say Y here to enable the HD-audio codec re-configuration feature.5353- This adds the sysfs interfaces to allow user to clear the whole5454- codec configuration, change the codec setup, add extra verbs,5555- and re-configure the codec dynamically.5353+ It allows user to clear the whole codec configuration, change the5454+ codec setup, add extra verbs, and re-configure the codec dynamically.5555+5656+ Note that this item alone doesn't provide the sysfs interface, but5757+ enables the feature just for the patch loader below.5858+ If you need the traditional sysfs entries for the manual interaction,5959+ turn on CONFIG_SND_HDA_HWDEP as well.56605761config SND_HDA_INPUT_BEEP5862 bool "Support digital beep via input layer"
···350350 case USB_SPEED_HIGH:351351 case USB_SPEED_WIRELESS:352352 case USB_SPEED_SUPER:353353+ case USB_SPEED_SUPER_PLUS:353354 break;354355 default:355356 dev_err(&dev->dev, "unknown device speed %d\n", snd_usb_get_speed(dev));···450449 break;451450 case USB_SPEED_SUPER:452451 strlcat(card->longname, ", super speed", sizeof(card->longname));452452+ break;453453+ case USB_SPEED_SUPER_PLUS:454454+ strlcat(card->longname, ", super speed plus", sizeof(card->longname));453455 break;454456 default:455457 break;
+4
sound/usb/clock.c
···309309 * support reading */310310 if (snd_usb_get_sample_rate_quirk(chip))311311 return 0;312312+ /* the firmware is likely buggy, don't repeat to fail too many times */313313+ if (chip->sample_rate_read_error > 2)314314+ return 0;312315313316 if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR,314317 USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN,···319316 data, sizeof(data))) < 0) {320317 dev_err(&dev->dev, "%d:%d: cannot get freq at ep %#x\n",321318 iface, fmt->altsetting, ep);319319+ chip->sample_rate_read_error++;322320 return 0; /* some devices don't support reading */323321 }324322
+1
sound/usb/helper.c
···120120 case USB_SPEED_HIGH:121121 case USB_SPEED_WIRELESS:122122 case USB_SPEED_SUPER:123123+ case USB_SPEED_SUPER_PLUS:123124 if (get_endpoint(alts, 0)->bInterval >= 1 &&124125 get_endpoint(alts, 0)->bInterval <= 4)125126 return get_endpoint(alts, 0)->bInterval - 1;
+1
sound/usb/midi.c
···911911 switch (snd_usb_get_speed(ep->umidi->dev)) {912912 case USB_SPEED_HIGH:913913 case USB_SPEED_SUPER:914914+ case USB_SPEED_SUPER_PLUS:914915 count = 1;915916 break;916917 default:
+76-2
sound/usb/mixer.c
···4545#include <linux/bitops.h>4646#include <linux/init.h>4747#include <linux/list.h>4848+#include <linux/log2.h>4849#include <linux/slab.h>4950#include <linux/string.h>5051#include <linux/usb.h>···13791378 snd_usb_mixer_add_control(&cval->head, kctl);13801379}1381138013811381+static int parse_clock_source_unit(struct mixer_build *state, int unitid,13821382+ void *_ftr)13831383+{13841384+ struct uac_clock_source_descriptor *hdr = _ftr;13851385+ struct usb_mixer_elem_info *cval;13861386+ struct snd_kcontrol *kctl;13871387+ char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];13881388+ int ret;13891389+13901390+ if (state->mixer->protocol != UAC_VERSION_2)13911391+ return -EINVAL;13921392+13931393+ if (hdr->bLength != sizeof(*hdr)) {13941394+ usb_audio_dbg(state->chip,13951395+ "Bogus clock source descriptor length of %d, ignoring.\n",13961396+ hdr->bLength);13971397+ return 0;13981398+ }13991399+14001400+ /*14011401+ * The only property of this unit we are interested in is the14021402+ * clock source validity. If that isn't readable, just bail out.14031403+ */14041404+ if (!uac2_control_is_readable(hdr->bmControls,14051405+ ilog2(UAC2_CS_CONTROL_CLOCK_VALID)))14061406+ return 0;14071407+14081408+ cval = kzalloc(sizeof(*cval), GFP_KERNEL);14091409+ if (!cval)14101410+ return -ENOMEM;14111411+14121412+ snd_usb_mixer_elem_init_std(&cval->head, state->mixer, hdr->bClockID);14131413+14141414+ cval->min = 0;14151415+ cval->max = 1;14161416+ cval->channels = 1;14171417+ cval->val_type = USB_MIXER_BOOLEAN;14181418+ cval->control = UAC2_CS_CONTROL_CLOCK_VALID;14191419+14201420+ if (uac2_control_is_writeable(hdr->bmControls,14211421+ ilog2(UAC2_CS_CONTROL_CLOCK_VALID)))14221422+ kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval);14231423+ else {14241424+ cval->master_readonly = 1;14251425+ kctl = snd_ctl_new1(&usb_feature_unit_ctl_ro, cval);14261426+ }14271427+14281428+ if (!kctl) {14291429+ kfree(cval);14301430+ return -ENOMEM;14311431+ }14321432+14331433+ kctl->private_free = snd_usb_mixer_elem_free;14341434+ ret = snd_usb_copy_string_desc(state, hdr->iClockSource,14351435+ name, sizeof(name));14361436+ if (ret > 0)14371437+ snprintf(kctl->id.name, sizeof(kctl->id.name),14381438+ "%s Validity", name);14391439+ else14401440+ snprintf(kctl->id.name, sizeof(kctl->id.name),14411441+ "Clock Source %d Validity", hdr->bClockID);14421442+14431443+ return snd_usb_mixer_add_control(&cval->head, kctl);14441444+}14451445+13821446/*13831447 * parse a feature unit13841448 *···2192212621932127 switch (p1[2]) {21942128 case UAC_INPUT_TERMINAL:21952195- case UAC2_CLOCK_SOURCE:21962129 return 0; /* NOP */21972130 case UAC_MIXER_UNIT:21982131 return parse_audio_mixer_unit(state, unitid, p1);21322132+ case UAC2_CLOCK_SOURCE:21332133+ return parse_clock_source_unit(state, unitid, p1);21992134 case UAC_SELECTOR_UNIT:22002135 case UAC2_CLOCK_SELECTOR:22012136 return parse_audio_selector_unit(state, unitid, p1);···23742307 __u8 unitid = (index >> 8) & 0xff;23752308 __u8 control = (value >> 8) & 0xff;23762309 __u8 channel = value & 0xff;23102310+ unsigned int count = 0;2377231123782312 if (channel >= MAX_CHANNELS) {23792313 usb_audio_dbg(mixer->chip,···23832315 return;23842316 }2385231723182318+ for (list = mixer->id_elems[unitid]; list; list = list->next_id_elem)23192319+ count++;23202320+23212321+ if (count == 0)23222322+ return;23232323+23862324 for (list = mixer->id_elems[unitid]; list; list = list->next_id_elem) {23872325 struct usb_mixer_elem_info *info;23882326···23962322 continue;2397232323982324 info = (struct usb_mixer_elem_info *)list;23992399- if (info->control != control)23252325+ if (count > 1 && info->control != control)24002326 continue;2401232724022328 switch (attribute) {
+1
sound/usb/usbaudio.h
···47474848 int num_interfaces;4949 int num_suspended_intf;5050+ int sample_rate_read_error;50515152 struct list_head pcm_list; /* list of pcm streams */5253 struct list_head ep_list; /* list of audio-related endpoints */